|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.HttpState
A container for HTTP attributes that may persist from request
to request, such as Cookie
s and authentication
Credentials
.
Preemptive authentication can be turned on by using the property value of #PREEMPTIVE_PROPERTY. If left unspecified, it has the default value of #PREEMPTIVE_DEFAULT. This configurable behaviour conforms to rcf2617:
Field Summary | |
static HttpAuthRealm |
DEFAULT_AUTH_REALM
The default authentication realm. |
static String |
PREEMPTIVE_DEFAULT
The default property value for #PREEMPTIVE_PROPERTY. |
static String |
PREEMPTIVE_PROPERTY
The boolean property name to turn on preemptive authentication. |
Constructor Summary | |
HttpState()
Constructor for HttpState. |
Method Summary | |
void |
addCookie(Cookie cookie)
Add a cookie. |
void |
addCookies(Cookie[] newcookies)
Add zero or more cookies If any given cookie has already expired, deletes the corresponding existing cookie (if any). |
int |
getCookiePolicy()
Return the current CookiePolicy |
Cookie[] |
getCookies()
Obtain an array of my Cookie s. |
Cookie[] |
getCookies(String domain,
int port,
String path,
boolean secure)
Obtain an array of my Cookie s that
match the given request parameters. |
Cookie[] |
getCookies(String domain,
int port,
String path,
boolean secure,
Date now)
Deprecated. use HttpState.getCookies(String, int, String, boolean) |
Credentials |
getCredentials(String realm)
Deprecated. This method does not distinguish between realms on different servers with the same name. Use getCredentials(String, String)
instead. |
Credentials |
getCredentials(String realm,
String host)
Get the Credentials for the given authentication realm. |
HttpConnectionManager |
getHttpConnectionManager()
Deprecated. Connection manager is controlled by the HttpClient class. Use HttpClient.getHttpConnectionManager() instead. |
Credentials |
getProxyCredentials(String realm)
Deprecated. This method does not distinguish between realms on different hosts. Use getProxyCredentials(String, String) instead. |
Credentials |
getProxyCredentials(String realm,
String proxyHost)
Get the Credentials for the proxy with the given authentication realm on the given host. |
boolean |
isAuthenticationPreemptive()
Return true if preemptive authentication should be attempted, otherwise return false |
boolean |
purgeExpiredCookies()
Remove all of my Cookie s that
have expired according to the current
system time. |
boolean |
purgeExpiredCookies(Date date)
Remove all of my Cookie s that have expired by the specified
date. |
void |
setAuthenticationPreemptive(boolean value)
Defines whether preemptive authentication should be attempted or not. |
void |
setCookiePolicy(int policy)
Set the CookiePolicy to one of CookiePolicy.COMPATIBILITY , CookiePolicy.NETSCAPE_DRAFT or
CookiePolicy.RFC2109 |
void |
setCredentials(String realm,
Credentials credentials)
Deprecated. This method does not distinguish between realms with the same name on different hosts. Use setCredentials(String, Credentials) instead. |
void |
setCredentials(String realm,
String host,
Credentials credentials)
Sets the credentials for realm on host. |
void |
setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Deprecated. Connection manager is controlled by the HttpClient class. Use HttpClient.setHttpConnectionManager(HttpConnectionManager) instead. |
void |
setProxyCredentials(String realm,
Credentials credentials)
Deprecated. This method does not differentiate between realms with the same name on different servers. Use setProxyCredentials(String, String, Credentials) instead. |
void |
setProxyCredentials(String realm,
String proxyHost,
Credentials credentials)
Set the credentials for the proxy with the given authentication realm. |
String |
toString()
Return a string representation of this object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final String PREEMPTIVE_PROPERTY
public static final String PREEMPTIVE_DEFAULT
public static final HttpAuthRealm DEFAULT_AUTH_REALM
Constructor Detail |
public HttpState()
Method Detail |
public void addCookie(Cookie cookie)
cookie
- the Cookie
to addaddCookies(Cookie[])
public void addCookies(Cookie[] newcookies)
newcookies
- the Cookie
s to addaddCookie(Cookie)
public Cookie[] getCookies()
Cookie
s.Cookie
s.getCookies(String, int, String, boolean, java.util.Date)
public Cookie[] getCookies(String domain, int port, String path, boolean secure, Date now)
Cookie
s that
match the given request parameters.domain
- the request domainport
- the request portpath
- the request pathsecure
- true
when using HTTPSnow
- the Date
by which expiration is determinedCookie
s.Cookie.matches(java.lang.String, int, java.lang.String, boolean, java.util.Date)
,
getCookies()
public Cookie[] getCookies(String domain, int port, String path, boolean secure)
Cookie
s that
match the given request parameters.domain
- the request domainport
- the request portpath
- the request pathsecure
- true
when using HTTPSCookie
s.Cookie.matches(java.lang.String, int, java.lang.String, boolean, java.util.Date)
,
getCookies()
public boolean purgeExpiredCookies()
Cookie
s that
have expired according to the current
system time.purgeExpiredCookies(java.util.Date)
public boolean purgeExpiredCookies(Date date)
Cookie
s that have expired by the specified
date.date
- The date to compare against.Cookie.isExpired(java.util.Date)
,
purgeExpiredCookies()
public int getCookiePolicy()
CookiePolicy
public void setAuthenticationPreemptive(boolean value)
value
- boolean flagpublic boolean isAuthenticationPreemptive()
public void setCookiePolicy(int policy)
CookiePolicy
to one of CookiePolicy.COMPATIBILITY
, CookiePolicy.NETSCAPE_DRAFT
or
CookiePolicy.RFC2109
policy
- new cookie policypublic void setCredentials(String realm, Credentials credentials)
setCredentials(String, Credentials)
instead.
null
, I'll use the given
credentials when no other Credentials
have
been supplied for the given challenging realm.
(I.e., use a null
realm to set the "default"
credentials.)
Any previous credentials for this realm will be overwritten.
realm
- the authentication realmcredentials
- the authentication credentials for the given realmgetCredentials(String, String)
,
setProxyCredentials(String, String, Credentials)
public void setCredentials(String realm, String host, Credentials credentials)
null
, I'll use the given
credentials when no other Credentials
have
been supplied for the given challenging realm.
(I.e., use a null
realm to set the "default"
credentials.)
Any previous credentials for this realm will be overwritten.
realm
- the authentication realmhost
- the host the realm belongs tocredentials
- the authentication credentials for the given realm.getCredentials(String, String)
,
setProxyCredentials(String, String, Credentials)
public Credentials getCredentials(String realm, String host)
null
.realm
- the authentication realmhost
- the host the realm is onsetCredentials(String, String, Credentials)
public Credentials getCredentials(String realm)
getCredentials(String, String)
instead.
null
.realm
- the authentication realmsetCredentials(String, String, Credentials)
public void setProxyCredentials(String realm, Credentials credentials)
setProxyCredentials(String, String, Credentials)
instead.
null
, I'll use the given
credentials when no other Credentials
have
been supplied for the given challenging realm.
(I.e., use a null
realm to set the "default"
credentials.) Realms rarely make much sense with proxies, so
null
is normally a good choice here.
Any previous credentials for this realm will be overwritten.
realm
- the authentication realmcredentials
- the authentication credentials for the given realmgetProxyCredentials(String)
,
setCredentials(String, Credentials)
public void setProxyCredentials(String realm, String proxyHost, Credentials credentials)
null
, I'll use the given
credentials when no other Credentials
have
been supplied for the given challenging realm.
(I.e., use a null
realm to set the "default"
credentials.) Realms rarely make much sense with proxies, so
null
is normally a good choice here.
Any previous credentials for this realm will be overwritten.
realm
- the authentication realmproxyHost
- the proxy hostcredentials
- the authentication credentials for the given realmgetProxyCredentials(String)
,
setCredentials(String, Credentials)
public Credentials getProxyCredentials(String realm)
getProxyCredentials(String, String)
instead.
null
.realm
- the authentication realmsetProxyCredentials(String, String, Credentials)
public Credentials getProxyCredentials(String realm, String proxyHost)
null
.realm
- the authentication realmproxyHost
- the proxy host the realm is onsetProxyCredentials(String, String, Credentials)
public String toString()
Object.toString()
public HttpConnectionManager getHttpConnectionManager()
HttpClient.getHttpConnectionManager()
instead.
public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
HttpClient.setHttpConnectionManager(HttpConnectionManager)
instead.
httpConnectionManager
- The httpConnectionManager to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |