Spring Security with Captcha integration
Let us demonstrate the integration of Spring Security with Captcha. We have downloaded a Kaptcha.jar
Captcha provider for this purpose. We need to install the jar file into the maven local repository for the application to work.
The example is an extension of the previous recipe where an additional input, mobile number, was considered for authorization and authentication by Spring Security. In this example, we will get the code for username and password from the user along with the Captcha code. The username is authenticated against the database, and the requested Captcha and the Captcha entered by the user are also compared.
When the entire conditions match, the user is said to be authenticated or else the authentication is a failure.
Getting ready
- Add the
Kaptcha
servlet to theWeb.xml
file - Configure the custom filter in your
Springsecurity.xml
file - Update the
UserDetailsService
implementation class to handleKaptcha
- Update the
login.jsp
file to take...