Hi,
On Fri, Jan 15, 2010 at 2:35 PM, Caleb James DeLisle <
calebdelisle(a)lavabit.com> wrote:
Hello folks,
I have a proposed method for migrating the captcha plugin to a component.
I have posted a patch here:
http://jira.xwiki.org/jira/browse/XWIKI-4741
which contains the core modifications which I am proposing. Though I have
a patch, this is still in the design phase and I welcome anyone to suggest
changes.
ComponentRole: Captcha
/**
* Check if the solution to the captcha is correct.
*
* @param answer The provided solution.
* @return true if the solution is correct.
*/
boolean isAnswerCorrect(String answer);
May be I have understood wrong, but it seems only your velocity API (below)
provides a method signature like:
boolean isAnswerCorrect(String captchaId, String answer);
- Why not have this in component API? For an example, recaptcha works like
this. It needs both a challengeId as well as it's answer for it to validate
the response.
- This methods should probably declare an exception (e.g. unable to contact
recaptcha servers?)
Implementing components:
DefaultImageCaptchaAction
DefaultSoundCaptchaAction
The new DefaultImageCaptcha component can be used to solve captchas which
were downloaded through the old struts based jcaptcha plugin. Both
components
also implement org.xwiki.action.Action and when execute() is called, they
send a captcha to the response.
The components depend on the request and response in the container being
servlet request/response because
com.octo.captcha.module.web.image.ImageToJpegHelper
and com.octo.captcha.module.web.sound.SoundToWavHelper require
HttpServletRequest and
HttpServletResponse. Also to get the ID of the session in a way that is
compatible
with the old struts based method of getting captchas, an HttpServletRequest
is needed.
I am not happy with this design as it demands the use of the if instanceof
then cast
hack. I would like to hear any ideas about how to clean this up.
There is also a velocity initializer which provides a captcha service with:
/**
* Check if the solution to the captcha is correct.
*
* @param captchaName The name of the Captcha you are checking the
answer against
* @param answer The provided solution
* @return true if the solution is correct
* @throws UnsupportedOperationException If there is no captcha by the
name captchaName
*/
public boolean isAnswerCorrect(String captchaName, String answer) throws
UnsupportedOperationException
If this is a velocity API (it sounds like that), it should not throw an
exception, there is no way to catch it from velocity. It should probably
return false in case of an error (and set an error message inside the
context).
I'm a bit unclear about your proposal and in doubt whether I have understood
your proposal wrong. Please correct me if that is the case.
Thanks.
- Asiri
and
/** @return a List of the names of all registered classes implementing
{@link org.xwiki.captcha.Captcha}. */
public List<String> listCaptchaNames()
In my opinion the html should all be in the application side and the core
code
should not even know it's URL. I am working on an application and would be
interested to hear what requirements you think it should meet.
Sorry for the long mail, I am anxious to hear your ideas about this.
Caleb James DeLisle
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs