Invalidating a session in jsf
Lets now look in detail as how to create a JSF login logout authentication mechanism in JSF application. Step 1: Create the table Users in mysql database as Before we move on to our project related code, below image shows the project structure in Eclipse. Authentication mechanism allows users to have secure access to the application by validating the username and password. Step 5: Now create the Login DAO java class as below. We will be using JSF view for login, DAO object , Http Session for session management, JSF managed bean and mysql database. Note that database operations code is not optimized to be used in a real project, I wrote it as quickly as possible because the idea is to learn authentication in JSF applications. Just create a dynamic web project and convert it to maven to get the project stub and then keep on adding different components. Also a method is written to perform logout by invalidating HTTPSession attached.
Integrating Spring Security with Spring MVC Framework is very easy, because we already have Spring Beans configuration file. Once logout is successful, user should be sent back to login page as configured. The first one is that the login URL is “/j_spring_security_check“.
Once we will be done with all the changes, our application will look like below image. Here is our controller class that defines two URIs that we can access. They should be same as configured in the spring security configurations.and pages are simple, but we could have included some information here based on the user details.