Class StoreBackedSubjectSessionRegistry
- All Implemented Interfaces:
SubjectSessionRegistry
SubjectSessionRegistry that stores its
(subject, sessionId) associations as full
SessionRecords in a SessionStore.
The registry contract is narrower than what
SessionStore can represent — it does not track
createdAt / lastActivityAt / status — so this
adapter fills the missing fields with sensible defaults at
register time:
timestamps from the supplied clock,
JSentinelVersion.INITIAL (or the subject's current
value when a JSentinelVersionStore is supplied), status
SessionStatus.ACTIVE. Calling
register again for an
existing session id refreshes the lastActivityAt via
upsert (idempotent in observable effect, as the contract
requires).
Bound to one TenantId at construction. Multi-tenant
deployments instantiate one registry per tenant.
For Phase 4c (JSentinelVersionCheck-driven session refresh),
pass a JSentinelVersionStore so each fresh session
captures the subject's current security version as its
snapshot.
Without one, every snapshot defaults to
JSentinelVersion.INITIAL — fine for adapters that don't
enforce drift but useless for the Vaadin/REST drift interceptors.
-
Constructor Summary
ConstructorsConstructorDescriptionBuilds a registry bound toTenantId.DEFAULTusing a system clock and no version-store integration — every new session is recorded withJSentinelVersion.INITIAL.StoreBackedSubjectSessionRegistry(SessionStore store, TenantId tenant, Clock clock) Version-store-free constructor.StoreBackedSubjectSessionRegistry(SessionStore store, TenantId tenant, Clock clock, JSentinelVersionStore versionStore) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionForgets every association forsubjectId.voidRecords thatsessionIdbelongs tosubjectId.sessionsOf(SubjectId subjectId) Returns every session id currently associated withsubjectId.voidunregister(SubjectId subjectId, String sessionId) Removes the(subjectId, sessionId)association if present.
-
Constructor Details
-
StoreBackedSubjectSessionRegistry
Builds a registry bound toTenantId.DEFAULTusing a system clock and no version-store integration — every new session is recorded withJSentinelVersion.INITIAL.- Parameters:
store- backing session store; non-null
-
StoreBackedSubjectSessionRegistry
Version-store-free constructor.- Parameters:
store- backing session store; non-nulltenant- tenant scope;nullbecomesTenantId.DEFAULTclock- time source; non-null
-
StoreBackedSubjectSessionRegistry
public StoreBackedSubjectSessionRegistry(SessionStore store, TenantId tenant, Clock clock, JSentinelVersionStore versionStore) Full constructor.- Parameters:
store- backing session store; non-nulltenant- tenant scope;nullbecomesTenantId.DEFAULTclock- time source; non-nullversionStore- optional version store consulted at register-time to capture the subject's currentJSentinelVersionas the session snapshot;nullfalls back toJSentinelVersion.INITIAL
-
-
Method Details
-
register
Description copied from interface:SubjectSessionRegistryRecords thatsessionIdbelongs tosubjectId. Idempotent — registering the same pair twice is a no-op.- Specified by:
registerin interfaceSubjectSessionRegistry- Parameters:
subjectId- subject the session belongs tosessionId- opaque session identifier (token, session id, …)
-
unregister
Description copied from interface:SubjectSessionRegistryRemoves the(subjectId, sessionId)association if present. No-op for unknown sessions.- Specified by:
unregisterin interfaceSubjectSessionRegistry- Parameters:
subjectId- subject the session belongs tosessionId- opaque session identifier
-
sessionsOf
Description copied from interface:SubjectSessionRegistryReturns every session id currently associated withsubjectId. The returned collection is a snapshot; subsequentregister/unregistercalls do not leak into it.- Specified by:
sessionsOfin interfaceSubjectSessionRegistry- Parameters:
subjectId- subject to query- Returns:
- snapshot of active session ids, possibly empty
-
clearAll
Description copied from interface:SubjectSessionRegistryForgets every association forsubjectId. Returns the set of removed session ids so the caller can drive downstream cleanup (e.g. revoke tokens, invalidate Vaadin sessions).- Specified by:
clearAllin interfaceSubjectSessionRegistry- Parameters:
subjectId- subject whose sessions to forget- Returns:
- removed session ids
-