Record Class PasswordResetTokenRecord
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.accountlifecycle.PasswordResetTokenRecord
- Record Components:
tokenHash- non-blank token hashtenant- tenant scope;nullbecomesTenantId.DEFAULTsubjectId- subject whose password the token resetscreatedAt- when the token was issuedexpiresAt- absolute expiry, strictly aftercreatedAtconsumedAt- instant the token was consumed, or empty when still pending; if present must be strictly aftercreatedAt
@ExperimentalJSentinelApi
public record PasswordResetTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt)
extends Record
Persistent representation of a single password-reset token.
Single-use: once consumedAt is set the token must not be
honoured again. Stores only the hash of the
token; the plain value is delivered to the user (e.g. as a
reset-link query parameter) and never persisted.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconsumedAtrecord component.Returns 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.booleanReturns whether the token has been consumed.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.Returns a copy withconsumedAt()set toat— the canonical way to mark a token consumed.
-
Constructor Details
-
PasswordResetTokenRecord
public PasswordResetTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt) Validates the record components and normalisesnulltenant /nullconsumedAt.- Parameters:
tokenHash- non-blank token hashtenant- tenant scope;nullbecomes DEFAULTsubjectId- non-null subjectcreatedAt- non-null creation instantexpiresAt- non-null expiry, strictly after createdAtconsumedAt- null becomes empty Optional
-
-
Method Details
-
withConsumedAt
Returns a copy withconsumedAt()set toat— the canonical way to mark a token consumed.- Parameters:
at- instant the token was consumed; must not benull- Returns:
- new record with
consumedAt = Optional.of(at)
-
isConsumed
public boolean isConsumed()Returns whether the token has been consumed.- Returns:
truewhen consumedAt is present
-
isExpired
Returnstruewhen the token is past its expiry at the supplied instant.- Parameters:
now- reference instant; non-null- 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
-
consumedAt
Returns the value of theconsumedAtrecord component.- Returns:
- the value of the
consumedAtrecord component
-