Record Class SessionContext<U>

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.session.SessionContext<U>
Type Parameters:
U - subject type
Record Components:
subject - the authenticated subject; may be null for navigation events that occur before login
sessionId - stable session identifier; may be null
createdAt - when the session was first established
lastActivity - most recent activity within the session; null when no activity has been recorded yet
clientAddress - remote client address as observed by the adapter, or null
attributes - free-form non-null attribute map (defensive copy)

public record SessionContext<U>(U subject, String sessionId, Instant createdAt, Instant lastActivity, String clientAddress, Map<String,Object> attributes) extends Record
Adapter-neutral session view for the SessionPolicy.

The Vaadin and REST adapters build this record from their respective runtime types (VaadinSession, HTTP session) so the policy stays Vaadin-free and unit-testable.

  • Constructor Details

    • SessionContext

      public SessionContext(U subject, String sessionId, Instant createdAt, Instant lastActivity, String clientAddress, Map<String,Object> attributes)
      Creates an instance of a SessionContext record class.
      Parameters:
      subject - the value for the subject record component
      sessionId - the value for the sessionId record component
      createdAt - the value for the createdAt record component
      lastActivity - the value for the lastActivity record component
      clientAddress - the value for the clientAddress record component
      attributes - the value for the attributes record component
  • Method Details

    • 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 Objects::equals(Object,Object).
      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.
    • subject

      public U subject()
      Returns the value of the subject record component.
      Returns:
      the value of the subject record component
    • sessionId

      public String sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component
    • createdAt

      public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • lastActivity

      public Instant lastActivity()
      Returns the value of the lastActivity record component.
      Returns:
      the value of the lastActivity record component
    • clientAddress

      public String clientAddress()
      Returns the value of the clientAddress record component.
      Returns:
      the value of the clientAddress record component
    • attributes

      public Map<String,Object> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component