-
1. Re: Retrieving user name
niwhsa Aug 16, 2005 12:47 AM (in response to tremalnaik)My guess is that in your JSP/servlet, the call to request.getUserPrincipal() is returning null.
If you are using a custom login module then you need to define a group named "CallerPrincipal" to which you can add your Principal impl class. If you do this then the request.getUserPrincipal() returns your custom Principal impl (of course you will need to cast it to your impl class).
HTH
Ashwin Karkala -
2. Re: Retrieving user name
tremalnaik Aug 16, 2005 3:57 AM (in response to tremalnaik)No, I'm able to fetch the user name from request, if I am in a JSP or whetever I can have access to the http request. I need to fetch user name if I don't have access to the request, i.e., from an helper class.
Is it possible doing it calling methods on mbean server service or security manager? I wasn't able to figure it out
thanks -
3. Re: Retrieving user name
soheil_has Aug 16, 2005 7:50 AM (in response to tremalnaik)May be this works for you!
SecurityAssociation.getPrincipal().getName() -
4. Re: Retrieving user name
tremalnaik Aug 16, 2005 11:01 AM (in response to tremalnaik)your method is simpler then what I figured out, certailnly:
Context securityCtx = null; AuthenticationManager securityMgr = null; InitialContext iniCtx = new InitialContext(); securityCtx = (Context) iniCtx.lookup("java:comp/env/security"); securityMgr = (AuthenticationManager) securityCtx.lookup("securityMgr"); Subject subject = securityMgr.getActiveSubject(); return subject.getPrincipals();
I'll try it, thanks