com.microsoft.tfs.core.httpclient
Class HttpState

java.lang.Object
  extended by com.microsoft.tfs.core.httpclient.HttpState

public class HttpState
extends java.lang.Object

A container for HTTP attributes that may persist from request to request, such as cookies and authentication credentials.


Field Summary
protected  java.util.ArrayList<Cookie> cookies
          Array of cookies that this HTTP state contains.
protected  java.util.HashMap<AuthScope,Credentials> credMap
          Map of credentials by realm that this HTTP state contains.
protected  java.util.HashMap<AuthScope,Credentials> proxyCred
          Map of proxy credentials by realm that this HTTP state contains
 
Constructor Summary
HttpState()
          Default constructor.
 
Method Summary
 void addCookie(Cookie cookie)
          Adds an HTTP cookie, replacing any existing equivalent cookies.
 void addCookies(Cookie[] cookies)
          Adds an array of HTTP cookies.
 void clear()
          Clears the state information (all cookies, credentials and proxy credentials).
 void clearCookies()
          Clears all cookies.
 void clearCredentials()
          Clears all credentials.
 void clearProxyCredentials()
          Clears all proxy credentials.
 Cookie[] getCookies()
          Returns an array of cookies that this HTTP state currently contains.
 Credentials getCredentials(AuthScope authscope)
          Get the credentials for the given authentication scope.
 Credentials getProxyCredentials(AuthScope authscope)
          Get the proxy credentials for the given authentication scope.
 boolean purgeExpiredCookies()
          Removes all of cookies in this HTTP state that have expired according to the current system time.
 boolean purgeExpiredCookies(java.util.Date date)
          Removes all of cookies in this HTTP state that have expired by the specified date.
 void setCredentials(AuthScope authscope, Credentials credentials)
          Sets the credentials for the given authentication scope.
 void setProxyCredentials(AuthScope authscope, Credentials credentials)
          Sets the proxy credentials for the given authentication realm.
 java.lang.String toString()
          Returns a string representation of this HTTP state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

credMap

protected java.util.HashMap<AuthScope,Credentials> credMap
Map of credentials by realm that this HTTP state contains.


proxyCred

protected java.util.HashMap<AuthScope,Credentials> proxyCred
Map of proxy credentials by realm that this HTTP state contains


cookies

protected java.util.ArrayList<Cookie> cookies
Array of cookies that this HTTP state contains.

Constructor Detail

HttpState

public HttpState()
Default constructor.

Method Detail

addCookie

public void addCookie(Cookie 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.

Parameters:
cookie - the cookie to be added
See Also:
addCookies(Cookie[])

addCookies

public void addCookies(Cookie[] cookies)
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.

Parameters:
cookies - the cookies to be added
See Also:
addCookie(Cookie)

getCookies

public Cookie[] getCookies()
Returns an array of cookies that this HTTP state currently contains.

Returns:
an array of cookies.
See Also:
#getCookies(String, int, String, boolean)

purgeExpiredCookies

public boolean purgeExpiredCookies()
Removes all of cookies in this HTTP state that have expired according to the current system time.

See Also:
purgeExpiredCookies(java.util.Date)

purgeExpiredCookies

public boolean purgeExpiredCookies(java.util.Date date)
Removes all of cookies in this HTTP state that have expired by the specified date.

Parameters:
date - The date to compare against.
Returns:
true if any cookies were purged.
See Also:
Cookie.isExpired(java.util.Date), purgeExpiredCookies()

setCredentials

public void setCredentials(AuthScope authscope,
                           Credentials credentials)
Sets the credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
authscope - the authentication scope
credentials - the authentication credentials for the given scope.
See Also:
getCredentials(AuthScope), setProxyCredentials(AuthScope, Credentials)
Since:
3.0

getCredentials

public Credentials getCredentials(AuthScope authscope)
Get the credentials for the given authentication scope.

Parameters:
authscope - the authentication scope
Returns:
the credentials
See Also:
setCredentials(AuthScope, Credentials)
Since:
3.0

setProxyCredentials

public void setProxyCredentials(AuthScope authscope,
                                Credentials credentials)
Sets the proxy credentials for the given authentication realm. Any previous credentials for the given realm will be overwritten.

Parameters:
authscope - the authentication scope
credentials - the authentication credentials for the given realm.
See Also:
getProxyCredentials(AuthScope), setCredentials(AuthScope, Credentials)
Since:
3.0

getProxyCredentials

public Credentials getProxyCredentials(AuthScope authscope)
Get the proxy credentials for the given authentication scope.

Parameters:
authscope - the authentication scope
Returns:
the credentials
See Also:
setProxyCredentials(AuthScope, Credentials)
Since:
3.0

toString

public java.lang.String toString()
Returns a string representation of this HTTP state.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the HTTP state.
See Also:
Object.toString()

clearCredentials

public void clearCredentials()
Clears all credentials.


clearProxyCredentials

public void clearProxyCredentials()
Clears all proxy credentials.


clearCookies

public void clearCookies()
Clears all cookies.


clear

public void clear()
Clears the state information (all cookies, credentials and proxy credentials).



© 2015 Microsoft. All rights reserved.