Hi,

On Sat, Jan 16, 2010 at 11:21 PM, Caleb James DeLisle <
[email protected]> wrote:

> Update:
> I have changed a few things in my copy of the code.
> I renamed the Captcha interface CaptchaVerifier because it is
> a component for verifying captchas of a certain type, not
> an individual captcha puzzle.
>
> I also named the id which is gotten from the request "userId" because
> it may be generated on a per-captcha basis and passed by a parameter
> depending on jcaptcha settings.
>
> From velocity the commands look like:
> #set($cv = $captchaservice.getCaptchaVerifier("defaultImageCaptcha"))
> #set($userId = $cv.getUserId($request))
> #if($cv.isAnswerCorrect($userId, $answer))
> ## Do whatever the captcha is protecting
> #else
> ## Show captcha image and ask for answer, submit button redirects to
> ## same page with answer given as parameter.
> #end
>
> isAnswerCorrect throws Exception but in Velocity getCaptchaVerifier
> returns a wrapper of the CaptchaVerifier which catches any Exception
> and returns false. It also switches null for "" in getUserId.
>

Sounds great!

Once you commit I'll try to implement a recaptcha version of the
CaptchaVerifier. This will be a good test case :)

PS: I hope I will have enough time ;)


>
> I have tried to build JCaptcha 2.0 from source but I am unable to as
> I use jdk 1.6 which fails with warnings for including com.sun.* classes
>
> Any ideas about what these functions should be named would be great:
> getUserId
> getCaptchaVerifier
>

I thought getCaptchaId() would make sense in case of recaptcha but
getUserId() might be more generic as you describe.

Thanks.

- Asiri


>
> Thanks,
>
> Caleb
>
>
>
> Caleb James DeLisle wrote:
> > I'm assuming you are referring to $captcha.getServletId($request)
> > I said getServletId because I couldn't think of a way a request could
> > yield any other type of id, maybe you can think of one?
> >
> > I do want to use captchaId for:
> > $captcha.isAnswerCorrect($servletId, $answer)
> >
> > the method would look like:
> > boolean isAnswerCorrect(String captchaId, String answer)
> >
> > In most implementations the servletId would be used as the captchaId.
> > On the one hand I feel like getServletId should be a function of the
> > $captchaservice but as you can see here:
> >
> http://www.docjar.com/html/api/com/octo/captcha/module/config/CaptchaModuleConfigHelper.java.html
> > If a configuration is set to ID_GENERATED=true then it uses a different
> method
> > (this is the function called by the struts jcaptcha action)
> >
> > Caleb
> >
> >
> > Asiri Rathnayake wrote:
> >> Hi Caleb,
> >>
> >> On Fri, Jan 15, 2010 at 4:21 PM, Caleb James DeLisle <
> >> [email protected]> wrote:
> >>
> >>> Whoops I made a mistake in my example:
> >>> How about:
> >>> #set($captcha = $captchaservice.getCaptcha("defaultImageCaptcha"))
> >>> #set($servletId = $captcha.getServletId($request))
> >>> $captcha.isAnswerCorrect($answer)
> >>>
> >>> should be:
> >>>
> >>> $captcha.isAnswerCorrect($servletId, $answer)
> >>>
> >> Why is it called servletId? shouldn't it be captchaId? Or may be I have
> >> misunderstood you.
> >>
> >>>>> $captchaservice.isAnswerCorrect($sessionId, $answer)
> >>>>> Yes. I believe here sessionId is generated by the captcha service for
> >>> each
> >>>>> captcha displayed? Or is it something else?
> >>>>>
> >>>>> I'm asking because recaptcha generates a unque captchaId for each
> >>> captcha it
> >>>>> generates. Then you need to handover this captchaId + user's answer
> to
> >>> the
> >>>>> server to verify the answer.
> >> May be my above question got commented out on your mail reader.
> >>
> >> Thanks.
> >>
> >> - Asiri
> >> _______________________________________________
> >> devs mailing list
> >> [email protected]
> >> http://lists.xwiki.org/mailman/listinfo/devs
> >>
> >
> > _______________________________________________
> > devs mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/devs
> >
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to