public class DefaultCredentialsProvider extends Object implements org.apache.http.client.CredentialsProvider, Serializable
CredentialsProvider
interface. Provides
credentials for both web servers and proxies. Supports Digest
authentication, Socks authentication and Basic HTTP authentication.Modifier and Type | Field and Description |
---|---|
static String |
ANY_HOST
The
null value represents any host. |
static int |
ANY_PORT
The
-1 value represents any port. |
static String |
ANY_REALM
The
null value represents any realm. |
static String |
ANY_SCHEME
The
null value represents any authentication scheme. |
Constructor and Description |
---|
DefaultCredentialsProvider() |
Modifier and Type | Method and Description |
---|---|
void |
addCredentials(String username,
char[] password)
Adds credentials for the specified username/password for any host/port/realm combination.
|
void |
addCredentials(String username,
char[] 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,
char[] password,
String host,
int port,
String workstation,
String domain)
Adds NTLM credentials for the specified username/password on the specified host/port.
|
void |
addSocksCredentials(String username,
char[] password,
String host,
int port)
Adds Socks credentials for the specified username/password on the specified host/port.
|
void |
clear() |
org.apache.http.auth.Credentials |
getCredentials(org.apache.http.auth.AuthScope authscope) |
boolean |
removeCredentials(org.apache.http.auth.AuthScope authscope)
Removes the credentials from the AuthScope.
|
void |
setCredentials(org.apache.http.auth.AuthScope authscope,
org.apache.http.auth.Credentials credentials) |
String |
toString() |
public static final String ANY_HOST
null
value represents any host.public static final int ANY_PORT
-1
value represents any port.public static final String ANY_REALM
null
value represents any realm.public static final String ANY_SCHEME
null
value represents any authentication scheme.public void addCredentials(String username, char[] password)
username
- the username for the new credentialspassword
- the password for the new credentialspublic void addCredentials(String username, char[] password, String host, int port, 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 addNTLMCredentials(String username, char[] password, String host, int port, String workstation, String domain)
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)workstation
- The workstation the authentication request is originating from.
Essentially, the computer name for this machine.domain
- the domain to authenticate withinpublic void addSocksCredentials(String username, char[] password, 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 setCredentials(org.apache.http.auth.AuthScope authscope, org.apache.http.auth.Credentials credentials)
setCredentials
in interface org.apache.http.client.CredentialsProvider
public org.apache.http.auth.Credentials getCredentials(org.apache.http.auth.AuthScope authscope)
getCredentials
in interface org.apache.http.client.CredentialsProvider
public boolean removeCredentials(org.apache.http.auth.AuthScope authscope)
authscope
- the AuthScope to remove the credentials ofpublic void clear()
clear
in interface org.apache.http.client.CredentialsProvider
Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.