com.gargoylesoftware.htmlunit
Class DefaultCredentialsProvider

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.DefaultCredentialsProvider
All Implemented Interfaces:
Serializable, CredentialsProvider

public class DefaultCredentialsProvider
extends Object
implements CredentialsProvider, 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: 5738 $
Author:
Daniel Gredler, Vikram Shitole, Marc Guillemot, Ahmed Ashour, Nicolas Belisle
See Also:
Serialized Form

Constructor Summary
DefaultCredentialsProvider()
           
 
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 workstation, String domain)
          Adds NTLM credentials for the specified username/password on the specified host/port.
 void addNTLMProxyCredentials(String username, String password, String host, int port, String workstation, String domain)
          Deprecated. as of 2.8, please use addNTLMCredentials(String, String, String, int, String, String) instead
 void addProxyCredentials(String username, String password)
          Deprecated. as of 2.8, please use addCredentials(String, String) instead
 void addProxyCredentials(String username, String password, String host, int port)
          Deprecated. as of 2.8, please use addCredentials(String, String, String, int, String) instead
 void clear()
          
 Credentials getCredentials(AuthScope authscope)
          
 void setCredentials(AuthScope authscope, Credentials credentials)
          
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultCredentialsProvider

public DefaultCredentialsProvider()
Method Detail

addCredentials

public void addCredentials(String username,
                           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 may 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(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. 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)

addProxyCredentials

@Deprecated
public void addProxyCredentials(String username,
                                           String password)
Deprecated. as of 2.8, please use addCredentials(String, String) instead

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

@Deprecated
public void addProxyCredentials(String username,
                                           String password,
                                           String host,
                                           int port)
Deprecated. as of 2.8, please use addCredentials(String, String, String, int, String) instead

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)

addNTLMCredentials

public void addNTLMCredentials(String username,
                               String password,
                               String host,
                               int port,
                               String workstation,
                               String domain)
Adds NTLM credentials for the specified username/password on the specified host/port.

Parameters:
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 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)
workstation - The workstation the authentication request is originating from. Essentially, the computer name for this machine.
domain - the domain to authenticate within
See Also:
How to use NTML authenticaion

addNTLMProxyCredentials

@Deprecated
public void addNTLMProxyCredentials(String username,
                                               String password,
                                               String host,
                                               int port,
                                               String workstation,
                                               String domain)
Deprecated. as of 2.8, please use addNTLMCredentials(String, String, String, int, String, String) instead

Adds NTLM proxy credentials for the specified username/password on the specified host/port.

Parameters:
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 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)
workstation - the host the authentication request is originating from; essentially, the computer name for this machine
domain - the domain to authenticate within

setCredentials

public void setCredentials(AuthScope authscope,
                           Credentials credentials)

Specified by:
setCredentials in interface CredentialsProvider

getCredentials

public Credentials getCredentials(AuthScope authscope)

Specified by:
getCredentials in interface CredentialsProvider

toString

public String toString()

Overrides:
toString in class Object

clear

public void clear()

Specified by:
clear in interface CredentialsProvider


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.