lundi 30 mars 2015

spring security get user id from DB

I am using spring security for authentication and successfully able to get User object (org.springframework.security.core.userdetails.User) anywhere I need.


But I want UserId also, which is not there in spring's User object. So I create my own object(com.app.site.pojo.User). It has few additional variables like userId,user date of birth etc. Now I want spring security to use my user object instead of spring User object. and it should have all the details about that user.


I tried to type cast the user object to my object, it is throwing exception (It is obvious).


I dont want to make DB call again to get the userId from DB again.


How can I achieve it?


Aucun commentaire:

Enregistrer un commentaire