com.stratelia.silverpeas.peasCore
Class SessionManager

java.lang.Object
  extended by com.stratelia.silverpeas.peasCore.SessionManager
All Implemented Interfaces:
SchedulerEventListener, SessionManagement

@Named(value="sessionManagement")
public class SessionManager
extends Object
implements SchedulerEventListener, SessionManagement

Class declaration This object is a singleton used by SilverpeasSessionOpenener : when the user log in, ComponentRequestRouter : when the user access a component. It provides functions to manage the sessions, to write a log journal and getFactory informations about the logged users.

Author:
Nicolas Eysseric

Method Summary
 void closeSession(String sessionId)
          Closes the specified user session.
 void doSessionManagement(Date currentDate)
          This method is called every scheduledSessionManagementTimeStamp minute by the scheduler, it notify the user when timeout has expired and then invalidates the session if the user has not accessed the server.
 Collection<SessionInfo> getConnectedUsersList()
          Gets all the connected users and the duration of their session.
 Collection<SessionInfo> getDistinctConnectedUsersList(UserDetail user)
          Gets all the connected users and the duration of their session.
 int getNbConnectedUsersList(UserDetail user)
          Gets number of connected users
 long getNextSessionTimeOut(String sessionKey)
          Gets the next timeout of the specified user session.
 SessionInfo getSessionInfo(String sessionId)
          Gets information about the specified user session.
 void initSessionManager()
          Init attributes
 boolean isUserConnected(UserDetail user)
          Is the specified user currently connected to Silverpeas?
 void jobFailed(SchedulerEvent anEvent)
          Invoked when the normal execution thread of a job is broken by an exception.
 void jobSucceeded(SchedulerEvent anEvent)
          Invoked when the execution of a job has been completed correctly.
 SessionInfo openAnonymousSession(javax.servlet.http.HttpServletRequest request)
          Opens a new anonymous session with the specified HTTP request at the origin of the session ask.
 SessionInfo openSession(UserDetail user)
          This method is dedicated to the authentication for only accessing the WEB services published in Silverpeas.
 SessionInfo openSession(UserDetail user, javax.servlet.http.HttpServletRequest request)
          This method is dedicated to the authentication of users behind a WEB browser.
 void removeSession(String sessionId)
          Remove a session and log session's data.
 void shutdown()
          This method remove and invalidates all sessions.
 void triggerFired(SchedulerEvent anEvent)
          Invoked when a job trigger fires the execution of a job.
 SessionInfo validateSession(SessionValidationContext context)
          Validates the session identified uniquely by the specified key.
 SessionInfo validateSession(String sessionKey)
          Calls SessionManagement.validateSession(SessionValidationContext) method by specifying to it a context that contains only the specified session key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initSessionManager

@PostConstruct
public void initSessionManager()
Init attributes


validateSession

public SessionInfo validateSession(String sessionKey)
Description copied from interface: SessionManagement
Calls SessionManagement.validateSession(SessionValidationContext) method by specifying to it a context that contains only the specified session key.

Specified by:
validateSession in interface SessionManagement
Parameters:
sessionKey - the key of the user session.
Returns:
the result of SessionManagement.validateSession(SessionValidationContext) execution.

validateSession

public SessionInfo validateSession(SessionValidationContext context)
Description copied from interface: SessionManagement
Validates the session identified uniquely by the specified key. The validation checks a session exists with the specified identifier and returns information about this session. At each access by the user to Silverpeas, its current session must be validated. The validation updates also useful information about the session like the timestamp of this access so that additional features can be performed (for example, the timeout computation of the session).

Specified by:
validateSession in interface SessionManagement
Parameters:
context - the context of the validation that contains at least the session key
Returns:
information about the session identified by the specified key or null if no such session exists.

removeSession

public void removeSession(String sessionId)
Remove a session and log session's data.

Parameters:
sessionId - identifier
See Also:
LogoutServlet

closeSession

public void closeSession(String sessionId)
Description copied from interface: SessionManagement
Closes the specified user session.

Specified by:
closeSession in interface SessionManagement
Parameters:
sessionId - the key of the session to close.

getSessionInfo

public SessionInfo getSessionInfo(String sessionId)
Description copied from interface: SessionManagement
Gets information about the specified user session.

Specified by:
getSessionInfo in interface SessionManagement
Parameters:
sessionId - the key of the user session.
Returns:
the information about the session mapped to the specified key.

getConnectedUsersList

public Collection<SessionInfo> getConnectedUsersList()
Gets all the connected users and the duration of their session.

Specified by:
getConnectedUsersList in interface SessionManagement
Returns:

getDistinctConnectedUsersList

