0 Replies Latest reply on Mar 5, 2005 2:24 AM by Belal Juma

    Getting subject from Ejb container?

    Belal Juma Newbie


      I found there are 2 ways to get the subject from the ejb container,

      1) InitialContext ic = new InitialContext();
      Subject subject = (Subject)ic.lookup("java:comp/env/security/subject");

      2) AccessControlContext ctx = AccessController.getContext();
      Subject subject = Subject.getSubject(ctx);

      first option works successfully, but the second option fails (subject is null)!!

      which one is JAAS/J2EE standard? why the second one didn't work? and when and why to use either option?