Posts

Showing posts from December, 2013

Spring Security - Adding more information to the authenticated user.

I was using spring Security to perform authentication against the database and I needed to load the user information once the user gets authenticated. However, the spring org.springframework.security.core.userdetails.User object was not allowing me add more details to the logged in User object. In my case, I had to add phone number to the authenticated user. In the following section I'll show as to how to add additional information to the authenticated user. Create an object to contain the additional information. We will first create a MediUser object which will extend the Spring org.springframework.security.core.userdetails.User object. The MediUser object contains additional information like first name, middle name, last name, phone number and alternative phone number. Following is the code for MediUser : import java.util.Collection; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.