Record Class CredentialRecord
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.credential.store.CredentialRecord
- Record Components:
username- case-sensitive identifier; nevernullor blankencodedHash- full Phase-1a envelope as storedstatus- current lifecycle statusversion- optimistic-lock counter, starts at 1createdAt- when the record was first writtenupdatedAt- when the record was last written
public record CredentialRecord(String username, String encodedHash, CredentialStatus status, long version, Instant createdAt, Instant updatedAt)
extends Record
Persisted credential row, returned by
CredentialStore reads
and used as the compare-and-swap witness on writes.
The version field is a monotonically increasing
optimistic-lock counter: every successful update returns a new record
with version + 1. CAS callers normally hand back the
encodedHash as the witness, but the version field is exposed
for adapters that prefer numeric optimistic-lock comparisons.
toString() never exposes encodedHash() (CWE-522 /
CWE-209).
-
Constructor Summary
ConstructorsConstructorDescriptionCredentialRecord(String username, String encodedHash, CredentialStatus status, long version, Instant createdAt, Instant updatedAt) Creates an instance of aCredentialRecordrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.Returns the value of theencodedHashrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static CredentialRecordinitial(String username, String encodedHash, CredentialStatus status, Instant now) Convenience: build a fresh record at version 1 with timestamps equal tonow.status()Returns the value of thestatusrecord component.toString()Returns a string representation of this record class.Returns the value of theupdatedAtrecord component.username()Returns the value of theusernamerecord component.longversion()Returns the value of theversionrecord component.Returns a new record with the supplied hash and timestamp, version bumped by one.withStatus(CredentialStatus newStatus, Instant when) Returns a new record with the supplied status and timestamp, version bumped by one.
-
Constructor Details
-
CredentialRecord
public CredentialRecord(String username, String encodedHash, CredentialStatus status, long version, Instant createdAt, Instant updatedAt) Creates an instance of aCredentialRecordrecord class.- Parameters:
username- the value for theusernamerecord componentencodedHash- the value for theencodedHashrecord componentstatus- the value for thestatusrecord componentversion- the value for theversionrecord componentcreatedAt- the value for thecreatedAtrecord componentupdatedAt- the value for theupdatedAtrecord component
-
-
Method Details
-
initial
public static CredentialRecord initial(String username, String encodedHash, CredentialStatus status, Instant now) Convenience: build a fresh record at version 1 with timestamps equal tonow. -
withHash
Returns a new record with the supplied hash and timestamp, version bumped by one. -
withStatus
Returns a new record with the supplied status and timestamp, version bumped by one. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
username
-
encodedHash
Returns the value of theencodedHashrecord component.- Returns:
- the value of the
encodedHashrecord component
-
status
-
version
-
createdAt
-
updatedAt
-