Class Sessions.Builder

java.lang.Object
com.jsgalactic.axiom.security.Sessions.Builder
Enclosing class:
Sessions

public static final class Sessions.Builder extends Object
Builds Sessions; used during configuration, not thread-safe.
  • Method Details

    • cookieName

      public Sessions.Builder cookieName(String name)
      Sets the cookie name. A __Host- or __Secure- prefix is checked against the other settings when built.
      Parameters:
      name - cookie name, an HTTP token
      Returns:
      this builder
    • secure

      public Sessions.Builder secure(boolean secure)
      Sets the Secure attribute (on by default). Browsers drop Secure cookies received over plain HTTP, so turn it off only for local development.
      Parameters:
      secure - whether the cookie is Secure
      Returns:
      this builder
    • sameSite

      public Sessions.Builder sameSite(SetCookie.SameSite sameSite)
      Sets SameSite (Lax by default). NONE requires Secure.
      Parameters:
      sameSite - the attribute
      Returns:
      this builder
    • path

      public Sessions.Builder path(String path)
      Sets the cookie path (default /).
      Parameters:
      path - path starting with /
      Returns:
      this builder
    • domain

      public Sessions.Builder domain(String domain)
      Sets a cookie domain, which sends the cookie to every sub-domain; the default is host-only.
      Parameters:
      domain - a lower-case DNS name without a leading dot
      Returns:
      this builder
    • maxAge

      public Sessions.Builder maxAge(Duration maxAge)
      Makes the cookie persistent for this long (default: a browser-session cookie). The store's timeouts still decide when the session ends.
      Parameters:
      maxAge - 0 to 400 days
      Returns:
      this builder
    • random

      public Sessions.Builder random(SecureRandom random)
      Sets the source of identifiers; for tests that need determinism.
      Parameters:
      random - a cryptographically strong generator
      Returns:
      this builder
    • maxCookieHeader

      public Sessions.Builder maxCookieHeader(int maxCookieHeader)
      Sets the longest Cookie header read (default 8,192 characters).
      Parameters:
      maxCookieHeader - 64 to 65,536
      Returns:
      this builder
    • build

      public Sessions build()
      Builds the sessions.
      Returns:
      the middleware
      Throws:
      IllegalArgumentException - if the cookie settings are inconsistent