Interface JSentinelVersionStore
- All Known Implementing Classes:
InMemoryJSentinelVersionStore
Persistent counter store for
JSentinelVersion per
JSentinelVersionKey. Backs the planned
JSentinelVersionCheck interceptor in
security-vaadin and security-rest: every session
captures the subject's version at login time
(SessionRecord.securityVersionAtLogin()); the interceptor
compares that snapshot against the subject's current
version returned by current(JSentinelVersionKey) on every
request and rejects the session when the two have drifted apart.
The API is behaviour-flavoured rather than pure CRUD because
the data shape is so narrow (a single non-negative counter):
callers either read the current version, atomically bump it, or
reset it. The reset path is intentional — an admin tooling that
forces a clean state for a tenant can call reset(JSentinelVersionKey) per
subject.
Implementations must be thread-safe; concurrent current
and increment calls happen on every authority change.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the currentJSentinelVersionassociated withkey.Atomically bumps the version forkeyby one and returns the new value.voidreset(JSentinelVersionKey key) Resets the version forkeytoJSentinelVersion.INITIAL.
-
Method Details
-
current
Returns the currentJSentinelVersionassociated withkey. ReturnsJSentinelVersion.INITIALwhen the key has never been incremented (i.e. the subject is fresh).- Parameters:
key- tenant + subject; must not benull- Returns:
- current version, never
null
-
increment
Atomically bumps the version forkeyby one and returns the new value. The very first call on a key transitionsJSentinelVersion.INITIALto value1.- Parameters:
key- tenant + subject; must not benull- Returns:
- the new (post-increment) version
-
reset
Resets the version forkeytoJSentinelVersion.INITIAL. No-op when no value was ever recorded.- Parameters:
key- tenant + subject; must not benull
-