[jboss-user] [Security & JAAS/JBoss] - Getting Subject in EJB3 Session Bean

ablevine1 do-not-reply at jboss.com
Wed Sep 27 21:36:06 EDT 2006


I am trying to access the subject in an ejb3 session bean so that one of the Subject's Principal's can be used for some auditing information. 

My subjects have several different principals including emailAddress and subjectID.  When I make a call to SecurityAssociation.getSubject from within a session bean method it returns null .  How ever, when I make the same call from an interceptor on the session method, the call returns the subject fine.  Why then can I not access the subject from within the session bean method itself??

I have also tried using:
Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
  | 

but that also returns null.

I also tried calling SecurityAssociation.getPrincipal and from within the session bean method and it works but returns the emailAddress Principal, while the subjectID Principal is the one that I need.  Possibly, just getting this call to return the subjectID Principal instead of the emailAddress Principal  would also be a viable solution to my problem.

Any suggestions would be appreciated.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974728#3974728

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974728



More information about the jboss-user mailing list