Skip to Content
author's profile photo Former Member
Former Member

Accessing JAAS Subject in EJB

Hi All,

I'm trying to obtain JAAS Subject instance inside local EJB method invoked from WebDynpro application (authorization enforced).

The code to get Subject is the following:

Subject subject = Subject.getSubject(AccessController.getContext());

However, I unexpectively receives NULL. I try to debug application, and see that EJB code is executed within Subject.doAs method.

While I get NULL Subject, I'm able to get Principal object from EJB context, however.

So my question is what's wrong with accessing current Subject. Do I need to pass any additional parameters when creating InitialContext?

Thanks in advance,


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Aug 18, 2004 at 09:49 AM

    Hello Valery,

    As you have noticed, you can obtain the Principal’s instance. This is because the SessionContext allows it (there is an appropriate method), but the situation is not the same for the Subject.

    I think you cannot obtain the Subject’s instance from EJB.

    At the AccessControlContext (which you are obtaining from AccessController.getContext(), inside the EJB) the DomainCombiner is not an instance of SubjectDomainCombiner and that is the reason for receiving null Subject when doing

    Subject subject = Subject.getSubject (AccessController.getContext());

    (inside the EJB).

    Can you describe me why do you need exactly the Subject’s instance in your EJB?

    Best regards,


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.