It may be easier to use JMX and retrieve the role out of the user information from the user bean.
Robert S. Harper 801.265.8800 ex. 255 > -----Original Message----- > From: Renato Primavera [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 30, 2004 7:47 AM > To: [EMAIL PROTECTED] > Subject: How to get Roles in a Principal with JNDIRealm > > Hello All, > > > I'm using JNDIRealm to authenticate users and it's working well. > In my java code, I need to retrieve roles associated with the > authenticated user. > Here is a sample of this code : > > Subject s = > Subject.getSubject((AccessControlContext)System.getSecurityManager().getSecuri > tyContext()); > Principal p = (Principal)s.getPrincipals().toArray()[0]; > > The API only allows me to retrieve, on the Principal, the name (with the > getName accessor) of the user, not associated roles. > Nevertheless, when running the code in a debugger, the state of the > Principal object seems containing all needed informations (name, > password, realm, roles). > > Is there a (standard) way to retrieve these additional information ? > Or should I develop my own LDAP Realm (JAAS module) and extend the > Principal interface to add role notions ? > > Any help would be appreciated... > > RP > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]