Interface SessionStore

All Known Implementing Classes:
InMemorySessionStore

@ExperimentalJSentinelApi public interface SessionStore
Store for SessionRecords, keyed on SessionId.

Distinct from the existing SubjectSessionRegistry which only maps a subject to its set of active session ids (an index used by multi-session logout). SessionStore owns the canonical, queryable representation of every session — including expired and revoked ones, until they age out via retention.

Mutation pattern: load a record, copy-with via the with… methods on SessionRecord, save the new value. Stores upsert on save(SessionRecord) — there is no separate update call.

Implementations must be thread-safe.

  • Method Details

    • save

      void save(SessionRecord session)
      Persists or replaces the supplied session record. Keyed on SessionRecord.sessionId().
      Parameters:
      session - record to persist; must not be null
    • findById

      Optional<SessionRecord> findById(SessionId sessionId)
      Looks up the record for a session id.
      Parameters:
      sessionId - session identifier; must not be null
      Returns:
      the record, if present
    • findBySubject

      List<SessionRecord> findBySubject(TenantId tenant, SubjectId subjectId)
      Returns every record (in any SessionStatus) belonging to subjectId within tenant, in insertion order (oldest first).
      Parameters:
      tenant - tenant scope; must not be null
      subjectId - subject; must not be null
      Returns:
      immutable list of records; empty when none exist
    • delete

      boolean delete(SessionId sessionId)
      Removes the record for sessionId.
      Parameters:
      sessionId - session identifier; must not be null
      Returns:
      true if a record was removed, false when no such session existed
    • findAll

      default List<SessionRecord> findAll()
      Returns every record currently persisted, in insertion order. Used by admin tooling — e.g. the Phase-8a SessionManagementView — that needs the full session inventory across all subjects.

      Default returns an empty list so pre-existing implementations keep compiling; concrete stores override.

      Returns:
      immutable list of records, possibly empty; never null