public Collection<SessionInfo> getDistinctConnectedUsersList(UserDetail user)
Gets all the connected users and the duration of their session.

Specified by:
getDistinctConnectedUsersList in interface SessionManagement
Parameters:
user - a user from whom all the distinct connected users are visible.
Returns:
Collection of HTTPSessionInfo

getNbConnectedUsersList

public int getNbConnectedUsersList(UserDetail user)
Gets number of connected users

Specified by:
getNbConnectedUsersList in interface SessionManagement
Parameters:
user -
Returns:
nb of connected users

doSessionManagement

public void doSessionManagement(Date currentDate)
This method is called every scheduledSessionManagementTimeStamp minute by the scheduler, it notify the user when timeout has expired and then invalidates the session if the user has not accessed the server. The maximum minutes duration of session before invalidation is userSessionTimeout + scheduledSessionManagementTimeStamp.

Parameters:
currentDate - the date when the method is called by the scheduler
See Also:
for parameters, addSession, setLastAccess

shutdown

public void shutdown()
This method remove and invalidates all sessions. The unique instance of the SessionManager will be destroyed.


triggerFired

public void triggerFired(SchedulerEvent anEvent)
                  throws Exception
Description copied from interface: SchedulerEventListener
Invoked when a job trigger fires the execution of a job. The call of this method occurs before the actual job execution. So, wether an error occurs during the processing of this call, it is considered as a job failure and as consequency an event about a job failure will be sent to the listener. The processing of this event can be, for example for preparing the resources before the job execution or performing the execution of the job itself (delegation).

Specified by:
triggerFired in interface SchedulerEventListener
Parameters:
anEvent - the event coming from the trigger firing.
Throws:
Exception

jobSucceeded

public void jobSucceeded(SchedulerEvent anEvent)
Description copied from interface: SchedulerEventListener
Invoked when the execution of a job has been completed correctly. The job execution is considered as completed when it ends without raising any exceptions. The processing of this call can be, for example, for freeing the resources after a job completion.

Specified by:
jobSucceeded in interface SchedulerEventListener
Parameters:
anEvent - the event coming from the job completion.

jobFailed

public void jobFailed(SchedulerEvent anEvent)
Description copied from interface: SchedulerEventListener
Invoked when the normal execution thread of a job is broken by an exception. When an exception is thrown by the job execution, the exception is catched by the scheduler that then considers the job has failed and thus send an event about that failure. The processing of this event can be, for example, for freeing correctly the resources after a job failure or to run a rollback or a retry process.

Specified by:
jobFailed in interface SchedulerEventListener
Parameters:
anEvent - the event coming from the job failure.

openSession

public SessionInfo openSession(UserDetail user)
This method is dedicated to the authentication for only accessing the WEB services published in Silverpeas. To openSession a user using a WEB browser to access Silverpeas, please prefers the below openSession method.

Specified by:
openSession in interface SessionManagement
Parameters:
user - the user for which the session has to be opened
Returns:
a SessionInfo instance representing the opened session.

openSession

public SessionInfo openSession(UserDetail user,
                               javax.servlet.http.HttpServletRequest request)
This method is dedicated to the authentication of users behind a WEB browser.

Specified by:
openSession in interface SessionManagement
Parameters:
user - the user for which the session has to be opened
request - the HTTP servlet request in which the authentication is performed.
Returns:
a SessionInfo instance representing the opened session.

openAnonymousSession

public SessionInfo openAnonymousSession(javax.servlet.http.HttpServletRequest request)
Description copied from interface: SessionManagement
Opens a new anonymous session with the specified HTTP request at the origin of the session ask. The opened session is an HTTP one and it is managed directly by the underlying HTTP server/container. This method is for anonymous session in which HTTP servlets are used as entry-point in the WEB communication with Silverpeas.

Specified by:
openAnonymousSession in interface SessionManagement
Parameters:
request - the HTTP request at the origin of the session opening ask.
Returns:
a SessionInfo instance representing the current opened anonymous session with information about that session.

isUserConnected

public boolean isUserConnected(UserDetail user)
Description copied from interface: SessionManagement
Is the specified user currently connected to Silverpeas?

Specified by:
isUserConnected in interface SessionManagement
Parameters:
user - the user for which the connection is checked.
Returns:
true if the user is connected, false otherwise.

getNextSessionTimeOut

public long getNextSessionTimeOut(String sessionKey)
Description copied from interface: SessionManagement
Gets the next timeout of the specified user session.

Specified by:
getNextSessionTimeOut in interface SessionManagement
Parameters:
sessionKey - the keu of the user session.
Returns:
the next session timout in milliseconds.


Copyright © 2016 Silverpeas. All Rights Reserved.