File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes captcha in login form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "captcha in login form" Watch "captcha in login form" New topic

captcha in login form

misha nesterenko

Joined: Feb 05, 2011
Posts: 28

I would like to add captcha to a login form, how can I implement it?
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1341

Although I have not implemented captcha in any login form, but , i do have some fair idea of it. So i am sharing my thoughts on it

a. captcha is any randon alphanumeric string used for authentication in login form. We can write a simple java class to generate random
aplhanumeric strings which can be shown on jsp page. I assume you know how to display a captcha string on jsp page and use it in validation in furthur processing after form submission.

b. you can use website like to have autogenerated captcha

Below mentioned is the link of a pdf from "Spring in Practice" book by Manning publication.
Refer to section 4.4 Use CAPTCHAs to prevent automated user account creation where it is mentioned how to use captcha in spring login form.

Hope all this explanation helps you

~ abhay

Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
misha nesterenko

Joined: Feb 05, 2011
Posts: 28
I have already done it.
I have used reCaptcha, no problems here. Main problem was to intercept authentication process to check captcha and reject authentication whenever that is necessary. I don't know if my way is the best one, so if there is better solution I would like to hear it . I had to declare my own authentication provider sublassed from DaoAuthenticationProvider and there I overrode additionalAuthenticationChecks, that is a place where I verify captcha. Moreover I subclassed WebAuthenticationDetails to save captcha from request for subsequent verification. That was a bit difficult to tie together, as I am new to spring and had to search internet for lots of things.
I agree. Here's the link:
subject: captcha in login form
It's not a secret anymore!