- All Known Implementing Classes:
NetAuthenticator
public interface Authenticator
Responds to authentication challenges from origin web servers or proxies. Implementations may either attempt to
authenticate preemptively (before a challenge is received) or reactively (in response to a challenge). An application
can supply a single authenticator for both origin and proxy authentication, or separate authenticators for each.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AuthenticatorAn authenticator that does not attempt to authenticate and always returns null. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(Route route, Response response) Returns a request that includes a credential to satisfy an authentication challenge inresponse.
-
Field Details
-
NONE
An authenticator that does not attempt to authenticate and always returns null.
-
-
Method Details
-
authenticate
Returns a request that includes a credential to satisfy an authentication challenge inresponse. Returnsnullif the challenge cannot be satisfied.The
routeparameter is a best-effort and may not always be provided, especially when an authenticator is invoked manually in an application interceptor (e.g., for client-specific retries).- Parameters:
route- The route that resulted in the challenge, or null if not available.response- The response containing the authentication challenge.- Returns:
- A new request with the appropriate authentication header, or null if no response is possible.
- Throws:
IOException- if an I/O error occurs.
-