I am looking for the right way to store and display additional details of a logged-in user through out my application using Spring Security.
For example, I want to show Welcome:Mr.Smith (Administrator, Math Dept) on top of every page. For this I want to obtain the prefix, last name, designation and dept for the logged in user.
I am using a custom UserDetails service to fetch a user from the database. While browsing, I found that Authentication has getDetails(), which can store additional details related to authentication, can I use that method to store additional details?
If yes can you show a simple example? Can I use AuthenticationSuccessHanlder to do this job, or am I looking at the problem in a completely wrong way? Should I not handle this in the spring security layer? where should I take care of it?
The extra details should be properties of a custom UserDetails class that your custom UserDetailsService returns from its loadUserByName method.