Class AbstractHttpServerAuthFilter<T>

  • Type Parameters:
    T - authorization token representation.
    All Implemented Interfaces:
    HttpFilterHandler

    @Contract(threading=STATELESS)
    public abstract class AbstractHttpServerAuthFilter<T>
    extends java.lang.Object
    implements HttpFilterHandler
    Abstract HTTP request filter that implements standard HTTP authentication handshake.
    Since:
    5.0
    • Field Detail

      • respondImmediately

        private final boolean respondImmediately
    • Constructor Detail

      • AbstractHttpServerAuthFilter

        protected AbstractHttpServerAuthFilter​(boolean respondImmediately)
    • Method Detail

      • parseChallengeResponse

        protected abstract T parseChallengeResponse​(java.lang.String authorizationValue,
                                                    HttpContext context)
                                             throws HttpException
        Parses authorization header value into an authentication token sent by the client as a response to an authentication challenge.
        Parameters:
        authorizationValue - the authorization header value.
        context - the actual execution context.
        Returns:
        authorization token
        Throws:
        HttpException
      • authenticate

        protected abstract boolean authenticate​(T challengeResponse,
                                                URIAuthority authority,
                                                java.lang.String requestUri,
                                                HttpContext context)
        Authenticates the client using the authentication token sent by the client as a response to an authentication challenge.
        Parameters:
        challengeResponse - the authentication token sent by the client as a response to an authentication challenge.
        authority - the URI authority.
        requestUri - the request URI.
        context - the actual execution context.
        Returns:
        true if the client could be successfully authenticated false otherwise.
      • generateChallenge

        protected abstract java.lang.String generateChallenge​(T challengeResponse,
                                                              URIAuthority authority,
                                                              java.lang.String requestUri,
                                                              HttpContext context)
        Generates an authentication challenge in case of unsuccessful authentication.
        Parameters:
        challengeResponse - the authentication token sent by the client as a response to an authentication challenge or null if the client has not sent any.
        authority - the URI authority.
        requestUri - the request URI.
        context - the actual execution context.
        Returns:
        an authorization challenge value.
      • generateResponseContent

        protected HttpEntity generateResponseContent​(HttpResponse unauthorized)
        Generates response body for UNAUTHORIZED response.
        Parameters:
        unauthorized - the response to return as a result of authentication failure.
        Returns:
        the response content entity.