Class SessionRegistryImpl
java.lang.Object
org.springframework.security.core.session.SessionRegistryImpl
- All Implemented Interfaces:
EventListener
,org.springframework.context.ApplicationListener<AbstractSessionEvent>
,SessionRegistry
public class SessionRegistryImpl
extends Object
implements SessionRegistry, org.springframework.context.ApplicationListener<AbstractSessionEvent>
Default implementation of
SessionRegistry
which
listens for SessionDestroyedEvent
s published in the Spring application context.
For this class to function correctly in a web application, it is important that you register an HttpSessionEventPublisher in the web.xml file so that this class is notified of sessions that expire.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSessionRegistryImpl
(ConcurrentMap<Object, Set<String>> principals, Map<String, SessionInformation> sessionIds) -
Method Summary
Modifier and TypeMethodDescriptionObtains all the known principals in theSessionRegistry
.getAllSessions
(Object principal, boolean includeExpiredSessions) Obtains all the known sessions for the specified principal.getSessionInformation
(String sessionId) Obtains the session information for the specifiedsessionId
.void
void
refreshLastRequest
(String sessionId) Updates the givensessionId
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 specifiedsessionId
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
SessionRegistryImpl
public SessionRegistryImpl() -
SessionRegistryImpl
public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals, Map<String, SessionInformation> sessionIds)
-
-
Method Details
-
getAllPrincipals
Description copied from interface:SessionRegistry
Obtains all the known principals in theSessionRegistry
.- Specified by:
getAllPrincipals
in interfaceSessionRegistry
- Returns:
- each of the unique principals, which can then be presented to
SessionRegistry.getAllSessions(Object, boolean)
.
-
getAllSessions
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 interfaceSessionRegistry
- Parameters:
principal
- to locate sessions for (should never benull
)includeExpiredSessions
- iftrue
, 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
Description copied from interface:SessionRegistry
Obtains the session information for the specifiedsessionId
. Even expired sessions are returned (although destroyed sessions are never returned).- Specified by:
getSessionInformation
in interfaceSessionRegistry
- Parameters:
sessionId
- to lookup (should never benull
)- Returns:
- the session information, or
null
if not found
-
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<AbstractSessionEvent>
-
refreshLastRequest
Description copied from interface:SessionRegistry
Updates the givensessionId
so its last request time is equal to the present date and time. Silently returns if the givensessionId
cannot be found or the session is marked to expire.- Specified by:
refreshLastRequest
in interfaceSessionRegistry
- Parameters:
sessionId
- for which to update the date and time of the last request (should never benull
)
-
registerNewSession
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 interfaceSessionRegistry
- Parameters:
sessionId
- to associate with the principal (should never benull
)principal
- to associate with the session (should never benull
)
-
removeSessionInformation
Description copied from interface:SessionRegistry
Deletes all the session information being maintained for the specifiedsessionId
. If thesessionId
is not found, the method gracefully returns.- Specified by:
removeSessionInformation
in interfaceSessionRegistry
- Parameters:
sessionId
- to delete information for (should never benull
)
-