Class InMemorySubjectSessionRegistry

java.lang.Object
com.svenruppert.jsentinel.logout.InMemorySubjectSessionRegistry
All Implemented Interfaces:
SubjectSessionRegistry

public final class InMemorySubjectSessionRegistry extends Object implements SubjectSessionRegistry
In-memory SubjectSessionRegistry suitable for single-node deployments and demos.

Thread-safe via a ConcurrentMap keyed by SubjectId. Each value is a synchronized LinkedHashSet so registrations preserve insertion order — useful for diagnostics.

  • Constructor Details

    • InMemorySubjectSessionRegistry

      public InMemorySubjectSessionRegistry()
  • Method Details

    • register

      public void register(SubjectId subjectId, String sessionId)
      Description copied from interface: SubjectSessionRegistry
      Records that sessionId belongs to subjectId. Idempotent — registering the same pair twice is a no-op.
      Specified by:
      register in interface SubjectSessionRegistry
      Parameters:
      subjectId - subject the session belongs to
      sessionId - opaque session identifier (token, session id, …)
    • unregister

      public void unregister(SubjectId subjectId, String sessionId)
      Description copied from interface: SubjectSessionRegistry
      Removes the (subjectId, sessionId) association if present. No-op for unknown sessions.
      Specified by:
      unregister in interface SubjectSessionRegistry
      Parameters:
      subjectId - subject the session belongs to
      sessionId - opaque session identifier
    • sessionsOf

      public Collection<String> sessionsOf(SubjectId subjectId)
      Description copied from interface: SubjectSessionRegistry
      Returns every session id currently associated with subjectId. The returned collection is a snapshot; subsequent register / unregister calls do not leak into it.
      Specified by:
      sessionsOf in interface SubjectSessionRegistry
      Parameters:
      subjectId - subject to query
      Returns:
      snapshot of active session ids, possibly empty
    • clearAll

      public Collection<String> clearAll(SubjectId subjectId)
      Description copied from interface: SubjectSessionRegistry
      Forgets every association for subjectId. Returns the set of removed session ids so the caller can drive downstream cleanup (e.g. revoke tokens, invalidate Vaadin sessions).
      Specified by:
      clearAll in interface SubjectSessionRegistry
      Parameters:
      subjectId - subject whose sessions to forget
      Returns:
      removed session ids