Record Class RememberMeTokenRecord
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.authentication.RememberMeTokenRecord
- Record Components:
tokenHash- non-blank token hash; the plain token is never storedtenant- tenant scope;nullbecomesTenantId.DEFAULTsubjectId- authenticated subject the token grantscreatedAt- when the token was issuedexpiresAt- absolute expiry; must be strictly aftercreatedAt
@ExperimentalJSentinelApi
public record RememberMeTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt)
extends Record
Persistent representation of a single "remember me" token.
Stores only the hash of the token, never the
plain value: the plain token lives in a cookie on the user's
device and must not be reconstructable from the store.
Implementations of
RememberMeTokenStore
keep the same hashing convention they apply at lookup time.
expiresAt is the absolute expiry instant; auth flows
compare it to Instant.now() (or a clock-injected
equivalent) and reject the token outside the validity window.
-
Constructor Summary
ConstructorsConstructorDescriptionRememberMeTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt) Validates the record components and normalisesnulltenant toTenantId.DEFAULT. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresAtrecord component.final inthashCode()Returns a hash code value for this object.booleanReturnstruewhen the token is past its expiry at the supplied instant.Returns the value of thesubjectIdrecord component.tenant()Returns the value of thetenantrecord component.Returns the value of thetokenHashrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RememberMeTokenRecord
public RememberMeTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt) Validates the record components and normalisesnulltenant toTenantId.DEFAULT.- Parameters:
tokenHash- non-blank token hashtenant- tenant scope;nullbecomes DEFAULTsubjectId- non-null subjectcreatedAt- non-null creation instantexpiresAt- non-null expiry instant, strictly after createdAt
-
-
Method Details
-
isExpired
Returnstruewhen the token is past its expiry at the supplied instant.- Parameters:
now- reference instant; must not benull- Returns:
- whether the token is expired
-
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). -
tokenHash
-
tenant
-
subjectId
-
createdAt
-
expiresAt
-