Interface Authenticator

  • All Known Implementing Classes:
    AuthenticatorAdapter

    public interface Authenticator
    Responds to authentication challenges from the remote web or proxy server.
    • Method Detail

      • authenticate

        Request authenticate​(Proxy proxy,
                             Response response)
                      throws IOException
        Returns a request that includes a credential to satisfy an authentication challenge in response. Returns null if the challenge cannot be satisfied. This method is called in response to an HTTP 401 unauthorized status code sent by the origin server.

        Typical implementations will look up a credential and create a request derived from the initial request by setting the "Authorization" header.

           
        
            String credential = Credentials.basic(...)
            return response.request().newBuilder()
                .header("Authorization", credential)
                .build();
         
        Throws:
        IOException
      • authenticateProxy

        Request authenticateProxy​(Proxy proxy,
                                  Response response)
                           throws IOException
        Returns a request that includes a credential to satisfy an authentication challenge made by response. Returns null if the challenge cannot be satisfied. This method is called in response to an HTTP 407 unauthorized status code sent by the proxy server.

        Typical implementations will look up a credential and create a request derived from the initial request by setting the "Proxy-Authorization" header.

           
        
            String credential = Credentials.basic(...)
            return response.request().newBuilder()
                .header("Proxy-Authorization", credential)
                .build();
         
        Throws:
        IOException