Hey,

 

Tomcat 6.0.14, Vista BE

 

I'm trying to implement a JAAS Realm solution, I'm unable to after
setting the subject/principal figure out how I'm supposed to
programmatically access either of these values after they've been set in
my LoginModule's commit() call?

 

I verify that my custom login modules' commit is called (see below). My
question is how do I access the principal that's stored here?

 

      public boolean commit() throws LoginException {

            if (succeeded) {

                  if (subject.isReadOnly()){

                        throw new LoginException("Subject is
readonly!");

                  }

                  // add a Principal (authenticated identity)

                  // to the Subject

 

                  userPrincipal = new UserPrincipal(username);

 

                  assignPrincipal(userPrincipal);

                  

                  assignPrincipal(new
UserPrincipal(AccountRole.PATIENT.getCode()));

                  

                  // in any case, clean out state

                  username = null;

                  for (int i = 0; i < password.length; i++)

                        password[i] = ' ';

                  password = null;

 

                  commitSucceeded = true;

                  

            }

            return true;

      }

 

 

Then, somewhere else in the code (say on a page), I try to figure out
who's calling the code? And the getSubject() line returns null.

            try {

                  LoginContext lc2 = new LoginContext("Jaas");

                  lc2.getSubject();

            } catch(LoginException le ){

                  le.printStackTrace();

            }

 

 

Rob

Reply via email to