Package org.silverpeas.core.web.session
Class SessionManager
- java.lang.Object
-
- org.silverpeas.core.web.session.SessionManager
-
- All Implemented Interfaces:
Initialization
,SessionManagement
@Service @Singleton public class SessionManager extends Object implements SessionManagement, Initialization
Implementation of theorg.silverpeas.core.security.session.SessionManagement
interface. It extends the session management performed by the underlying application service by adding useful session-related features like statistics about the connection time of each user or like the actual number of connected users.- Author:
- Nicolas Eysseric
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SessionManager()
Prevent the class from being instantiate (private)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeSession(String sessionId)
Closes the specified user session.Collection<SessionInfo>
getConnectedUsersList()
Gets all the connected users and the duration of their session.Collection<SessionInfo>
getDistinctConnectedUsersList(User user)
Gets for the specified user all the connected users and the duration of their session.int
getNbConnectedUsersList(User user)
Gets the number of connected users in Silverpeas for the specified user.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
init()
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.boolean
isUserConnected(User user)
Is the specified user currently connected to Silverpeas?SessionInfo
openAnonymousSession(javax.servlet.http.HttpServletRequest request)
Opens a new anonymous session.SessionInfo
openSession(User user)
This method is dedicated to the authentication for only accessing the WEB services published in Silverpeas.SessionInfo
openSession(User user, javax.servlet.http.HttpServletRequest request)
This method is dedicated to the authentication of users behind a WEB browser.void
release()
Releases the previously initialized resources at Silverpeas shutdown.void
shutdown()
This method remove and invalidates all sessions.SessionInfo
validateSession(String sessionKey)
CallsSessionManagement.validateSession(SessionValidationContext)
method by specifying to it a context that contains only the specified session key.SessionInfo
validateSession(SessionValidationContext context)
Validates the session identified uniquely by the specified key.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.initialization.Initialization
getPriority
-
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:Initialization
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.- Specified by:
init
in interfaceInitialization
-
release
public void release() throws Exception
Description copied from interface:Initialization
Releases the previously initialized resources at Silverpeas shutdown. The implementation of this method is optional. By default it does nothing.- Specified by:
release
in interfaceInitialization
- Throws:
Exception
- if an error occurs during the shutdown process. In this case, a log will be outputed and the shutdown goes one.
-
validateSession
public SessionInfo validateSession(String sessionKey)
Description copied from interface:SessionManagement
CallsSessionManagement.validateSession(SessionValidationContext)
method by specifying to it a context that contains only the specified session key.- Specified by:
validateSession
in interfaceSessionManagement
- 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 interfaceSessionManagement
- 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.
-
closeSession
public void closeSession(String sessionId)
Description copied from interface:SessionManagement
Closes the specified user session.- Specified by:
closeSession
in interfaceSessionManagement
- 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 interfaceSessionManagement
- 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 interfaceSessionManagement
- Returns:
- a collection of all opened user sessions in Silverpeas.
-
getDistinctConnectedUsersList
public Collection<SessionInfo> getDistinctConnectedUsersList(User user)
Gets for the specified user all the connected users and the duration of their session. The actual domain restriction policy is taken into account for the user asking the users currently connected in Silverpeas.- Specified by:
getDistinctConnectedUsersList
in interfaceSessionManagement
- Parameters:
user
- the current user asking for actual opened user sessions.- Returns:
- Collection of opened user sessions.
-
getNbConnectedUsersList
public int getNbConnectedUsersList(User user)
Gets the number of connected users in Silverpeas for the specified user. The domain restriction policy is taken into account for the given user in the filtering of the opened user sessions.- Specified by:
getNbConnectedUsersList
in interfaceSessionManagement
- Parameters:
user
- the user asking the number of actually connected users.- Returns:
- nb of connected users
-
shutdown
public void shutdown()
This method remove and invalidates all sessions. The unique instance of the SessionManager will be destroyed.
-
openSession
public SessionInfo openSession(User 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 interfaceSessionManagement
- Parameters:
user
- the user for which the session has to be opened- Returns:
- a SessionInfo instance representing the opened session.
-
openSession
public SessionInfo openSession(User user, javax.servlet.http.HttpServletRequest request)
This method is dedicated to the authentication of users behind a WEB browser.- Specified by:
openSession
in interfaceSessionManagement
- Parameters:
user
- the user for which the session has to be openedrequest
- 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. 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 interfaceSessionManagement
- Returns:
- a SessionInfo instance representing the current opened anonymous session with information about that session.
-
isUserConnected
public boolean isUserConnected(User user)
Description copied from interface:SessionManagement
Is the specified user currently connected to Silverpeas?- Specified by:
isUserConnected
in interfaceSessionManagement
- 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 interfaceSessionManagement
- Parameters:
sessionKey
- the keu of the user session.- Returns:
- the next session timout in milliseconds.
-
-