Accessing User subject or User principal

2008-11-16 Thread Rob Mercer
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



Re: Accessing User subject or User principal

2008-11-16 Thread Michael Ludwig
Rob Mercer schrieb am 16.11.2008 um 12:24:00 (-0800):
 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?

You're supposed to access these values by calling getUserPrincipal() on
the HttpServletRequest object.

http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/

Michael Ludwig

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Accessing User subject or User principal

2008-11-16 Thread Rob Mercer
First off, thanks for the quick response!

 I've tried to make that call but keep getting null values back for
both the getUerPrincipal and getRemoteUser on the HttpServletRequest...
do I need to wait until the next request to make these calls or is it ok
to check them immediately after the commit is called?

-Rob

-Original Message-
From: Michael Ludwig [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 16, 2008 3:48 PM
To: Tomcat Users List
Subject: Re: Accessing User subject or User principal

Rob Mercer schrieb am 16.11.2008 um 12:24:00 (-0800):
 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?

You're supposed to access these values by calling getUserPrincipal() on
the HttpServletRequest object.

http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/

Michael Ludwig

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Accessing User subject or User principal

2008-11-16 Thread Mark Thomas
Rob Mercer wrote:
 First off, thanks for the quick response!
 
  I've tried to make that call but keep getting null values back for
 both the getUerPrincipal and getRemoteUser on the HttpServletRequest...
 do I need to wait until the next request to make these calls or is it ok
 to check them immediately after the commit is called?

It should work immediately. You might want to try a build from trunk as
there have been a number of JAAS fixes that will be in 6.0.19.

Mark

 
 -Rob
 
 -Original Message-
 From: Michael Ludwig [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, November 16, 2008 3:48 PM
 To: Tomcat Users List
 Subject: Re: Accessing User subject or User principal
 
 Rob Mercer schrieb am 16.11.2008 um 12:24:00 (-0800):
 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?
 
 You're supposed to access these values by calling getUserPrincipal() on
 the HttpServletRequest object.
 
 http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/
 
 Michael Ludwig
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]