|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectHTTPClient.AuthorizationInfo
Holds the information for an authorization response.
There are 7 fields which make up this class: host, port, scheme, realm, cookie, params, and extra_info. The host and port select which server the info will be sent to. The realm is server specified string which groups various URLs under a given server together and which is used to select the correct info when a server issues an auth challenge; for schemes which don't use a realm (such as "NTLM", "PEM", and "Kerberos") the realm must be the empty string (""). The scheme is the authorization scheme used (such as "Basic" or "Digest").
There are basically two formats used for the Authorization header, the one used by the "Basic" scheme and derivatives, and the one used by the "Digest" scheme and derivatives. The first form contains just the the scheme and a "cookie":
Authorization: Basic aGVsbG86d29ybGQ=The second form contains the scheme followed by a number of parameters in the form of name=value pairs:
Authorization: Digest username="hello", realm="test", nonce="42", ...The two fields "cookie" and "params" correspond to these two forms. toString() is used by the AuthorizationModule when generating the Authorization header and will format the info accordingly. Note that "cookie" and "params" are mutually exclusive: if the cookie field is non-null then toString() will generate the first form; otherwise it will generate the second form.
In some schemes "extra" information needs to be kept which doesn't appear directly in the Authorization header. An example of this are the A1 and A2 strings in the Digest scheme. Since all elements in the params field will appear in the Authorization header this field can't be used for storing such info. This is what the extra_info field is for. It is an arbitrary object which can be manipulated by the corresponding setExtraInfo() and getExtraInfo() methods, but which will not be printed by toString().
The addXXXAuthorization(), removeXXXAuthorization(), and getAuthorization() methods manipulate and query an internal list of AuthorizationInfo instances. There can be only one instance per host, port, scheme, and realm combination (see equals()).
| Constructor Summary | |
(package private) |
AuthorizationInfo(AuthorizationInfo templ)
Creates a new copy of the given AuthorizationInfo. |
(package private) |
AuthorizationInfo(String host,
int port)
Creates an new info structure for the specified host and port. |
|
AuthorizationInfo(String host,
int port,
String scheme,
String realm,
NVPair[] params,
Object info)
Creates a new info structure for the specified host and port with the specified scheme, realm, params. |
|
AuthorizationInfo(String host,
int port,
String scheme,
String realm,
String cookie)
Creates a new info structure for the specified host and port with the specified scheme, realm and cookie. |
| Method Summary | |
static void |
addAuthorization(AuthorizationInfo auth_info)
Adds an authorization entry to the list using the default context. |
static void |
addAuthorization(AuthorizationInfo auth_info,
Object context)
Adds an authorization entry to the list. |
static void |
addAuthorization(String host,
int port,
String scheme,
String realm,
String cookie,
NVPair[] params,
Object info)
Adds an authorization entry to the list using the default context. |
static void |
addAuthorization(String host,
int port,
String scheme,
String realm,
String cookie,
NVPair[] params,
Object info,
Object context)
Adds an authorization entry to the list. |
static void |
addBasicAuthorization(String host,
int port,
String realm,
String user,
String passwd)
Adds an authorization entry for the "Basic" authorization scheme to the list using the default context. |
static void |
addBasicAuthorization(String host,
int port,
String realm,
String user,
String passwd,
Object context)
Adds an authorization entry for the "Basic" authorization scheme to the list. |
static void |
addDigestAuthorization(String host,
int port,
String realm,
String user,
String passwd)
Adds an authorization entry for the "Digest" authorization scheme to the list using the default context. |
static void |
addDigestAuthorization(String host,
int port,
String realm,
String user,
String passwd,
Object context)
Adds an authorization entry for the "Digest" authorization scheme to the list. |
void |
addPath(String resource)
Adds the path from the given resource to our path list. |
Object |
clone()
|
boolean |
equals(Object obj)
Two AuthorizationInfos are considered equal if their host, port, scheme and realm match. |
(package private) static AuthorizationInfo |
findBest(RoRequest req)
Tries to find the candidate in the current list of auth info for the given request. |
static AuthorizationHandler |
getAuthHandler()
Get's the current authorization handler. |
(package private) static AuthorizationInfo |
getAuthorization(AuthorizationInfo auth_info,
RoRequest req,
RoResponse resp,
boolean query_auth_h)
Searches for the authorization info using the host, port, scheme and realm from the given info struct. |
static AuthorizationInfo |
getAuthorization(String host,
int port,
String scheme,
String realm)
Searches for the authorization info using the given host, port, scheme and realm. |
static AuthorizationInfo |
getAuthorization(String host,
int port,
String scheme,
String realm,
Object context)
Searches for the authorization info in the given context using the given host, port, scheme and realm. |
(package private) static AuthorizationInfo |
getAuthorization(String host,
int port,
String scheme,
String realm,
RoRequest req,
RoResponse resp,
boolean query_auth_h)
Searches for the authorization info given a host, port, scheme and realm. |
String |
getCookie()
Get the cookie |
Object |
getExtraInfo()
Get the extra info. |
String |
getHost()
Get the host. |
NVPair[] |
getParams()
Get the authentication parameters. |
int |
getPort()
Get the port. |
String |
getRealm()
Get the realm. |
String |
getScheme()
Get the scheme. |
int |
hashCode()
Produces a hash code based on host, scheme and realm. |
(package private) static AuthorizationInfo[] |
parseAuthString(String challenge,
RoRequest req,
RoResponse resp)
Parses the authentication challenge(s) into an array of new info structures for the specified host and port. |
(package private) static AuthorizationInfo |
queryAuthHandler(AuthorizationInfo auth_info,
RoRequest req,
RoResponse resp)
Queries the AuthHandler for authorization info. |
static void |
removeAuthorization(AuthorizationInfo auth_info)
Removes an authorization entry from the list using the default context. |
static void |
removeAuthorization(AuthorizationInfo auth_info,
Object context)
Removes an authorization entry from the list. |
static void |
removeAuthorization(String host,
int port,
String scheme,
String realm)
Removes an authorization entry from the list using the default context. |
static void |
removeAuthorization(String host,
int port,
String scheme,
String realm,
Object context)
Removes an authorization entry from the list. |
static AuthorizationHandler |
setAuthHandler(AuthorizationHandler handler)
Set's the authorization handler. |
void |
setCookie(String cookie)
Set the cookie |
void |
setExtraInfo(Object info)
Set the extra info. |
void |
setParams(NVPair[] params)
Set the authentication parameters. |
String |
toString()
Constructs a string containing the authorization info. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
AuthorizationInfo(String host,
int port)
host - the hostport - the port
public AuthorizationInfo(String host,
int port,
String scheme,
String realm,
NVPair[] params,
Object info)
host - the hostport - the portscheme - the schemerealm - the realmparams - the parameters as an array of name/value pairs, or nullinfo - arbitrary extra info, or null
public AuthorizationInfo(String host,
int port,
String scheme,
String realm,
String cookie)
host - the hostport - the portscheme - the schemerealm - the realmcookie - for the "Basic" scheme this is the base64-encoded
username/password; for the "NTLM" scheme this is the
base64-encoded username/password message.AuthorizationInfo(AuthorizationInfo templ)
templ - the info to copy| Method Detail |
public static AuthorizationHandler setAuthHandler(AuthorizationHandler handler)
If no handler is set then a default
handler is used. This handler currently only handles the "Basic" and
"Digest" schemes and brings up a popup which prompts for the username
and password.
The default handler can be disabled by setting the auth handler to null.
handler - the new authorization handler
AuthorizationHandlerpublic static AuthorizationHandler getAuthHandler()
AuthorizationHandler
public static AuthorizationInfo getAuthorization(String host,
int port,
String scheme,
String realm)
host - the hostport - the portscheme - the schemerealm - the realm
public static AuthorizationInfo getAuthorization(String host,
int port,
String scheme,
String realm,
Object context)
host - the hostport - the portscheme - the schemerealm - the realmcontext - the context this info is associated with
static AuthorizationInfo queryAuthHandler(AuthorizationInfo auth_info,
RoRequest req,
RoResponse resp)
throws AuthSchemeNotImplException,
IOException
auth_info - any info needed by the AuthHandler; at a minimum the
host, scheme and realm should be set.req - the request which initiated this queryresp - the full response
AuthSchemeNotImplException - if this is thrown by
the AuthHandler.
IOException
static AuthorizationInfo getAuthorization(AuthorizationInfo auth_info,
RoRequest req,
RoResponse resp,
boolean query_auth_h)
throws AuthSchemeNotImplException,
IOException
auth_info - the AuthorizationInforeq - the request which initiated this queryresp - the full responsequery_auth_h - if true, query the auth-handler if no info found.
AuthSchemeNotImplException - If thrown by the AuthHandler.
IOException
static AuthorizationInfo getAuthorization(String host,
int port,
String scheme,
String realm,
RoRequest req,
RoResponse resp,
boolean query_auth_h)
throws AuthSchemeNotImplException,
IOException
host - the hostport - the portscheme - the schemerealm - the realmreq - the request which initiated this queryresp - the full responsequery_auth_h - if true, query the auth-handler if no info found.
AuthSchemeNotImplException - If thrown by the AuthHandler.
IOExceptionpublic static void addAuthorization(AuthorizationInfo auth_info)
auth_info - the AuthorizationInfo to add
public static void addAuthorization(AuthorizationInfo auth_info,
Object context)
auth_info - the AuthorizationInfo to addcontext - the context to associate this info with
public static void addAuthorization(String host,
int port,
String scheme,
String realm,
String cookie,
NVPair[] params,
Object info)
host - the hostport - the portscheme - the schemerealm - the realmcookie - the cookieparams - an array of name/value pairs of parametersinfo - arbitrary extra auth info
public static void addAuthorization(String host,
int port,
String scheme,
String realm,
String cookie,
NVPair[] params,
Object info,
Object context)
host - the hostport - the portscheme - the schemerealm - the realmcookie - the cookieparams - an array of name/value pairs of parametersinfo - arbitrary extra auth infocontext - the context to associate this info with
public static void addBasicAuthorization(String host,
int port,
String realm,
String user,
String passwd)
host - the hostport - the portrealm - the realmuser - the usernamepasswd - the password
public static void addBasicAuthorization(String host,
int port,
String realm,
String user,
String passwd,
Object context)
host - the hostport - the portrealm - the realmuser - the usernamepasswd - the passwordcontext - the context to associate this info with
public static void addDigestAuthorization(String host,
int port,
String realm,
String user,
String passwd)
host - the hostport - the portrealm - the realmuser - the usernamepasswd - the password
public static void addDigestAuthorization(String host,
int port,
String realm,
String user,
String passwd,
Object context)
host - the hostport - the portrealm - the realmuser - the usernamepasswd - the passwordcontext - the context to associate this info withpublic static void removeAuthorization(AuthorizationInfo auth_info)
auth_info - the AuthorizationInfo to remove
public static void removeAuthorization(AuthorizationInfo auth_info,
Object context)
auth_info - the AuthorizationInfo to removecontext - the context this info is associated with
public static void removeAuthorization(String host,
int port,
String scheme,
String realm)
host - the hostport - the portscheme - the schemerealm - the realm
public static void removeAuthorization(String host,
int port,
String scheme,
String realm,
Object context)
host - the hostport - the portscheme - the schemerealm - the realmcontext - the context this info is associated withstatic AuthorizationInfo findBest(RoRequest req)
req - the Request
public void addPath(String resource)
resource - the resource from which to extract the path
static AuthorizationInfo[] parseAuthString(String challenge,
RoRequest req,
RoResponse resp)
throws ProtocolException
challenge - a string containing authentication info. This must
have the same format as value part of a
WWW-authenticate response header field, and may
contain multiple authentication challenges.req - the original request.
ProtocolException - if any error during the parsing occurs.public final String getHost()
public final int getPort()
public final String getScheme()
public final String getRealm()
public final String getCookie()
public final void setCookie(String cookie)
cookie - the new cookiepublic final NVPair[] getParams()
public final void setParams(NVPair[] params)
public final Object getExtraInfo()
public final void setExtraInfo(Object info)
info - the extra infopublic String toString()
public int hashCode()
public boolean equals(Object obj)
obj - another AuthorizationInfo against which this one is
to be compared.
public Object clone()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||