Package com.gargoylesoftware.htmlunit
Class DefaultCredentialsProvider
- java.lang.Object
-
- com.gargoylesoftware.htmlunit.DefaultCredentialsProvider
-
- All Implemented Interfaces:
java.io.Serializable,org.apache.http.client.CredentialsProvider
public class DefaultCredentialsProvider extends java.lang.Object implements org.apache.http.client.CredentialsProvider, java.io.SerializableDefault HtmlUnit implementation of the CredentialsProvider interface. Provides credentials for both web servers and proxies. Supports Digest authentication, and Basic HTTP authentication.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultCredentialsProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCredentials(java.lang.String username, java.lang.String password)Adds credentials for the specified username/password for any host/port/realm combination.voidaddCredentials(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.voidaddNTLMCredentials(java.lang.String username, java.lang.String password, java.lang.String host, int port, java.lang.String workstation, java.lang.String domain)Adds NTLM credentials for the specified username/password on the specified host/port.voidclear()org.apache.http.auth.CredentialsgetCredentials(org.apache.http.auth.AuthScope authscope)booleanremoveCredentials(org.apache.http.auth.AuthScope authscope)Removes the credentials from the AuthScope.voidsetCredentials(org.apache.http.auth.AuthScope authscope, org.apache.http.auth.Credentials credentials)java.lang.StringtoString()
-
-
-
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 may receive the specified username and password.- Parameters:
username- the username for the new credentialspassword- 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 credentialspassword- the password for the new credentialshost- the host to which to the new credentials apply (nullif 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 (nullif 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 workstation, java.lang.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 notpassword- the password for the new credentialshost- the host to which to the new credentials apply (nullif 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
-
setCredentials
public void setCredentials(org.apache.http.auth.AuthScope authscope, org.apache.http.auth.Credentials credentials)- Specified by:
setCredentialsin interfaceorg.apache.http.client.CredentialsProvider
-
getCredentials
public org.apache.http.auth.Credentials getCredentials(org.apache.http.auth.AuthScope authscope)
- Specified by:
getCredentialsin interfaceorg.apache.http.client.CredentialsProvider
-
removeCredentials
public boolean removeCredentials(org.apache.http.auth.AuthScope authscope)
Removes the credentials from the AuthScope.- Parameters:
authscope- the AuthScope to remove the credentials of- Returns:
- whether it was removed or not
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clear
public void clear()
- Specified by:
clearin interfaceorg.apache.http.client.CredentialsProvider
-
-