|
||||||||||
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(String username,
String password)
Adds credentials for the specified username/password for any host/port/realm combination. |
void |
addCredentials(String username,
String password,
String host,
int port,
String realm)
Adds credentials for the specified username/password on the specified host/port for the specified realm. |
void |
addNTLMCredentials(String username,
String password,
String host,
int port,
String clientHost,
String clientDomain)
Adds NTLM credentials for the specified username/password on the specified host/port. |
void |
addNTLMProxyCredentials(String username,
String password,
String host,
int port,
String clientHost,
String clientDomain)
Adds NTLM proxy credentials for the specified username/password on the specified host/port. |
void |
addProxyCredentials(String username,
String password)
Adds proxy credentials for the specified username/password for any host/port/realm combination. |
void |
addProxyCredentials(String username,
String password,
String host,
int port)
Adds proxy credentials for the specified username/password on the specified host/port. |
protected boolean |
alreadyAnswered(AuthScheme scheme,
String host,
int port,
boolean proxy)
Indicates if this provider has already provided an answer for this (scheme, host, port, proxy). |
protected Object |
buildKey(AuthScheme scheme,
String host,
int port,
boolean proxy)
Build a key with the specified data |
protected void |
clearAnswered()
Clears the cache of answered (scheme, host, port, proxy) combinations. |
Credentials |
getCredentials(AuthScheme scheme,
String host,
int port,
boolean proxy)
Returns the credentials associated with the specified scheme, host and port |
protected Log |
getLog()
Return the log object for this class |
protected void |
markAsAnswered(AuthScheme scheme,
String host,
int port,
boolean proxy)
|
protected boolean |
matchHost(AuthScope scope,
String host)
|
protected boolean |
matchPort(AuthScope scope,
int port)
|
protected boolean |
matchRealm(AuthScope scope,
AuthScheme scheme)
|
protected boolean |
matchScheme(AuthScope scope,
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(String username, String password)
username
- The username for the new credentials.password
- The password for the new credentials.public void addCredentials(String username, String password, String host, int port, String realm)
username
- The username for the new credentials.password
- The password for the new credentials.host
- 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(String username, String password)
username
- The username for the new credentials.password
- The password for the new credentials.public void addProxyCredentials(String username, String password, String host, int port)
username
- The username for the new credentials.password
- The password for the new credentials.host
- 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(String username, String password, String host, int port, String clientHost, String clientDomain)
username
- The username for the new credentials. This should not include the domain to authenticate with.
For example: "user" is correct whereas "DOMAIN\\user" is not.password
- The password for the new credentials.host
- 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 within.public void addNTLMProxyCredentials(String username, String password, String host, int port, String clientHost, String clientDomain)
username
- The username for the new credentials. This should not include the domain to authenticate with.
For example: "user" is correct whereas "DOMAIN\\user" is not.password
- The password for the new credentials.host
- 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 within.public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy) throws CredentialsNotAvailableException
getCredentials
in interface CredentialsProvider
scheme
- The authentication scheme being used (basic, digest, NTLM, etc).host
- The host we are authenticating for.port
- The port we are authenticating for.proxy
- Whether or not we are authenticating using a proxy.
null
if already asked for it to avoid infinite loop
CredentialsNotAvailableException
- If the specified credentials cannot be provided due to an error.CredentialsProvider.getCredentials(AuthScheme, String, int, boolean)
protected boolean matchRealm(AuthScope scope, 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(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(AuthScope scope, 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(AuthScope scope, 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(AuthScheme scheme, String host, int port, boolean proxy)
scheme
- The schemehost
- the server name.port
- the server port.proxy
- is proxy
protected void markAsAnswered(AuthScheme scheme, String host, int port, boolean proxy)
scheme
- The schemehost
- the server name.port
- the server port.proxy
- is proxyprotected void clearAnswered()
protected Object buildKey(AuthScheme scheme, String host, int port, boolean proxy)
scheme
- The schemehost
- the server name.port
- the server port.proxy
- is proxy
protected final Log getLog()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |