|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.htmlunit.DefaultCredentialsProvider
public class DefaultCredentialsProvider
Default HtmlUnit implementation of the CredentialsProvider interface. Provides credentials for both web servers and proxies. Supports NTLM authentication, Digest authentication, and Basic HTTP authentication.
Field Summary |
---|
Fields inherited from interface org.apache.commons.httpclient.auth.CredentialsProvider |
---|
PROVIDER |
Constructor Summary | |
---|---|
DefaultCredentialsProvider()
Creates a new DefaultCredentialsProvider instance. |
Method Summary | |
---|---|
void |
addCredentials(java.lang.String username,
java.lang.String password)
Adds credentials for the specified username/password for any host/port/realm combination. |
void |
addCredentials(java.lang.String username,
java.lang.String password,
java.lang.String host,
int port,
java.lang.String realm)
Adds credentials for the specified username/password on the specified host/port for the specified realm. |
void |
addNTLMCredentials(java.lang.String username,
java.lang.String password,
java.lang.String host,
int port,
java.lang.String clientHost,
java.lang.String clientDomain)
Adds NTLM credentials for the specified username/password on the specified host/port. |
void |
addNTLMProxyCredentials(java.lang.String username,
java.lang.String password,
java.lang.String host,
int port,
java.lang.String clientHost,
java.lang.String clientDomain)
Adds NTLM proxy credentials for the specified username/password on the specified host/port. |
void |
addProxyCredentials(java.lang.String username,
java.lang.String password)
Adds proxy credentials for the specified username/password for any host/port/realm combination. |
void |
addProxyCredentials(java.lang.String username,
java.lang.String password,
java.lang.String host,
int port)
Adds proxy credentials for the specified username/password on the specified host/port. |
protected boolean |
alreadyAnswered(org.apache.commons.httpclient.auth.AuthScheme scheme,
java.lang.String host,
int port,
boolean proxy)
Returns true if this provider has already provided an answer for the specified (scheme, host, port, proxy) combination. |
protected java.lang.Object |
buildKey(org.apache.commons.httpclient.auth.AuthScheme scheme,
java.lang.String host,
int port,
boolean proxy)
Builds a key with the specified data. |
protected void |
clearAnswered()
Clears the cache of answered (scheme, host, port, proxy) combinations. |
org.apache.commons.httpclient.Credentials |
getCredentials(org.apache.commons.httpclient.auth.AuthScheme scheme,
java.lang.String host,
int port,
boolean proxy)
Returns the credentials associated with the specified scheme, host and port. |
protected void |
markAsAnswered(org.apache.commons.httpclient.auth.AuthScheme scheme,
java.lang.String host,
int port,
boolean proxy)
Marks the specified (scheme, host, port, proxy) combination as having already been processed. |
protected boolean |
matchHost(org.apache.commons.httpclient.auth.AuthScope scope,
java.lang.String host)
|
protected boolean |
matchPort(org.apache.commons.httpclient.auth.AuthScope scope,
int port)
|
protected boolean |
matchRealm(org.apache.commons.httpclient.auth.AuthScope scope,
org.apache.commons.httpclient.auth.AuthScheme scheme)
|
protected boolean |
matchScheme(org.apache.commons.httpclient.auth.AuthScope scope,
org.apache.commons.httpclient.auth.AuthScheme scheme)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultCredentialsProvider()
Method Detail |
---|
public void addCredentials(java.lang.String username, java.lang.String password)
username
- the username for the new credentialspassword
- the password for the new credentialspublic void addCredentials(java.lang.String username, java.lang.String password, java.lang.String host, int port, java.lang.String realm)
username
- the username for the new credentialspassword
- the password for the new credentialshost
- the host to which to the new credentials apply (null if applicable to any host)port
- the port to which to the new credentials apply (negative if applicable to any port)realm
- the realm to which to the new credentials apply (null if applicable to any realm)public void addProxyCredentials(java.lang.String username, java.lang.String password)
username
- the username for the new credentialspassword
- the password for the new credentialspublic void addProxyCredentials(java.lang.String username, java.lang.String password, java.lang.String host, int port)
username
- the username for the new credentialspassword
- the password for the new credentialshost
- the host to which to the new credentials apply (null if applicable to any host)port
- the port to which to the new credentials apply (negative if applicable to any port)public void addNTLMCredentials(java.lang.String username, java.lang.String password, java.lang.String host, int port, java.lang.String clientHost, java.lang.String clientDomain)
username
- the username for the new credentials; should not include the domain to authenticate with;
for example: "user" is correct whereas "DOMAIN\\user" is notpassword
- the password for the new credentialshost
- the host to which to the new credentials apply (null if applicable to any host)port
- the port to which to the new credentials apply (negative if applicable to any port)clientHost
- the host the authentication request is originating from; essentially, the computer name for
this machine.clientDomain
- the domain to authenticate withinpublic void addNTLMProxyCredentials(java.lang.String username, java.lang.String password, java.lang.String host, int port, java.lang.String clientHost, java.lang.String clientDomain)
username
- the username for the new credentials; should not include the domain to authenticate with;
for example: "user" is correct whereas "DOMAIN\\user" is not.password
- the password for the new credentialshost
- the host to which to the new credentials apply (null if applicable to any host)port
- the port to which to the new credentials apply (negative if applicable to any port)clientHost
- the host the authentication request is originating from; essentially, the computer name for
this machineclientDomain
- the domain to authenticate withinpublic org.apache.commons.httpclient.Credentials getCredentials(org.apache.commons.httpclient.auth.AuthScheme scheme, java.lang.String host, int port, boolean proxy) throws org.apache.commons.httpclient.auth.CredentialsNotAvailableException
getCredentials
in interface org.apache.commons.httpclient.auth.CredentialsProvider
scheme
- the authentication scheme being used (basic, digest, NTLM, etc)host
- the host we are authenticating forport
- the port we are authenticating forproxy
- Whether or not we are authenticating using a proxy
null
if already asked for it to avoid infinite loop
org.apache.commons.httpclient.auth.CredentialsNotAvailableException
- if the specified credentials cannot be provided due to an errorCredentialsProvider.getCredentials(AuthScheme, String, int, boolean)
protected boolean matchRealm(org.apache.commons.httpclient.auth.AuthScope scope, org.apache.commons.httpclient.auth.AuthScheme scheme)
scheme
- the request scheme for which Credentials are askedscope
- the configured authorization scope
true
if the scope's realm matches the one of the schemeprotected boolean matchPort(org.apache.commons.httpclient.auth.AuthScope scope, int port)
port
- the request port for which Credentials are askedscope
- the configured authorization scope
true
if the scope's port matches the provided oneprotected boolean matchHost(org.apache.commons.httpclient.auth.AuthScope scope, java.lang.String host)
host
- the request host for which Credentials are askedscope
- the configured authorization scope
true
if the scope's host matches the provided oneprotected boolean matchScheme(org.apache.commons.httpclient.auth.AuthScope scope, org.apache.commons.httpclient.auth.AuthScheme scheme)
scheme
- the request scheme for which Credentials are askedscope
- the configured authorization scope
true
if the scope's scheme matches the provided oneprotected boolean alreadyAnswered(org.apache.commons.httpclient.auth.AuthScheme scheme, java.lang.String host, int port, boolean proxy)
scheme
- the schemehost
- the server nameport
- the server portproxy
- is proxy
protected void markAsAnswered(org.apache.commons.httpclient.auth.AuthScheme scheme, java.lang.String host, int port, boolean proxy)
scheme
- the schemehost
- the server nameport
- the server portproxy
- is proxyprotected void clearAnswered()
protected java.lang.Object buildKey(org.apache.commons.httpclient.auth.AuthScheme scheme, java.lang.String host, int port, boolean proxy)
scheme
- the schemehost
- the server nameport
- the server portproxy
- is proxy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |