Skip to main content

Accessing the JAAS subject

2 replies [Last post]
erikengerd
Offline
Joined: 2007-10-13

Hi,

I would like to access the JAAS subject for an authenticated user. The JAAS approach

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

returns null. What is the correct method to access the subject?

Cheers
Erik

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

Or this:

Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");

erikengerd
Offline
Joined: 2007-10-13

I have just solved this problem myself.

The method is:

import javax.security.auth.Subject;

import com.sun.enterprise.security.SecurityContext;

Subject subject = SecurityContext.getCurrent().getSubject();