com.gargoylesoftware.htmlunit
Class DefaultCredentialsProvider

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.DefaultCredentialsProvider
All Implemented Interfaces:
java.io.Serializable, org.apache.commons.httpclient.auth.CredentialsProvider

public class DefaultCredentialsProvider
extends java.lang.Object
implements org.apache.commons.httpclient.auth.CredentialsProvider, java.io.Serializable

Default HtmlUnit implementation of the CredentialsProvider interface. Provides credentials for both web servers and proxies. Supports NTLM authentication, Digest authentication, and Basic HTTP authentication.

Version:
$Revision: 1.3 $
Author:
Daniel Gredler, Vikram Shitole, Marc Guillemot, Ahmed Ashour
See Also:
Serialized Form

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.
 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCredentialsProvider

public DefaultCredentialsProvider()
Creates a new DefaultCredentialsProvider instance.

Method Detail

addCredentials

public void addCredentials(java.lang.String username,
                           java.lang.String password)
Adds credentials for the specified username/password for any host/port/realm combination. The credentials may be for any authentication scheme, including NTLM, digest and basic HTTP authentication. If you are using sensitive username/password information, please do NOT use this method. If you add credentials using this method, any server that requires authentication will receive the specified username and password.

Parameters:
username - The username for the new credentials.
password - The password for the new credentials.

addCredentials

public 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. The credentials may be for any authentication scheme, including NTLM, digest and basic HTTP authentication.

Parameters:
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).

addNTLMCredentials

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)
Adds NTLM credentials for the specified username/password on the specified host/port.

Parameters:
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.

addNTLMProxyCredentials

public 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.

Parameters:
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.

addProxyCredentials

public void addProxyCredentials(java.lang.String username,
                                java.lang.String password)
Adds proxy credentials for the specified username/password for any host/port/realm combination.

Parameters:
username - The username for the new credentials.
password - The password for the new credentials.

addProxyCredentials

public 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.

Parameters:
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).

getCredentials

public 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
Returns the credentials associated with the specified scheme, host and port

Specified by:
getCredentials in interface org.apache.commons.httpclient.auth.CredentialsProvider
Parameters:
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.
Returns:
The credentials corresponding to the specified scheme, host and port or null if already asked for it to avoid infinite loop
Throws:
org.apache.commons.httpclient.auth.CredentialsNotAvailableException - If the specified credentials cannot be provided due to an error.
See Also:
CredentialsProvider.getCredentials(AuthScheme, String, int, boolean)


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.