Package com.jsgalactic.axiom.security
Record Class SessionState
java.lang.Object
java.lang.Record
com.jsgalactic.axiom.security.SessionState
- Record Components:
identity- the signed-in identity, empty for an anonymous sessionattributes- application data as text; an unmodifiable copycreatedAt- when the session was created; the absolute timeout counts from herelastAccessedAt- when the session was last used; the idle timeout counts from here
public record SessionState(Optional<SecurityIdentity> identity, Map<String,String> attributes, Instant createdAt, Instant lastAccessedAt)
extends Record
The data a
SessionStore keeps for one session: who is signed in, application attributes
and two timestamps. Immutable; the store, not the caller, owns the timestamps.
Attribute names match [A-Za-z0-9_.:-]{1,128}, values are at most 4,096 characters, and
at most 64 attributes are kept, so a store can bound what one session
costs. The session identifier is not part of the state.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMost attributes one session holds.static final intLongest attribute value, in characters. -
Constructor Summary
ConstructorsConstructorDescriptionSessionState(Optional<SecurityIdentity> identity, Map<String, String> attributes, Instant createdAt, Instant lastAccessedAt) Validates and copies the components. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattributesrecord component.Returns the value of thecreatedAtrecord component.static SessionStateempty()Returns an anonymous state without attributes; the store stamps the times.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.identity()Returns the value of theidentityrecord component.Returns the value of thelastAccessedAtrecord component.toString()Returns a string representation of this record class.withAttributes(Map<String, String> attributes) Returns a copy with other attributes.withIdentity(Optional<SecurityIdentity> identity) Returns a copy with another identity.Returns a copy with other timestamps.
-
Field Details
-
MAX_ATTRIBUTES
public static final int MAX_ATTRIBUTESMost attributes one session holds.- See Also:
-
MAX_VALUE_LENGTH
public static final int MAX_VALUE_LENGTHLongest attribute value, in characters.- See Also:
-
-
Constructor Details
-
SessionState
public SessionState(Optional<SecurityIdentity> identity, Map<String, String> attributes, Instant createdAt, Instant lastAccessedAt) Validates and copies the components.- Throws:
IllegalArgumentException- if an attribute name or value is invalid or there are too many
-
-
Method Details
-
empty
Returns an anonymous state without attributes; the store stamps the times.- Returns:
- the empty state
-
withIdentity
Returns a copy with another identity.- Parameters:
identity- the identity, or empty- Returns:
- the copy
-
withAttributes
Returns a copy with other attributes.- Parameters:
attributes- the attributes- Returns:
- the copy
-
withTimes
Returns a copy with other timestamps.- Parameters:
createdAt- the creation timelastAccessedAt- the last access time- Returns:
- the copy
-
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. -
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. -
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). -
identity
Returns the value of theidentityrecord component.- Returns:
- the value of the
identityrecord component
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-
lastAccessedAt
Returns the value of thelastAccessedAtrecord component.- Returns:
- the value of the
lastAccessedAtrecord component
-