9 Replies Latest reply on May 8, 2013 5:02 AM by Bond Chan

    Error when getting Subject

    Paco Avila Newbie

      Hi, I've a authenticated web application. When I log on it, I should get the authenticated subject usign this code:

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

      But, subject is null.

      I've seen a workaround for this:

      Context ctx = new InitialContext();
      org.jboss.security.SubjectSecurityManager mgr = (org.jboss.security.SubjectSecurityManager)ctx.lookup("java:comp/env/security/securityMgr");
      Subject sub = mgr.getActiveSubject();

      but i want to know if it is a bug really or I'm doing an mistake.