Class DefaultAuthHandler
java.lang.Object
org.exoplatform.common.http.client.DefaultAuthHandler
- All Implemented Interfaces:
AuthorizationHandler
This class is the default authorization handler. It currently handles the
authentication schemes "Basic", "Digest", and "SOCKS5" (used for the
SocksClient and not part of HTTP per se).
By default, when a username and password is required, this handler throws up
a message box requesting the desired info. However, applications can
set their
own authorization prompter if desired.
Note: all methods except for setAuthorizationPrompter are meant to be invoked by the AuthorizationModule only, i.e. should not be invoked by the application (those methods are only public because implementing the AuthorizationHandler interface requires them to be).
- Since:
- V0.2
- Version:
- 0.3-3 06/05/2001
- Author:
- Ronald Tschal���r
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intContent delimitersstatic final intpossible http protocols we (might) handlestatic final intsome known http versionsstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfixupAuthInfo(AuthorizationInfo info, RoRequest req, AuthorizationInfo challenge, RoResponse resp) For Digest authentication we need to set the uri, response and opaque parameters.getAuthorization(AuthorizationInfo challenge, RoRequest req, RoResponse resp) returns the requested authorization, or null if none was given.voidhandleAuthHeaders(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) We handle the "Authentication-Info" and "Proxy-Authentication-Info" headers here.voidhandleAuthTrailers(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) We handle the "Authentication-Info" and "Proxy-Authentication-Info" trailers here.static AuthorizationPrompterSet a new username/password prompter.
-
Field Details
-
HTTP
static final int HTTPpossible http protocols we (might) handle- See Also:
-
HTTPS
static final int HTTPS- See Also:
-
SHTTP
static final int SHTTP- See Also:
-
HTTP_NG
static final int HTTP_NG- See Also:
-
HTTP_1_0
static final int HTTP_1_0some known http versions- See Also:
-
HTTP_1_1
static final int HTTP_1_1- See Also:
-
CD_NONE
static final int CD_NONEContent delimiters- See Also:
-
CD_HDRS
static final int CD_HDRS- See Also:
-
CD_0
static final int CD_0- See Also:
-
CD_CLOSE
static final int CD_CLOSE- See Also:
-
CD_CONTLEN
static final int CD_CONTLEN- See Also:
-
CD_CHUNKED
static final int CD_CHUNKED- See Also:
-
CD_MP_BR
static final int CD_MP_BR- See Also:
-
-
Constructor Details
-
DefaultAuthHandler
public DefaultAuthHandler()
-
-
Method Details
-
fixupAuthInfo
public AuthorizationInfo fixupAuthInfo(AuthorizationInfo info, RoRequest req, AuthorizationInfo challenge, RoResponse resp) throws AuthSchemeNotImplException For Digest authentication we need to set the uri, response and opaque parameters. For "Basic" and "SOCKS5" nothing is done.- Specified by:
fixupAuthInfoin interfaceAuthorizationHandler- Parameters:
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.- Returns:
- the authorization info to be sent with the request, or null if none is to be sent.
- Throws:
AuthSchemeNotImplException- if the authorization scheme in the info cannot be handled.
-
getAuthorization
public AuthorizationInfo getAuthorization(AuthorizationInfo challenge, RoRequest req, RoResponse resp) throws AuthSchemeNotImplException, IOException returns the requested authorization, or null if none was given.- Specified by:
getAuthorizationin interfaceAuthorizationHandler- Parameters:
challenge- the parsed challenge from the server.req- the request which solicited this responseresp- the full response received- Returns:
- a structure containing the necessary authorization info, or null
- Throws:
AuthSchemeNotImplException- if the authentication scheme in the challenge cannot be handled.IOException- if an exception occurs while processing the challenge
-
handleAuthHeaders
public void handleAuthHeaders(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) throws IOException We handle the "Authentication-Info" and "Proxy-Authentication-Info" headers here.- Specified by:
handleAuthHeadersin interfaceAuthorizationHandler- Parameters:
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 sent- Throws:
IOException- if an exception occurs during the reading of the headers.
-
handleAuthTrailers
public void handleAuthTrailers(Response resp, RoRequest req, AuthorizationInfo prev, AuthorizationInfo prxy) throws IOException We handle the "Authentication-Info" and "Proxy-Authentication-Info" trailers here.- Specified by:
handleAuthTrailersin interfaceAuthorizationHandler- Parameters:
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 sent- Throws:
IOException- if an exception occurs during the reading of the trailers.- See Also:
-
setAuthorizationPrompter
Set a new username/password prompter.- Parameters:
prompt- the AuthorizationPrompter to use whenever a username and password are needed; if null, no querying will be done- Returns:
- the previous prompter
-