On Mar 13, 2009, at 10:24 AM, Jerome Velociter
wrote:
Vincent Massol wrote:
> On Mar 13, 2009, at 8:36 AM, Jerome Velociter wrote:
>
>> Hello Devs,
>>
>> I'm starting to think about the integration of JCaptcha 2.0
>>
(
http://forge.octo.com/jcaptcha/confluence/display/general/Simple+Servlet+In…
>> )
>> that would deprecated our current Captcha plugin.
>> I think we need it as a component, for example xwiki-captcha
>>
>> We can have a CaptchaedRequestValidator component interface that
>> declares the following method :
>>
>> boolean validateCaptcha(HttpServletRequest request);
>>
>> which would be called from the register action, comment add action,
>> etc.
>> (anywhere a captcha is needed - we could even expose a velocity
>> API if
>> we need it)
>>
>> WDYT ?
> Hmm. Is it possible not to have it not depend on any environment
> (servlet or other) or not? ie internally use the Execution Context
> and
> any passed parameters. This is important since captcha could be used
> in a variety of environments, be it portlets, servlets, maybe even
> web
> services although that would probably be done best with a token.
Hum, the portlet integration will have to be written if we want it.
What
JCaptcha provides is a simple servlet integration, i.e:
String userCaptchaResponse = request.getParameter("jcaptcha");
boolean captchaPassed =
SimpleImageCaptchaServlet.validateResponse(request,
userCaptchaResponse);
Well this can be made indep of the environment I think.
We could just pass an object with the data needed (the user captcha
response and whatever other data is required) and create an instance
of HttpServletRequest internally and pass it to jcaptcha.
What am I missing (I'm sure I'm missing something ;))?
The fact jcaptcha
internally keeps a generated challenge response
alongside with the session for which it has been generated. It's the
SimpleImageCaptchaServlet itself that offers the image:
<servlet>
<servlet-name>jcaptcha</servlet-name>
<servlet-class>com.octo.captcha.servlet.image.SimpleImageCaptchaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jcaptcha</servlet-name>
<url-pattern>/jcaptcha.jpg</url-pattern>
</servlet-mapping>
So for portlet we would have to do that same work too. In the end we can
abstract everything from the environment, but I can't see an easy way of
doing it without writing a "SimpleImageCaptchaPortlet"