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,
Valery
Hello Valery,
As you have noticed, you can obtain the Principals 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 Subjects 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 Subjects instance in your EJB?
Best regards,
Lyubomir
Add a comment