| Method from org.apache.commons.httpclient.HttpState Detail: |
public synchronized void addCookie(Cookie cookie) {
LOG.trace("enter HttpState.addCookie(Cookie)");
if (cookie != null) {
// first remove any old cookie that is equivalent
for (Iterator it = cookies.iterator(); it.hasNext();) {
Cookie tmp = (Cookie) it.next();
if (cookie.equals(tmp)) {
it.remove();
break;
}
}
if (!cookie.isExpired()) {
cookies.add(cookie);
}
}
}
Adds an HTTP cookie , replacing any existing equivalent cookies.
If the given cookie has already expired it will not be added, but existing
values will still be removed. |
public synchronized void addCookies(Cookie[] cookies) {
LOG.trace("enter HttpState.addCookies(Cookie[])");
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
this.addCookie(cookies[i]);
}
}
}
Adds an array of HTTP cookies . Cookies are added individually and
in the given array order. If any of the given cookies has already expired it will
not be added, but existing values will still be removed. |
public void clear() {
clearCookies();
clearCredentials();
clearProxyCredentials();
}
Clears the state information (all cookies, credentials and proxy credentials). |
public synchronized void clearCookies() {
this.cookies.clear();
}
|
public void clearCredentials() {
this.credMap.clear();
}
|
public void clearProxyCredentials() {
this.proxyCred.clear();
}
Clears all proxy credentials. |
public int getCookiePolicy() {
return this.cookiePolicy;
} Deprecated! Use -
org.apache.commons.httpclient.params.HttpMethodParams#getCookiePolicy() ,
HttpMethod#getParams() .
|
public synchronized Cookie[] getCookies() {
LOG.trace("enter HttpState.getCookies()");
return (Cookie[]) (cookies.toArray(new Cookie[cookies.size()]));
}
Returns an array of cookies that this HTTP
state currently contains. |
public synchronized Cookie[] getCookies(String domain,
int port,
String path,
boolean secure) {
LOG.trace("enter HttpState.getCookies(String, int, String, boolean)");
CookieSpec matcher = CookiePolicy.getDefaultSpec();
ArrayList list = new ArrayList(cookies.size());
for (int i = 0, m = cookies.size(); i < m; i++) {
Cookie cookie = (Cookie) (cookies.get(i));
if (matcher.match(domain, port, path, secure, cookie)) {
list.add(cookie);
}
}
return (Cookie[]) (list.toArray(new Cookie[list.size()]));
} Deprecated! use - CookieSpec#match(String, int, String, boolean, Cookie)
Returns an array of cookies in this HTTP
state that match the given request parameters. |
public synchronized Credentials getCredentials(AuthScope authscope) {
if (authscope == null) {
throw new IllegalArgumentException("Authentication scope may not be null");
}
LOG.trace("enter HttpState.getCredentials(AuthScope)");
return matchCredentials(this.credMap, authscope);
}
Get the credentials for the given authentication scope. |
public synchronized Credentials getCredentials(String realm,
String host) {
LOG.trace("enter HttpState.getCredentials(String, String");
return matchCredentials(this.credMap,
new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME));
} Deprecated! use - #getCredentials(AuthScope)
Get the credentials for the given authentication scope on the
given host.
If the realm exists on host, return the coresponding credentials.
If the host exists with a null realm, return the corresponding
credentials.
If the realm exists with a null host, return the
corresponding credentials. If the realm does not exist, return
the default Credentials. If there are no default credentials, return
null. |
public synchronized Credentials getProxyCredentials(AuthScope authscope) {
if (authscope == null) {
throw new IllegalArgumentException("Authentication scope may not be null");
}
LOG.trace("enter HttpState.getProxyCredentials(AuthScope)");
return matchCredentials(this.proxyCred, authscope);
}
|
public synchronized Credentials getProxyCredentials(String realm,
String proxyHost) {
LOG.trace("enter HttpState.getCredentials(String, String");
return matchCredentials(this.proxyCred,
new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME));
} Deprecated! use - #getProxyCredentials(AuthScope)
Get the credentials for the proxy host with the given
authentication scope.
If the realm exists on host, return the coresponding credentials.
If the host exists with a null realm, return the corresponding
credentials.
If the realm exists with a null host, return the
corresponding credentials. If the realm does not exist, return
the default Credentials. If there are no default credentials, return
null. |
public boolean isAuthenticationPreemptive() {
return this.preemptive;
} Deprecated! Use -
org.apache.commons.httpclient.params.HttpClientParams#isAuthenticationPreemptive() ,
HttpClient#getParams() .
Returns true if preemptive authentication should be
attempted, false otherwise. |
public synchronized boolean purgeExpiredCookies() {
LOG.trace("enter HttpState.purgeExpiredCookies()");
return purgeExpiredCookies(new Date());
}
Removes all of cookies in this HTTP state
that have expired according to the current system time. |
public synchronized boolean purgeExpiredCookies(Date date) {
LOG.trace("enter HttpState.purgeExpiredCookies(Date)");
boolean removed = false;
Iterator it = cookies.iterator();
while (it.hasNext()) {
if (((Cookie) (it.next())).isExpired(date)) {
it.remove();
removed = true;
}
}
return removed;
}
Removes all of cookies in this HTTP state
that have expired by the specified date . |
public void setAuthenticationPreemptive(boolean value) {
this.preemptive = value;
} Deprecated! Use -
org.apache.commons.httpclient.params.HttpClientParams#setAuthenticationPreemptive(boolean) ,
HttpClient#getParams() .
Defines whether preemptive authentication should be
attempted. |
public void setCookiePolicy(int policy) {
this.cookiePolicy = policy;
} Deprecated! Use - org.apache.commons.httpclient.params.HttpMethodParams#setCookiePolicy(String) ,
HttpMethod#getParams() .
|
public synchronized void setCredentials(AuthScope authscope,
Credentials credentials) {
if (authscope == null) {
throw new IllegalArgumentException("Authentication scope may not be null");
}
LOG.trace("enter HttpState.setCredentials(AuthScope, Credentials)");
credMap.put(authscope, credentials);
}
Sets the credentials for the given authentication
scope. Any previous credentials for the given scope will be overwritten. |
public synchronized void setCredentials(String realm,
String host,
Credentials credentials) {
LOG.trace("enter HttpState.setCredentials(String, String, Credentials)");
credMap.put(new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials);
} Deprecated! use - #setCredentials(AuthScope, Credentials)
Sets the credentials for the given authentication
realm on the given host. The null realm signifies default
credentials for the given host, which should be used when no
credentials have been explictly supplied for the
challenging realm. The null host signifies default
credentials, which should be used when no credentials
have been explictly supplied for the challenging host. Any previous
credentials for the given realm on the given host will be overwritten. |
public synchronized void setProxyCredentials(AuthScope authscope,
Credentials credentials) {
if (authscope == null) {
throw new IllegalArgumentException("Authentication scope may not be null");
}
LOG.trace("enter HttpState.setProxyCredentials(AuthScope, Credentials)");
proxyCred.put(authscope, credentials);
}
Sets the proxy credentials for the given authentication
realm. Any previous credentials for the given realm will be overwritten. |
public synchronized void setProxyCredentials(String realm,
String proxyHost,
Credentials credentials) {
LOG.trace("enter HttpState.setProxyCredentials(String, String, Credentials");
proxyCred.put(new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials);
} Deprecated! use - #setProxyCredentials(AuthScope, Credentials)
Sets the credentials for the given proxy authentication
realm on the given proxy host. The null proxy realm signifies
default credentials for the given proxy host, which should be used when no
credentials have been explictly supplied for the
challenging proxy realm. The null proxy host signifies default
credentials, which should be used when no credentials
have been explictly supplied for the challenging proxy host. Any previous
credentials for the given proxy realm on the given proxy host will be
overwritten. |
public synchronized String toString() {
StringBuffer sbResult = new StringBuffer();
sbResult.append("[");
sbResult.append(getCredentialsStringRepresentation(proxyCred));
sbResult.append(" | ");
sbResult.append(getCredentialsStringRepresentation(credMap));
sbResult.append(" | ");
sbResult.append(getCookiesStringRepresentation(cookies));
sbResult.append("]");
String strResult = sbResult.toString();
return strResult;
}
Returns a string representation of this HTTP state. |