Class BasicAuthenticator


  • final class BasicAuthenticator
    extends java.lang.Object
    Implementation of Basic Http Authentication method (RFC 2617).
    • Constructor Detail

      • BasicAuthenticator

        BasicAuthenticator​(HttpAuthenticationFilter.Credentials defaultCredentials)
        Creates a new instance of basic authenticator.
        Parameters:
        defaultCredentials - Credentials. Can be null if no default credentials should be used.
    • Method Detail

      • filterRequest

        public void filterRequest​(javax.ws.rs.client.ClientRequestContext request)
                           throws RequestAuthenticationException
        Adds authentication information to the request.
        Parameters:
        request - Request context.
        Throws:
        RequestAuthenticationException - in case that basic credentials missing or are in invalid format
      • filterResponseAndAuthenticate

        public boolean filterResponseAndAuthenticate​(javax.ws.rs.client.ClientRequestContext request,
                                                     javax.ws.rs.client.ClientResponseContext response)
        Checks the response and if basic authentication is required then performs a new request with basic authentication.
        Parameters:
        request - Request context.
        response - Response context (will be updated with newest response data if the request was repeated).
        Returns:
        true if response does not require authentication or if authentication is required, new request was done with digest authentication information and authentication was successful.
        Throws:
        ResponseAuthenticationException - in case that basic credentials missing or are in invalid format