This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Spring and the fly likes Access spring user object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Access spring user object" Watch "Access spring user object" New topic
Author

Access spring user object

Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Access spring user object