public interface AuthorizationHandler
AuthorizationInfo.setAuthHandler(HTTPClient.AuthorizationHandler)
Modifier and Type | Method and Description |
---|---|
AuthorizationInfo |
fixupAuthInfo(AuthorizationInfo info,
RoRequest req,
AuthorizationInfo challenge,
RoResponse resp)
This method is called whenever auth info is chosen from the list of
known info in the AuthorizationInfo class to be sent with a request.
|
AuthorizationInfo |
getAuthorization(AuthorizationInfo challenge,
RoRequest req,
RoResponse resp)
This method is called whenever a 401 or 407 response is received and
no candidate info is found in the list of known auth info.
|
void |
handleAuthHeaders(Response resp,
RoRequest req,
AuthorizationInfo prev,
AuthorizationInfo prxy)
Sometimes even non-401 responses will contain headers pertaining to
authorization (such as the "Authentication-Info" header).
|
void |
handleAuthTrailers(Response resp,
RoRequest req,
AuthorizationInfo prev,
AuthorizationInfo prxy)
This method is similar to
handleAuthHeaders except that
it is called if any headers in the trailer were sent. |
AuthorizationInfo getAuthorization(AuthorizationInfo challenge, RoRequest req, RoResponse resp) throws AuthSchemeNotImplException, java.io.IOException
If the returned info is not null it will be added to the list of known info. If the info is valid for more than one (host, port, realm, scheme) tuple then this method must add the corresponding auth infos itself.
This method must check req.allow_ui and only attempt user interaction if it's true.
challenge
- the parsed challenge from the server; the host,
port, scheme, realm and params are set to the
values given by the server in the challenge.req
- the request which provoked this response.resp
- the full response.AuthSchemeNotImplException
- if the authorization scheme
in the challenge cannot be handled.java.io.IOException
- if an exception occurs while processing the
challengeAuthorizationInfo fixupAuthInfo(AuthorizationInfo info, RoRequest req, AuthorizationInfo challenge, RoResponse resp) throws AuthSchemeNotImplException, java.io.IOException
info
- the authorization info retrieved from the list of
known info.req
- the request this info is targeted for.challenge
- the authorization challenge received from the server
if this is in response to a 401, or null if we are
preemptively sending the info.resp
- the full 401 response received, or null if we are
preemptively sending the info.AuthSchemeNotImplException
- if the authorization scheme
in the info cannot be handled.java.io.IOException
- if an exception occurs while fixing up the
infovoid handleAuthHeaders(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) throws java.io.IOException
fixupAuthInfo()
and getAuthorization()
are
invoked after this method.resp
- the full Responsereq
- the Request which provoked this responseprev
- the previous auth info sent, or null if none was sentprxy
- the previous proxy auth info sent, or null if none was sentjava.io.IOException
- if an exception occurs during the reading of
the headers.void handleAuthTrailers(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) throws java.io.IOException
handleAuthHeaders
except that
it is called if any headers in the trailer were sent. This also
implies that it is invoked after any fixupAuthInfo()
or
getAuthorization()
invocation.resp
- the full Responsereq
- the Request which provoked this responseprev
- the previous auth info sent, or null if none was sentprxy
- the previous proxy auth info sent, or null if none was sentjava.io.IOException
- if an exception occurs during the reading of
the trailers.handleAuthHeaders(HTTPClient.Response, HTTPClient.RoRequest, HTTPClient.AuthorizationInfo, HTTPClient.AuthorizationInfo)