Class CookieSessionInjector<A,B extends Session<A>,C extends ExchangeContext,D extends Exchange<C>>

java.lang.Object
io.inverno.mod.session.http.CookieSessionInjector<A,B,C,D>
Type Parameters:
A - the session data type
B - the session type
C - the exchange context type
D - the exchange type
All Implemented Interfaces:
SessionInjector<A,B,C,D>

public class CookieSessionInjector<A,B extends Session<A>,C extends ExchangeContext,D extends Exchange<C>> extends Object implements SessionInjector<A,B,C,D>

A session injector that sets the session identifier in a response cookie.

The secure flag is set on the session cookie when the server is configured with TLS (HTTPS). An application deployed behind an SSL offloader is likely to be configured without TLS and as a result it is up to the SSL offloader to set the secure flag on the session cookie.

Since:
1.13
Author:
Jeremy Kuhn
  • Field Details

  • Constructor Details

    • CookieSessionInjector

      public CookieSessionInjector()

      Creates a cookie session injector with default path and session cookie name.

    • CookieSessionInjector

      public CookieSessionInjector(String path)

      Creates a cookie session injector with specified path and default session cookie name.

      Parameters:
      path - the session cookie path
    • CookieSessionInjector

      public CookieSessionInjector(String path, String sessionCookie)

      Creates a cookie session injector with specified path and session cookie name.

      Parameters:
      path - the session cookie path
      sessionCookie - the session cookie name
  • Method Details

    • getPath

      public String getPath()

      Returns the session cookie path.

      Returns:
      the session cookie path
    • getSessionCookie

      public String getSessionCookie()

      Returns the session cookie name.

      Returns:
      the session cookie name
    • getSameSitePolicy

      public Headers.SetCookie.SameSitePolicy getSameSitePolicy()

      Returns the cookie same site policy.

      Returns:
      the same site policy
    • setSameSitePolicy

      public void setSameSitePolicy(Headers.SetCookie.SameSitePolicy sameSitePolicy)

      Sets the cookie same site policy

      Parameters:
      sameSitePolicy - a same site policy
    • inject

      public Mono<Void> inject(D exchange, B session)
      Description copied from interface: SessionInjector

      Injects the specified session into the exchange.

      Specified by:
      inject in interface SessionInjector<A,B extends Session<A>,C extends ExchangeContext,D extends Exchange<C>>
      Parameters:
      exchange - the exchange
      session - the session
      Returns:
      a mono which completes when the session has been injected
    • remove

      public Mono<Void> remove(D exchange)
      Description copied from interface: SessionInjector

      Removes the session from the exchange.

      Specified by:
      remove in interface SessionInjector<A,B extends Session<A>,C extends ExchangeContext,D extends Exchange<C>>
      Parameters:
      exchange - the exchange
      Returns:
      a mono which completes when the session has been removed