Class AuthenticatorAdapter
- java.lang.Object
-
- com.squareup.okhttp.internal.http.AuthenticatorAdapter
-
- All Implemented Interfaces:
Authenticator
public final class AuthenticatorAdapter extends Object implements Authenticator
AdaptsAuthenticatortoAuthenticator.
-
-
Field Summary
Fields Modifier and Type Field Description static AuthenticatorINSTANCEUses the global authenticator to get the password.
-
Constructor Summary
Constructors Constructor Description AuthenticatorAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Requestauthenticate(Proxy proxy, Response response)Returns a request that includes a credential to satisfy an authentication challenge inresponse.RequestauthenticateProxy(Proxy proxy, Response response)Returns a request that includes a credential to satisfy an authentication challenge made byresponse.
-
-
-
Field Detail
-
INSTANCE
public static final Authenticator INSTANCE
Uses the global authenticator to get the password.
-
-
Method Detail
-
authenticate
public Request authenticate(Proxy proxy, Response response) throws IOException
Description copied from interface:AuthenticatorReturns a request that includes a credential to satisfy an authentication challenge inresponse. 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();- Specified by:
authenticatein interfaceAuthenticator- Throws:
IOException
-
authenticateProxy
public Request authenticateProxy(Proxy proxy, Response response) throws IOException
Description copied from interface:AuthenticatorReturns a request that includes a credential to satisfy an authentication challenge made byresponse. 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();- Specified by:
authenticateProxyin interfaceAuthenticator- Throws:
IOException
-
-