You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Renato Primavera <re...@ionicsoft.com> on 2004/06/30 15:46:54 UTC
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().getSecurityContext());
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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: How to get Roles in a Principal with JNDIRealm
Posted by Robert Harper <ro...@iat-cti.com>.
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:renato.primavera@ionicsoft.com]
> Sent: Wednesday, June 30, 2004 7:47 AM
> To: tomcat-user@jakarta.apache.org
> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org