| Author |
Jcaptcha support
|
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Hi, i found jcaptcha a few days ago and saw that jforum supports it.
I want to use it to validate the registration of new users in my site, but it is terribly documented, just the api and it is very complex.
I just have a form on a .html page, which uses javascript to validate the email of the user and then sends it to a servlet in order to register it with the database.
How can i use jcaptcha? I guess i would need to make the .html page a servlet instead. I just want to generate the image and output it to the .html page (i use freemarker too). I tried browsing your cvs, but it is too slow and somehow i can't do a checkout, not even with an account.
Thanks [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
See this class:
https://jforum.dev.java.net/source/browse/jforum/src/net/jforum/util/Captcha.java?rev=1.3&view=auto&content-type=text/vnd.viewcvs-markup
Here is what I do: first, the return of
is put into user's session. Then JForum will ask him to enter the magic phrase. After that, get the image from its session and call the method "validateResponse()" to check if it matches the challenge. It is done by the method "validateCaptchaResponse", in UserSession.java:
That's all. You can call the method "getChallenge();" to get a BufferedImage and write it to the Servlet. I do that using the method "writeCaptchaImage()", located in the class "Captcha.java".
Rafael [originally posted on jforum.net by Rafael Steil]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Much appreciated! Jcaptcha should really include a tutorial for beginners like me [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
BTW, what class calls createNewCaptcha() in UserSession.java?
Java.net doesn't seem to have a search in cvs option, and i can't checkout the source with
cvs -d :pserver:myusername@cvs.dev.java.net:/cvs login
Hope you release 2.1 soon so i can get it from sourceforge and answer my own questions [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Sorry, somehow the java.net cvs server makes the cvs client of macosx freeze. As soon as i checkout from my linux box it works ok. [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Anonymous wrote:BTW, what class calls createNewCaptcha() in UserSession.java?
Java.net doesn't seem to have a search in cvs option, and i can't checkout the source with
cvs -d :pserver:myusername@cvs.dev.java.net:/cvs login
Hope you release 2.1 soon so i can get it from sourceforge and answer my own questions
It's the "insert" method on "net.jforum.view.forum.UserAction"
Rafael [originally posted on jforum.net by Rafael Steil]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
See this :
http://luminal.gotdns.com/confluence/display/general/5+minutes+application+integration+tutorial [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
I tried that, but it doesn't work.
it has some bugs:
There is no method init() in super
BufferedImage challenge =
CaptchaServiceSingleton.getInstance().getImageChallengeForID(,
httpServletRequest.getLocale());
There is something missing before that comma, i guess it's captchaID
Anyway i added this to web.xml like the example says, but i called /mycontext/jcaptcha and it returns a 404.
Anyone has some tips? [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Whoops, i forgot to extend httpservlet
Aside from the bug in not putting captchaID, it works [originally posted on jforum.net by Anonymous]
|
 |
Migrated From Jforum.net
Ranch Hand
Joined: Apr 22, 2012
Posts: 17424
|
|
Another little bug :
isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId,
jcaptcha_validation);
validateResponseForID returns a Boolean, not boolean type, so you need to use .booleanValue() in that call
It really works this time [originally posted on jforum.net by Anonymous]
|
 |
 |
|
|
subject: Jcaptcha support
|
|
|