org.springframework.security.core.session
Class SessionRegistryImpl

java.lang.Object
  extended by org.springframework.security.core.session.SessionRegistryImpl
All Implemented Interfaces:
EventListener, ApplicationListener<SessionDestroyedEvent>, SessionRegistry

public class SessionRegistryImpl
extends Object
implements SessionRegistry, ApplicationListener<SessionDestroyedEvent>

Base implementation of SessionRegistry which also listens for HttpSessionDestroyedEvents published in the Spring application context.

NB: It is important that you register the HttpSessionEventPublisher in web.xml so that this class is notified of sessions that expire.

Version:
$Id: SessionRegistryImpl.java 4039 2009-12-08 01:33:01Z ltaylor $
Author:
Ben Alex, Luke Taylor

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
SessionRegistryImpl()
           
 
Method Summary
 List<Object> getAllPrincipals()
          Obtains all the known principals in the SessionRegistry.
 List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions)
          Obtains all the known sessions for the specified principal.
 SessionInformation getSessionInformation(String sessionId)
          Obtains the session information for the specified sessionId.
 void onApplicationEvent(SessionDestroyedEvent event)
           
 void refreshLastRequest(String sessionId)
          Updates the given sessionId so its last request time is equal to the present date and time.
 void registerNewSession(String sessionId, Object principal)
          Registers a new session for the specified principal.
 void removeSessionInformation(String sessionId)
          Deletes all the session information being maintained for the specified sessionId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

SessionRegistryImpl

public SessionRegistryImpl()
Method Detail

getAllPrincipals

public List<Object> getAllPrincipals()
Description copied from interface: SessionRegistry
Obtains all the known principals in the SessionRegistry.

Specified by:
getAllPrincipals in interface SessionRegistry
Returns:
each of the unique principals, which can then be presented to SessionRegistry.getAllSessions(Object, boolean).

getAllSessions

public List<SessionInformation> getAllSessions(Object principal,
                                               boolean includeExpiredSessions)
Description copied from interface: SessionRegistry
Obtains all the known sessions for the specified principal. Sessions that have been destroyed are not returned. Sessions that have expired may be returned, depending on the passed argument.

Specified by:
getAllSessions in interface SessionRegistry
Parameters:
principal - to locate sessions for (should never be null)
includeExpiredSessions - if true, the returned sessions will also include those that have expired for the principal
Returns:
the matching sessions for this principal (should not return null).

getSessionInformation

public SessionInformation getSessionInformation(String sessionId)
Description copied from interface: SessionRegistry
Obtains the session information for the specified sessionId. Even expired sessions are returned (although destroyed sessions are never returned).

Specified by:
getSessionInformation in interface SessionRegistry
Parameters:
sessionId - to lookup (should never be null)
Returns:
the session information, or null if not found

onApplicationEvent

public void onApplicationEvent(SessionDestroyedEvent event)
Specified by:
onApplicationEvent in interface ApplicationListener<SessionDestroyedEvent>

refreshLastRequest

public void refreshLastRequest(String sessionId)
Description copied from interface: SessionRegistry
Updates the given sessionId so its last request time is equal to the present date and time. Silently returns if the given sessionId cannot be found or the session is marked to expire.

Specified by:
refreshLastRequest in interface SessionRegistry
Parameters:
sessionId - for which to update the date and time of the last request (should never be null)

registerNewSession

public void registerNewSession(String sessionId,
                               Object principal)
Description copied from interface: SessionRegistry
Registers a new session for the specified principal. The newly registered session will not be marked for expiration.

Specified by:
registerNewSession in interface SessionRegistry
Parameters:
sessionId - to associate with the principal (should never be null)
principal - to associate with the session (should never be null)

removeSessionInformation

public void removeSessionInformation(String sessionId)
Description copied from interface: SessionRegistry
Deletes all the session information being maintained for the specified sessionId. If the sessionId is not found, the method gracefully returns.

Specified by:
removeSessionInformation in interface SessionRegistry
Parameters:
sessionId - to delete information for (should never be null)


Copyright © 2004-2009 SpringSource, Inc. All Rights Reserved.