com.groiss.org
Class UserSessionManager

java.lang.Object
  extended by com.groiss.org.UserSessionManager
All Implemented Interfaces:
com.groiss.servlet.impl.UserSessionManager, 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, com.groiss.servlet.impl.UserSessionManager

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.
static boolean addRestartAction()
          This method calls addPendingAction with the parameters WARNING, restart, and an appropriate message for the restart.
 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 int getActiveSessionCount()
          return the number of users currently logged in
static java.util.List<com.groiss.org.impl.UserSession> getActiveSessions()
          return the list of users currently logged in
static java.util.List<com.groiss.org.impl.UserSession> getActiveSessions(java.lang.String node)
          return the list of users currently logged in at a node
static java.util.List<com.groiss.org.impl.UserSession> getConcurrentSessions()
          return the list of userssessions which count for concurrent licenses
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.List<com.groiss.org.impl.UserSession> 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 java.util.List<com.groiss.org.impl.UserSession> getSessions(java.lang.Boolean active, java.util.Date since, java.util.Date until, com.dec.avw.core.User u, int lastaccess)
           
static boolean hasPendingAction(short type, java.lang.String id)
          Check if a pending action has been added to the user session.
static void init()
           
static void initSessions()
          On startup set namedUsers and put user session in httpSessions
 boolean isActiveSession(java.lang.String id)
           
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 java.lang.String login(com.dec.avw.core.User user, java.lang.String ip, boolean interactive, short sessiontype)
           
static void logout(java.lang.String sessionId)
          End the session with the given session id (if session is already finished, do nothing).
static void logout(com.groiss.org.impl.UserSession ss)
          End the session (if session is already finished, do nothing).
static void removeInactiveSessions()
          Performs a logout for all users, where the http session is expired.
static void removePendindActions()
           
static void removePendingAction(short type, java.lang.String id)
           
static void removeSession(java.lang.String sessionId)
           
 void sessionCreated(javax.servlet.http.HttpSessionEvent e)
           
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent e)
           
static void setLoginAllowed(boolean allow, java.lang.String message)
           
static void setSessionEventHandler(com.groiss.org.impl.UserSessionEventHandler seh)
           
static void updateLastAccessOnSessions()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFO

public static final short INFO
See Also:
Constant Field Values

WARNING

public static final short WARNING
See Also:
Constant Field Values
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

setSessionEventHandler

public static void setSessionEventHandler(com.groiss.org.impl.UserSessionEventHandler seh)

login

public static java.lang.String login(com.dec.avw.core.User user,
                                     java.lang.String ip,
                                     boolean interactive,
                                     short sessiontype)

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

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

logout

public static void logout(com.groiss.org.impl.UserSession ss)
                   throws java.lang.Exception
End the session (if session is already finished, do nothing).

Throws:
java.lang.Exception

removeSession

public static void removeSession(java.lang.String sessionId)

getActiveSessions

public static java.util.List<com.groiss.org.impl.UserSession> getActiveSessions()
return the list of users currently logged in


getActiveSessionCount

public static int getActiveSessionCount()
return the number of users currently logged in


getActiveSessions

public static java.util.List<com.groiss.org.impl.UserSession> getActiveSessions(java.lang.String node)
return the list of users currently logged in at a node


getConcurrentSessions

public static java.util.List<com.groiss.org.impl.UserSession> getConcurrentSessions()
return the list of userssessions which count for concurrent licenses


getMaxConcurrent

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

getSessions

public static java.util.List<com.groiss.org.impl.UserSession> 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. All params may be null.

Parameters:
active - if True show only active users
since - login since this timestamp
until - logins until this timestamp
u - only for this user
Returns:

getSessions

public static java.util.List<com.groiss.org.impl.UserSession> getSessions(java.lang.Boolean active,
                                                                          java.util.Date since,
                                                                          java.util.Date until,
                                                                          com.dec.avw.core.User u,
                                                                          int lastaccess)

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 via http-server


updateLastAccessOnSessions

public static void updateLastAccessOnSessions()

initSessions

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


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:
true if the action was possible

hasPendingAction

public static boolean hasPendingAction(short type,
                                       java.lang.String id)
Check if a pending action has been added to the user session.

Parameters:
type - either INFO or WARNING
id - the id of the action.
Returns:
true if the action already has been in the user session.

addRestartAction

public static boolean addRestartAction()
This method calls addPendingAction with the parameters WARNING, restart, and an appropriate message for the restart. It remove all other pending actions (not infos).

Returns:
true if the action was possible

removePendingAction

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

removePendindActions

public static void removePendindActions()

isActiveSession

public boolean isActiveSession(java.lang.String id)
Specified by:
isActiveSession in interface com.groiss.servlet.impl.UserSessionManager


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.