Record Class SessionRecord
- Record Components:
sessionId- unique session identifiersubjectId- authenticated subject; non-nulltenant- tenant scope;nullbecomesTenantId.DEFAULTcreatedAt- when the session was opened; non-nulllastActivityAt- last activity on the session; non-null, must not predatecreatedAtsecurityVersionAtLogin- subject security version at login; non-nullstatus- current lifecycle state; non-null
Stored by SessionStore keyed on sessionId();
queried by
(tenant, subjectId) when an admin or a security service
needs to enumerate every session of a given subject (e.g.
"revoke all sessions of alice after a password change").
The securityVersionAtLogin component is the
JSentinelVersion of the subject at the moment this session
was opened. A planned JSentinelVersionCheck interceptor
(Phase 4 of the V00.70 roadmap) compares this value to the
subject's current security version on every request: a
mismatch means the subject's authority has changed since login,
and the session must be re-validated.
Mutation: records are immutable. Callers update fields by
building a new SessionRecord via the with…
convenience methods and calling SessionStore.save(...)
again.
-
Constructor Summary
ConstructorsConstructorDescriptionSessionRecord(SessionId sessionId, SubjectId subjectId, TenantId tenant, Instant createdAt, Instant lastActivityAt, JSentinelVersion securityVersionAtLogin, SessionStatus status) Validates the record components and normalises anulltenant toTenantId.DEFAULT. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelastActivityAtrecord component.Returns the value of thesecurityVersionAtLoginrecord component.Returns the value of thesessionIdrecord component.status()Returns the value of thestatusrecord component.Returns the value of thesubjectIdrecord component.tenant()Returns the value of thetenantrecord component.final StringtoString()Returns a string representation of this record class.withLastActivityAt(Instant newLastActivity) Returns a copy withlastActivityAt()updated tonewLastActivity.withStatus(SessionStatus newStatus) Returns a copy withstatus()updated tonewStatus.
-
Constructor Details
-
SessionRecord
public SessionRecord(SessionId sessionId, SubjectId subjectId, TenantId tenant, Instant createdAt, Instant lastActivityAt, JSentinelVersion securityVersionAtLogin, SessionStatus status) Validates the record components and normalises anulltenant toTenantId.DEFAULT.- Parameters:
sessionId- unique session identifier; non-nullsubjectId- authenticated subject; non-nulltenant- tenant scope;nullbecomes DEFAULTcreatedAt- creation instant; non-nulllastActivityAt- last activity instant; non-null and not beforecreatedAtsecurityVersionAtLogin- subject security version; non-nullstatus- lifecycle state; non-null
-
-
Method Details
-
withLastActivityAt
Returns a copy withlastActivityAt()updated tonewLastActivity.- Parameters:
newLastActivity- new last-activity instant; non-null- Returns:
- new
SessionRecord; receiver unchanged
-
withStatus
Returns a copy withstatus()updated tonewStatus. Use this to transition anSessionStatus.ACTIVEsession toSessionStatus.EXPIREDorSessionStatus.REVOKED.- Parameters:
newStatus- new lifecycle state; non-null- Returns:
- new
SessionRecord; receiver unchanged
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
sessionId
-
subjectId
-
tenant
-
createdAt
-
lastActivityAt
Returns the value of thelastActivityAtrecord component.- Returns:
- the value of the
lastActivityAtrecord component
-
securityVersionAtLogin
Returns the value of thesecurityVersionAtLoginrecord component.- Returns:
- the value of the
securityVersionAtLoginrecord component
-
status
-