com.groiss.org
Class UserSessionManager

java.lang.Object
  extended by com.groiss.org.UserSessionManager
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionAttributeListener, javax.servlet.http.HttpSessionListener

public class UserSessionManager
extends java.lang.Object
implements javax.servlet.http.HttpSessionListener, javax.servlet.http.HttpSessionAttributeListener

Maintains user sessions


Field Summary
static short INFO
           
static short WARNING
           
 
Constructor Summary
UserSessionManager()
           
 
Method Summary
static boolean addPendingAction(short type, java.lang.String id, java.lang.String message)
          Add a pending action to the user session which is visible later via an icon in the toolbar.
 void attributeAdded(javax.servlet.http.HttpSessionBindingEvent arg0)
           
 void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent arg0)
           
 void attributeReplaced(javax.servlet.http.HttpSessionBindingEvent ev)
           
static void deleteUserSessions(int days)
          Delete all sessions older than the given dates
static void dumpSessions()
          on shutdown dump the last access dates
static java.util.Vector getActiveSessions()
          return the list of users currently logged in
static java.util.Vector getActiveSessions(java.lang.String node)
          return the list of users currently logged in at a node
static int getConcurrentUsers()
           
static java.lang.String getLoginMessage()
           
static int getMaxConcurrent(java.util.Date since, java.util.Date until)
           
static IUserSession getSessionById(java.lang.String sessionId)
          called when session are read from dumped file after restart.
static java.util.Vector getSessions(java.lang.Boolean active, java.util.Date since, java.util.Date until, com.dec.avw.core.User u)
          the sessions selected by date and/or user
static void init()
           
static void initSessions()
          On startup set namedUsers and put user session in httpSessions
static boolean isLoggedIn(com.dec.avw.core.User user)
           
static boolean isLoginAllowed()
           
static java.lang.String login(com.dec.avw.core.User user, java.lang.String ip)
          Called on login of a user
static void logout(java.lang.String sessionId)
          End the session with the given session id (if session is already finished, do nothing).
static void relogin(java.lang.String sessionId)
          called when session are read from dumped file after restart.
static void removeInactiveSessions()
          Performs a logout for all users, where the http session is expired.
static void removePendingAction(short type, java.lang.String id)
           
 void sessionCreated(javax.servlet.http.HttpSessionEvent e)
           
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent e)
           
static void setLoginAllowed(boolean allow, java.lang.String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFO

public static short INFO

WARNING

public static short WARNING
Constructor Detail

UserSessionManager

public UserSessionManager()
Method Detail

init

public static void init()

login

public static java.lang.String login(com.dec.avw.core.User user,
                                     java.lang.String ip)
Called on login of a user

Returns:
the session id

getSessionById

public static IUserSession getSessionById(java.lang.String sessionId)
                                   throws java.lang.Exception
called when session are read from dumped file after restart.

Throws:
java.lang.Exception

relogin

public static void relogin(java.lang.String sessionId)
                    throws java.lang.Exception
called when session are read from dumped file after restart.

Throws:
java.lang.Exception

logout

public static void logout(java.lang.String sessionId)
                   throws java.lang.Exception
End the session with the given session id (if session is already finished, do nothing).

Throws:
java.lang.Exception

getActiveSessions

public static java.util.Vector getActiveSessions()
return the list of users currently logged in


getActiveSessions

public static java.util.Vector getActiveSessions(java.lang.String node)
return the list of users currently logged in at a node


getMaxConcurrent

public static int getMaxConcurrent(java.util.Date since,
                                   java.util.Date until)

getSessions

public static java.util.Vector getSessions(java.lang.Boolean active,
                                           java.util.Date since,
                                           java.util.Date until,
                                           com.dec.avw.core.User u)
the sessions selected by date and/or user


isLoggedIn

public static boolean isLoggedIn(com.dec.avw.core.User user)

setLoginAllowed

public static void setLoginAllowed(boolean allow,
                                   java.lang.String message)
                            throws java.io.IOException
Throws:
java.io.IOException

getConcurrentUsers

public static int getConcurrentUsers()

isLoginAllowed

public static boolean isLoginAllowed()

getLoginMessage

public static java.lang.String getLoginMessage()

removeInactiveSessions

public static void removeInactiveSessions()
Performs a logout for all users, where the http session is expired. Necessary when session have been loaded by this class but not by http-server


initSessions

public static void initSessions()
On startup set namedUsers and put user session in httpSessions


dumpSessions

public static void dumpSessions()
                         throws java.lang.Exception
on shutdown dump the last access dates

Throws:
java.lang.Exception

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent e)
Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent e)
Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener

attributeAdded

public void attributeAdded(javax.servlet.http.HttpSessionBindingEvent arg0)
Specified by:
attributeAdded in interface javax.servlet.http.HttpSessionAttributeListener

attributeRemoved

public void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent arg0)
Specified by:
attributeRemoved in interface javax.servlet.http.HttpSessionAttributeListener

attributeReplaced

public void attributeReplaced(javax.servlet.http.HttpSessionBindingEvent ev)
Specified by:
attributeReplaced in interface javax.servlet.http.HttpSessionAttributeListener

deleteUserSessions

public static void deleteUserSessions(int days)
                               throws java.lang.Exception
Delete all sessions older than the given dates

Throws:
java.lang.Exception

addPendingAction

public static boolean addPendingAction(short type,
                                       java.lang.String id,
                                       java.lang.String message)
Add a pending action to the user session which is visible later via an icon in the toolbar.

Parameters:
type - either INFO or WARNING
id - the id of the action, it is used to remove actions.
message - the already translated message a HTML text
Returns:
the result of the action

removePendingAction

public static void removePendingAction(short type,
                                       java.lang.String id)


Copyright © 2001-2006 Groiss Informatics GmbH. All Rights Reserved.