Class SpringSessionBackedSessionRegistry<S extends Session>

java.lang.Object
org.springframework.session.security.SpringSessionBackedSessionRegistry<S>
Type Parameters:
S - the Session type.
All Implemented Interfaces:
org.springframework.security.core.session.SessionRegistry

public class SpringSessionBackedSessionRegistry<S extends Session> extends Object implements org.springframework.security.core.session.SessionRegistry
A SessionRegistry that retrieves session information from Spring Session, rather than maintaining it itself. This allows concurrent session management with Spring Security in a clustered environment.

Relies on being able to derive the same String-based representation of the principal given to getAllSessions(Object, boolean) as used by Spring Session in order to look up the user's sessions.

Does not support getAllPrincipals(), since that information is not available.

Since:
1.3
  • Constructor Details

  • Method Details

    • getAllPrincipals

      public List<Object> getAllPrincipals()
      Specified by:
      getAllPrincipals in interface org.springframework.security.core.session.SessionRegistry
    • getAllSessions

      public List<org.springframework.security.core.session.SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions)
      Specified by:
      getAllSessions in interface org.springframework.security.core.session.SessionRegistry
    • getSessionInformation

      public org.springframework.security.core.session.SessionInformation getSessionInformation(String sessionId)
      Specified by:
      getSessionInformation in interface org.springframework.security.core.session.SessionRegistry
    • refreshLastRequest

      public void refreshLastRequest(String sessionId)
      Specified by:
      refreshLastRequest in interface org.springframework.security.core.session.SessionRegistry
    • registerNewSession

      public void registerNewSession(String sessionId, Object principal)
      Specified by:
      registerNewSession in interface org.springframework.security.core.session.SessionRegistry
    • removeSessionInformation

      public void removeSessionInformation(String sessionId)
      Specified by:
      removeSessionInformation in interface org.springframework.security.core.session.SessionRegistry
    • name

      protected String name(Object principal)
      Derives a String name for the given principal.
      Parameters:
      principal - as provided by Spring Security
      Returns:
      name of the principal, or its toString() representation if no name could be derived