com.silverpeas.web.mock
Class SessionManagerMock

java.lang.Object
  extended by com.silverpeas.web.mock.SessionManagerMock
All Implemented Interfaces:
SessionManagement

@Named(value="sessionManagement")
public class SessionManagerMock
extends Object
implements SessionManagement

A mock of a session manager for testing purpose.


Constructor Summary
SessionManagerMock()
           
 
Method Summary
 void closeSession(String sessionKey)
          Closes the specified user session.
 Collection<SessionInfo> getConnectedUsersList()
          Gets the session information about all the connected users in the Silverpeas platform, whatever their domain and the applied domain isolation policy.
 Collection<SessionInfo> getDistinctConnectedUsersList(UserDetail user)
          Gets the session information about all the connected users that are accessible to the specified user.
 int getNbConnectedUsersList(UserDetail user)
          Gets the count of users that are connected to Silverpeas.
 long getNextSessionTimeOut(String sessionKey)
          Gets the next timeout of the specified user session.
 SessionInfo getSessionInfo(String sessionKey)
          Gets information about the specified user session.
 boolean isNoSession()
           
 boolean isUserConnected(UserDetail user)
          Is the specified user currently connected to Silverpeas?
 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)
          Opens a new session for the specified user.
 SessionInfo openSession(UserDetail user, javax.servlet.http.HttpServletRequest request)
          Opens a new session for the specified user with the specified HTTP request at the origin of the session ask.
 void setNoSession(boolean noSession)
           
 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
 

Constructor Detail

SessionManagerMock

public SessionManagerMock()
Method Detail

getConnectedUsersList

public Collection<SessionInfo> getConnectedUsersList()
Description copied from interface: SessionManagement
Gets the session information about all the connected users in the Silverpeas platform, whatever their domain and the applied domain isolation policy.

Specified by:
getConnectedUsersList in interface SessionManagement
Returns:
Collection of session information.

getDistinctConnectedUsersList

public Collection<SessionInfo> getDistinctConnectedUsersList(UserDetail user)
Description copied from interface: SessionManagement
Gets the session information about all the connected users that are accessible to the specified user. According to the domain level isolation, a user can see either all the others connected users or only thoses in the same domain.

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

getNbConnectedUsersList

public int getNbConnectedUsersList(UserDetail user)
Description copied from interface: SessionManagement
Gets the count of users that are connected to Silverpeas. The domain level isolation applied to the running Silverpeas is taken into account in the computation of the connected user count: either all the connected users are taken into account or only those in the same domain.

Specified by:
getNbConnectedUsersList in interface SessionManagement
Parameters:
user - the user from whom all the users to count are visible.
Returns:
the count of connected users

getSessionInfo

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

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

openSession

public SessionInfo openSession(UserDetail user)
Description copied from interface: SessionManagement
Opens a new session for the specified user. This method is dedicated to open session off any WEB browsing context with HTTP servlets.

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

openSession

public SessionInfo openSession(UserDetail user,
                               javax.servlet.http.HttpServletRequest request)
Description copied from interface: SessionManagement
Opens a new session for the specified user 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 session in which HTTP servlets are used as entry-point in the WEB communication with Silverpeas.

Specified by:
openSession in interface SessionManagement
Parameters:
user - the user for which an HTTP session with Silverpeas has to be opened.
request - the HTTP request at the origin of the session opening ask.
Returns:
a SessionInfo instance representing the current opened session with information about that 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.

closeSession

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

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

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.

isNoSession

public boolean isNoSession()
Returns:
the noSession

setNoSession

public void setNoSession(boolean noSession)
Parameters:
noSession - the noSession to set

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.

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.