voyent
ICEFaces + Spring + ReCaptcha  XML
Forum Index -> General Help
Author Message
apapadak

Joined: 20/Apr/2010 00:00:00
Messages: 7
Offline


Hello,


Implementing Captcha functionality with ICEFaces became a request in my application so I became involved in combining them.
Also, I've seen a couple of requests in the forums so I've uploaded a stripped version of my project with
a simple login page where I use Spring for authenticating the user (username="1", password="2") .

The main idea is as follows :

1) Call the actionListener of the submit button when the form is submitted.
2) Extract the ReCaptcha parameters from the HttpServletRequest like this :
String challenge = req.getParameter("recaptcha_challenge_field");
String response = req.getParameter("recaptcha_response_field");
3) Redirect to the pattern that will be served by the recaptcha servlet but ALSO adding to the parameters j_username and j_password for later j_spring_authentication:
FacesContext.getCurrentInstance().getExternalContext().redirect("/icefacesrecaptcha/checkcaptcha?recaptcha_challenge_field=" + challenge + "&recaptcha_response_field=" + response + "&j_username=" + userId + "&j_password=" + password);
4) Validating the ReCaptcha challenge&response in the ReCaptcha servlet and, if valid, redirect to the pattern that will be caught by the Spring authentication, namely, : /icefacesrecaptcha/j_spring_security_check?j_username=" + username + "&j_password=" + password


I'll be happy to have any follow-ups or improvements on this :-)


Antony

p.s. You have to supply YOUR public/private key where it is needed in the code.
 Filename icefacesrecaptcha.zip [Disk] Download
 Description
 Filesize 5540 Kbytes
 Downloaded:  153 time(s)

[Thumb - libraries.png]
 Filename libraries.png [Disk] Download
 Description
 Filesize 23 Kbytes
 Downloaded:  278 time(s)

 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team