Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access spring user object

 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I am using default spring security authentication where my user and pasword are defined in application-contextsecurity.xml file. my security concerns are very limited and i am fine with this implementation. i just wanted to check if the user name is xyz i want to dipslay some links. how can i access teh user object i am using right now a static method but not comfortable with ti. is there any cleaner solution. Any advice
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep that is the only way to get the User Principal object.


But I don't see the need for the instanceof check. If your UserDetails object is of that type, and that is the only User object you have, then you will only get one that is of that type, so no need to do that check.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic