This content has been marked as final.
Show 1 reply
-
1. Re: How to access Groups from a SessionContext
starksm64 Mar 23, 2004 9:59 AM (in response to aquila125)There is no standard api for accessing this information. You can obtain the Subject of the caller and look to its java.security.acl.Group instance called 'Roles' to find this out.
... // Check the java:comp/env/security/security-domain try { InitialContext ctx = new InitialContext(); Subject activeSubject = (Subject) ctx.lookup("java:comp/env/security/subject"); log.debug("ActiveSubject: "+activeSubject); if( activeSubject == null ) throw new EJBException("No ActiveSubject found"); // Get the roles from the Group("Roles") Set principals = activeSubject.getPrincipals(); ... } catch(NamingException e) { log.debug("failed", e); throw new EJBException("Naming exception: "+e.toString(true)); }