Record Class JSentinelVersion
java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.session.JSentinelVersion
- Record Components:
value- non-negative version counter
- All Implemented Interfaces:
Comparable<JSentinelVersion>
@ExperimentalJSentinelApi
public record JSentinelVersion(long value)
extends Record
implements Comparable<JSentinelVersion>
Monotonically-increasing version of a subject's security-relevant
state (roles, permissions, password, …).
Stored on a SessionRecord as
securityVersionAtLogin; a downstream
JSentinelVersionCheck (planned for V00.70 Phase 4) compares
the value at request time against the subject's current
security version, and refuses the session once they drift apart.
The version is intentionally a long (not an
Instant): it expresses ordering, not real time, and is
cheap to increment from any application code path that mutates a
subject's authority.
INITIAL is the canonical starting point for any new
subject; comparisons (less-than / greater-than) work directly on the
value component.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JSentinelVersionInitial version (zero) — the value used when a subject is first persisted. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(JSentinelVersion other) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.next()Returns the next-higher version.final StringtoString()Returns a string representation of this record class.longvalue()Returns the value of thevaluerecord component.
-
Field Details
-
INITIAL
Initial version (zero) — the value used when a subject is first persisted.
-
-
Constructor Details
-
JSentinelVersion
public JSentinelVersion(long value) Validates the record component.- Parameters:
value- non-negative version counter
-
-
Method Details
-
next
Returns the next-higher version. Pure function — the receiver is unchanged.- Returns:
- version with
value + 1
-
compareTo
- Specified by:
compareToin interfaceComparable<JSentinelVersion>
-
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 with thecomparemethod from their corresponding wrapper classes. -
value
-