Class VaadinJSentinelVersionContext

java.lang.Object
com.svenruppert.jsentinel.session.vaadin.VaadinJSentinelVersionContext

@ExperimentalJSentinelApi public final class VaadinJSentinelVersionContext extends Object
Per-VaadinSession carrier for the security-version snapshot captured at login time. The Vaadin enforcer listener consults this context on every navigation; the application records it once after a successful login via record.

Stored as a single VaadinJSentinelVersionContext.Snapshot object under the VaadinJSentinelVersionContext.Snapshot class key, so it survives session-id rotation (the attribute lives on the VaadinSession, not on the WrappedSession).

This class only reads and writes — it does not consult the JSentinelVersionStore itself. Apps that want "capture-current-on-login" semantics pair this helper with a call to versionStore.current(new JSentinelVersionKey(tenant, subjectId)) right before record.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Per-session security state captured at login time.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Removes the snapshot from VaadinSession.getCurrent().
    static void
    clear(com.vaadin.flow.server.VaadinSession session)
    Removes the snapshot from session.
    Reads the recorded snapshot from VaadinSession.getCurrent().
    current(com.vaadin.flow.server.VaadinSession session)
    Returns the recorded snapshot for session, or empty when none was recorded.
    static void
    record(com.svenruppert.jsentinel.logout.SubjectId subjectId, com.svenruppert.jsentinel.authorization.api.tenant.TenantId tenant, com.svenruppert.jsentinel.session.JSentinelVersion snapshot, String sessionId)
    Convenience overload writing to VaadinSession.getCurrent().
    static void
    record(com.vaadin.flow.server.VaadinSession session, com.svenruppert.jsentinel.logout.SubjectId subjectId, com.svenruppert.jsentinel.authorization.api.tenant.TenantId tenant, com.svenruppert.jsentinel.session.JSentinelVersion snapshot, String sessionId)
    Records the snapshot on the supplied session.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • record

      public static void record(com.vaadin.flow.server.VaadinSession session, com.svenruppert.jsentinel.logout.SubjectId subjectId, com.svenruppert.jsentinel.authorization.api.tenant.TenantId tenant, com.svenruppert.jsentinel.session.JSentinelVersion snapshot, String sessionId)
      Records the snapshot on the supplied session. Replaces any previously recorded snapshot.
      Parameters:
      session - target session; non-null
      subjectId - authenticated subject; non-null
      tenant - tenant scope; null becomes TenantId.DEFAULT
      snapshot - security version captured at login time; non-null
      sessionId - opaque session identifier (typically the servlet-session id); may be null when the adapter does not track session ids
    • record

      public static void record(com.svenruppert.jsentinel.logout.SubjectId subjectId, com.svenruppert.jsentinel.authorization.api.tenant.TenantId tenant, com.svenruppert.jsentinel.session.JSentinelVersion snapshot, String sessionId)
      Convenience overload writing to VaadinSession.getCurrent(). No-op when no session is bound.
      Parameters:
      subjectId - authenticated subject; non-null
      tenant - tenant scope; null becomes TenantId.DEFAULT
      snapshot - security version captured at login time; non-null
      sessionId - opaque session identifier; may be null
    • current

      public static Optional<VaadinJSentinelVersionContext.Snapshot> current(com.vaadin.flow.server.VaadinSession session)
      Returns the recorded snapshot for session, or empty when none was recorded.
      Parameters:
      session - session to query; null returns empty
      Returns:
      recorded snapshot, if present
    • current

      Reads the recorded snapshot from VaadinSession.getCurrent().
      Returns:
      recorded snapshot, if present
    • clear

      public static void clear(com.vaadin.flow.server.VaadinSession session)
      Removes the snapshot from session. No-op when no snapshot was recorded.
      Parameters:
      session - session to clear; null is a no-op
    • clear

      public static void clear()
      Removes the snapshot from VaadinSession.getCurrent().