0 Replies Latest reply on Sep 27, 2006 9:36 PM by Alex Levine

    Getting Subject in EJB3 Session Bean

    Alex Levine Newbie

      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.