Class AuthenticationErrorInterceptor<A extends ExchangeContext,B extends ErrorExchange<A>>

java.lang.Object
io.inverno.mod.security.http.AuthenticationErrorInterceptor<A,B>
Type Parameters:
A - the context type
B - the error echange type
All Implemented Interfaces:
ExchangeInterceptor<A,B>
Direct Known Subclasses:
FormAuthenticationErrorInterceptor, HttpAuthenticationErrorInterceptor

public abstract class AuthenticationErrorInterceptor<A extends ExchangeContext,B extends ErrorExchange<A>> extends Object implements ExchangeInterceptor<A,B>

Base implemenation for authentication error interceptors.

An authentication error interceptor intercepts UNAUTHORIZED(401) errors in order to provide authentication instructions to the requester in the error response. Such interceptor is typically used to initiate the authentication process with the requester.

Since:
1.5
Author:
Jeremy Kuhn
  • Field Details

    • terminal

      protected final boolean terminal
      Flag indicating whether the interceptor should claim the exchange (i.e. terminates the exchange by returning an empty response).
  • Constructor Details

    • AuthenticationErrorInterceptor

      protected AuthenticationErrorInterceptor()

      Creates a non-terminating authentication error interceptor.

    • AuthenticationErrorInterceptor

      protected AuthenticationErrorInterceptor(boolean terminal)

      Creates an authentication error interceptor.

      If terminal, the interceptor claims the exchange and return an empty response resulting in no further processing.

      Parameters:
      terminal - true to terminate the exchange, false otherwise
  • Method Details

    • intercept

      public Mono<? extends B> intercept(B exchange)
      Description copied from interface: ExchangeInterceptor

      Intercepts the exchange before the exchange handler is invoked.

      Specified by:
      intercept in interface ExchangeInterceptor<A extends ExchangeContext,B extends ErrorExchange<A>>
      Parameters:
      exchange - the server exchange to handle
      Returns:
      a Mono emitting the exchange or an instrumented exchange to continue the exchange handling chain or an empty Mono to stop the exchange handling chain
    • interceptUnauthorized

      protected abstract void interceptUnauthorized(B exchange) throws HttpException

      Intercepts an unauthorized exchange.

      Parameters:
      exchange - the unauthorized exchange to intercept
      Throws:
      HttpException - if there was an error intercepting the exchange