com.sun.jersey.client.apache.config
Class ApacheHttpClientState

java.lang.Object
  extended by com.sun.jersey.client.apache.config.ApacheHttpClientState

public class ApacheHttpClientState
extends Object

An encapsulation of the Apache HttpState that provides easier functionality for setting up credentials and proxy credentials.

Author:
jorgeluisw@mac.com, Paul.Sandoz@Sun.Com

Constructor Summary
ApacheHttpClientState()
          Create a new instance with a default instance of an Apache HTTP state.
ApacheHttpClientState(org.apache.commons.httpclient.HttpState state)
          Create a new state instance with an Apacahe HTTP state instance.
 
Method Summary
 void clearCredentials()
          Clears all credentials.
 void clearProxyCredentials()
          Clears all proxy credentials.
 org.apache.commons.httpclient.HttpState getHttpState()
          Get the HTTP state.
 void setCredentials(String realm, String host, int port, String usernamepassword)
          Sets the credentials for the given authentication scope.
 void setCredentials(String realm, String host, int port, String username, String password)
          Sets the credentials for the given authentication scope.
 void setCredentials(String realm, String host, int port, String username, String password, String domain, String thisHost)
          Sets the credentials for the given authentication scope.
 void setProxyCredentials(String realm, String host, int port, String usernamepassword)
          Sets the proxy credentials for the given authentication scope.
 void setProxyCredentials(String realm, String host, int port, String username, String password)
          Sets the proxy credentials for the given authentication scope.
 void setProxyCredentials(String realm, String host, int port, String username, String password, String domain, String thisHost)
          Sets the proxy credentials for the given authentication scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheHttpClientState

public ApacheHttpClientState()
Create a new instance with a default instance of an Apache HTTP state.


ApacheHttpClientState

public ApacheHttpClientState(org.apache.commons.httpclient.HttpState state)
Create a new state instance with an Apacahe HTTP state instance.

Parameters:
state - the Apache HTTP state.
Method Detail

setCredentials

public void setCredentials(String realm,
                           String host,
                           int port,
                           String usernamepassword)
Sets the credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
usernamepassword - The username:password formed string.

setCredentials

public void setCredentials(String realm,
                           String host,
                           int port,
                           String username,
                           String password)
Sets the credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
username - The username
password - The password

setCredentials

public void setCredentials(String realm,
                           String host,
                           int port,
                           String username,
                           String password,
                           String domain,
                           String thisHost)
Sets the credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten. This method should be used when setting credentials for the NTLM authentication scheme.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
username - The username, this should not include the domain to authenticate with. For example: "user" is correct wheareas "DOMAIN\\user" is not.
password - The password
thisHost - The host the authentication requiest is originating from. Essentially, the computer name for this machine.
domain - The domain to authentice with.

setProxyCredentials

public void setProxyCredentials(String realm,
                                String host,
                                int port,
                                String usernamepassword)
Sets the proxy credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
usernamepassword - The username:password formed string.

setProxyCredentials

public void setProxyCredentials(String realm,
                                String host,
                                int port,
                                String username,
                                String password)
Sets the proxy credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
username - The username
password - The password

setProxyCredentials

public void setProxyCredentials(String realm,
                                String host,
                                int port,
                                String username,
                                String password,
                                String domain,
                                String thisHost)
Sets the proxy credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten. This method should be used when setting credentials for the NTLM authentication scheme.

Parameters:
realm - The authentication realm. The null realm signifies default credentials for the given host, which should be used when no credentials have been explicitly supplied for the challenging realm.
host - The host the realm belongs to. The null host signifies default credentials which should be used when no credentials have been explicitly supplied for the challenging host.
port - The port the realm belongs to. A negitive port signifies the credentials are applicaple to any port when no credentials have been explicitly supplied for the challenging port.
username - The username, this should not include the domain to authenticate with. For example: "user" is correct wheareas "DOMAIN\\user" is not.
password - The password
thisHost - The host the authentication requiest is originating from. Essentially, the computer name for this machine.
domain - The domain to authentice with.

clearCredentials

public void clearCredentials()
Clears all credentials.


clearProxyCredentials

public void clearProxyCredentials()
Clears all proxy credentials.


getHttpState

public org.apache.commons.httpclient.HttpState getHttpState()
Get the HTTP state.

Returns:
the HTTP state.


Copyright © 2013 Oracle Corporation. All Rights Reserved.