Record Class RefreshTokenRecord
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.authentication.RefreshTokenRecord
- Record Components:
tokenHash- non-blank token hashtenant- tenant scope;nullbecomesTenantId.DEFAULTsubjectId- subject the token authenticatescreatedAt- issuance instantexpiresAt- absolute expiry, strictly after createdAtreplacedByHash- hash of the successor token, empty until the first rotationrevokedAt- revocation instant, empty until revoked
@ExperimentalJSentinelApi
public record RefreshTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt, Optional<String> replacedByHash, Optional<Instant> revokedAt)
extends Record
Persistent representation of a single rotating refresh token.
Hash-only; the plain value is handed to the client exactly once when issued and is presented back on every token-rotation request. Rotation works like this:
- Issue refresh token A.
replacedByHashempty. - Client presents A, server issues access token + new refresh
token B. A is updated with
replacedByHash = hash(B); B starts withreplacedByHashempty. - If A is ever presented again after step 2, it has
replacedByHashset — that is the signal that someone replayed an already-rotated token. The auth flow should revoke the entire chain (the implementation handles that; this record only carries the link).
-
Constructor Summary
Constructors -
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.booleanWhether the token is admissible — not revoked, not replaced, not expired.booleanWhether the token is past expiry atnow.booleanWhetherreplacedByHash()is present.booleanWhetherrevokedAt()is present.Returns the value of thereplacedByHashrecord component.Returns the value of therevokedAtrecord component.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.withReplacedBy(String successorHash) Returns a copy linking this record to its successor.withRevokedAt(Instant at) Returns a copy marked revoked atat.
-
Constructor Details
-
RefreshTokenRecord
-
-
Method Details
-
withReplacedBy
Returns a copy linking this record to its successor.- Parameters:
successorHash- hash of the new token; non-blank- Returns:
- new record with
replacedByHashset
-
withRevokedAt
Returns a copy marked revoked atat.- Parameters:
at- revocation instant; non-null- Returns:
- new record with
revokedAtset
-
isRevoked
public boolean isRevoked()WhetherrevokedAt()is present. -
isReplaced
public boolean isReplaced()WhetherreplacedByHash()is present. -
isExpired
Whether the token is past expiry atnow.- Parameters:
now- reference instant; non-null- Returns:
- whether the token is expired
-
isActive
Whether the token is admissible — not revoked, not replaced, not expired.- Parameters:
now- reference instant; non-null- Returns:
- whether the token can be used for rotation
-
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
-
replacedByHash
Returns the value of thereplacedByHashrecord component.- Returns:
- the value of the
replacedByHashrecord component
-
revokedAt
-