Class SessionRegistryImpl
- java.lang.Object
-
- org.springframework.security.core.session.SessionRegistryImpl
-
- All Implemented Interfaces:
java.util.EventListener,org.springframework.context.ApplicationListener<AbstractSessionEvent>,SessionRegistry
public class SessionRegistryImpl extends java.lang.Object implements SessionRegistry, org.springframework.context.ApplicationListener<AbstractSessionEvent>
Default implementation ofSessionRegistrywhich listens forSessionDestroyedEvents 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
Fields Modifier and Type Field Description protected org.apache.commons.logging.Loglogger
-
Constructor Summary
Constructors Constructor Description SessionRegistryImpl()SessionRegistryImpl(java.util.concurrent.ConcurrentMap<java.lang.Object,java.util.Set<java.lang.String>> principals, java.util.Map<java.lang.String,SessionInformation> sessionIds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.Object>getAllPrincipals()Obtains all the known principals in theSessionRegistry.java.util.List<SessionInformation>getAllSessions(java.lang.Object principal, boolean includeExpiredSessions)Obtains all the known sessions for the specified principal.SessionInformationgetSessionInformation(java.lang.String sessionId)Obtains the session information for the specifiedsessionId.voidonApplicationEvent(AbstractSessionEvent event)voidrefreshLastRequest(java.lang.String sessionId)Updates the givensessionIdso its last request time is equal to the present date and time.voidregisterNewSession(java.lang.String sessionId, java.lang.Object principal)Registers a new session for the specified principal.voidremoveSessionInformation(java.lang.String sessionId)Deletes all the session information being maintained for the specifiedsessionId.
-
-
-
Constructor Detail
-
SessionRegistryImpl
public SessionRegistryImpl()
-
SessionRegistryImpl
public SessionRegistryImpl(java.util.concurrent.ConcurrentMap<java.lang.Object,java.util.Set<java.lang.String>> principals, java.util.Map<java.lang.String,SessionInformation> sessionIds)
-
-
Method Detail
-
getAllPrincipals
public java.util.List<java.lang.Object> getAllPrincipals()
Description copied from interface:SessionRegistryObtains all the known principals in theSessionRegistry.- Specified by:
getAllPrincipalsin interfaceSessionRegistry- Returns:
- each of the unique principals, which can then be presented to
SessionRegistry.getAllSessions(Object, boolean).
-
getAllSessions
public java.util.List<SessionInformation> getAllSessions(java.lang.Object principal, boolean includeExpiredSessions)
Description copied from interface:SessionRegistryObtains 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:
getAllSessionsin 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
public SessionInformation getSessionInformation(java.lang.String sessionId)
Description copied from interface:SessionRegistryObtains the session information for the specifiedsessionId. Even expired sessions are returned (although destroyed sessions are never returned).- Specified by:
getSessionInformationin interfaceSessionRegistry- Parameters:
sessionId- to lookup (should never benull)- Returns:
- the session information, or
nullif not found
-
onApplicationEvent
public void onApplicationEvent(AbstractSessionEvent event)
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<AbstractSessionEvent>
-
refreshLastRequest
public void refreshLastRequest(java.lang.String sessionId)
Description copied from interface:SessionRegistryUpdates the givensessionIdso its last request time is equal to the present date and time. Silently returns if the givensessionIdcannot be found or the session is marked to expire.- Specified by:
refreshLastRequestin interfaceSessionRegistry- Parameters:
sessionId- for which to update the date and time of the last request (should never benull)
-
registerNewSession
public void registerNewSession(java.lang.String sessionId, java.lang.Object principal)Description copied from interface:SessionRegistryRegisters a new session for the specified principal. The newly registered session will not be marked for expiration.- Specified by:
registerNewSessionin interfaceSessionRegistry- Parameters:
sessionId- to associate with the principal (should never benull)principal- to associate with the session (should never benull)
-
removeSessionInformation
public void removeSessionInformation(java.lang.String sessionId)
Description copied from interface:SessionRegistryDeletes all the session information being maintained for the specifiedsessionId. If thesessionIdis not found, the method gracefully returns.- Specified by:
removeSessionInformationin interfaceSessionRegistry- Parameters:
sessionId- to delete information for (should never benull)
-
-