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 Details

    • INITIAL

      public static final JSentinelVersion 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

      public JSentinelVersion next()
      Returns the next-higher version. Pure function — the receiver is unchanged.
      Returns:
      version with value + 1
    • compareTo

      public int compareTo(JSentinelVersion other)
      Specified by:
      compareTo in interface Comparable<JSentinelVersion>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public long value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component