You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nathan Coast <na...@codeczar.com> on 2005/05/31 23:53:30 UTC

login events

Hi,

I'm guessing there's no 'official' mechanism within the servlet spec to 
identify when a user has logged in.  I've looked at the session 
lifecycle events but these relate to creating and destroying sessions 
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionListener.html 
  which happen independently of login.

Is there a prefered mechanism to detect when login occurs?  I'd like to 
set up various state variables and log the user login when a user logs in.

This is a solution I'm thinking of implementing.

1) Have a filter that detects the absence of a session variable.
2) If the variable is missing, call request.getUserPrincipal();
3) If user principal returned then user has logged in, set up vars log 
login etc.
4) If no user returned.  User has not yet logged in.

I'd be interested to hear how others have solved this problem.

I use my own implementation of a Realm class so I can detect login here 
but the Realm api has no access to the session or request so that 
doesn't really help.

cheers
Nathan

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org