|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.core.httpclient.cookie.CookieSpecBase
com.microsoft.tfs.core.httpclient.cookie.RFC2965Spec
public class RFC2965Spec
RFC 2965 specific cookie management functions.
Field Summary | |
---|---|
static java.lang.String |
SET_COOKIE2_KEY
Cookie Response Header name for cookies processed by this spec. |
Fields inherited from class com.microsoft.tfs.core.httpclient.cookie.CookieSpecBase |
---|
LOG |
Fields inherited from interface com.microsoft.tfs.core.httpclient.cookie.CookieSpec |
---|
PATH_DELIM, PATH_DELIM_CHAR |
Constructor Summary | |
---|---|
RFC2965Spec()
Default constructor |
Method Summary | |
---|---|
boolean |
domainMatch(java.lang.String host,
java.lang.String domain)
Performs domain-match as defined by the RFC2965. |
protected CookieAttributeHandler |
findAttribHandler(java.lang.String name)
Finds an attribute handler CookieAttributeHandler for the given
attribute. |
java.lang.String |
formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header as defined in RFC 2965 |
java.lang.String |
formatCookies(Cookie[] cookies)
Create a RFC 2965 compliant "Cookie" header value containing all Cookie s suitable for sending in a
"Cookie" header |
protected CookieAttributeHandler |
getAttribHandler(java.lang.String name)
Gets attribute handler CookieAttributeHandler for the given
attribute. |
protected java.util.Iterator<CookieAttributeHandler> |
getAttribHandlerIterator()
|
int |
getVersion()
|
Header |
getVersionHeader()
|
boolean |
match(java.lang.String host,
int port,
java.lang.String path,
boolean secure,
Cookie cookie)
Return true if the cookie should be submitted with a request with given attributes, false otherwise. |
Cookie[] |
parse(java.lang.String host,
int port,
java.lang.String path,
boolean secure,
Header header)
Parses the Set-Cookie2 value into an array of Cookies. |
Cookie[] |
parse(java.lang.String host,
int port,
java.lang.String path,
boolean secure,
java.lang.String header)
Parses the Set-Cookie value into an array of Cookies. |
void |
parseAttribute(NameValuePair attribute,
Cookie cookie)
Parse RFC 2965 specific cookie attribute and update the corresponsing Cookie properties. |
protected void |
registerAttribHandler(java.lang.String name,
CookieAttributeHandler handler)
|
void |
validate(java.lang.String host,
int port,
java.lang.String path,
boolean secure,
Cookie cookie)
Performs RFC 2965 compliant Cookie
validation |
Methods inherited from class com.microsoft.tfs.core.httpclient.cookie.CookieSpecBase |
---|
formatCookieHeader, formatCookieHeader, getValidDateFormats, match, parse, parse, pathMatch, setValidDateFormats |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SET_COOKIE2_KEY
"set-cookie2"
Constructor Detail |
---|
public RFC2965Spec()
Method Detail |
---|
protected void registerAttribHandler(java.lang.String name, CookieAttributeHandler handler)
protected CookieAttributeHandler findAttribHandler(java.lang.String name)
CookieAttributeHandler
for the given
attribute. Returns null if no attribute handler is found for the
specified attribute.
name
- attribute name. e.g. Domain, Path, etc.
protected CookieAttributeHandler getAttribHandler(java.lang.String name)
CookieAttributeHandler
for the given
attribute.
name
- attribute name. e.g. Domain, Path, etc.
java.lang.IllegalStateException
- if handler not found for the specified attribute.protected java.util.Iterator<CookieAttributeHandler> getAttribHandlerIterator()
public Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, Header header) throws MalformedCookieException
The syntax for the Set-Cookie2 response header is:
set-cookie = "Set-Cookie2:" cookies cookies = 1#cookie cookie = NAME "=" VALUE * (";" cookie-av) NAME = attr VALUE = value cookie-av = "Comment" "=" value | "CommentURL" "=" <"> http_URL <"> | "Discard" | "Domain" "=" value | "Max-Age" "=" value | "Path" "=" value | "Port" [ "=" <"> portlist <"> ] | "Secure" | "Version" "=" 1*DIGIT portlist = 1#portnum portnum = 1*DIGIT
parse
in interface CookieSpec
parse
in class CookieSpecBase
host
- the host from which the Set-Cookie2 value was
receivedport
- the port from which the Set-Cookie2 value was
receivedpath
- the path from which the Set-Cookie2 value was
receivedsecure
- true when the Set-Cookie2 value was
received over secure conectionheader
- the Set-Cookie2 Header received from the server
CookieSpec.validate(String, int, String, boolean, Cookie)
MalformedCookieException
- if an exception occurs during parsingpublic Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, java.lang.String header) throws MalformedCookieException
CookieSpecBase
The syntax for the Set-Cookie response header is:
set-cookie = "Set-Cookie:" cookies cookies = 1#cookie cookie = NAME "=" VALUE * (";" cookie-av) NAME = attr VALUE = value cookie-av = "Comment" "=" value | "Domain" "=" value | "Max-Age" "=" value | "Path" "=" value | "Secure" | "Version" "=" 1*DIGIT
parse
in interface CookieSpec
parse
in class CookieSpecBase
host
- the host from which the Set-Cookie value was receivedport
- the port from which the Set-Cookie value was receivedpath
- the path from which the Set-Cookie value was receivedsecure
- true when the Set-Cookie value was received over
secure conectionheader
- the Set-Cookie received from the server
parse(String, int, String, boolean,
com.microsoft.tfs.core.httpclient.Header)
MalformedCookieException
- if an exception occurs during parsingpublic void parseAttribute(NameValuePair attribute, Cookie cookie) throws MalformedCookieException
Cookie
properties.
parseAttribute
in interface CookieSpec
parseAttribute
in class CookieSpecBase
attribute
- NameValuePair
cookie
attribute from the Set-Cookie2 header.cookie
- Cookie
to be updated
MalformedCookieException
- if an exception occurs during parsingpublic void validate(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie) throws MalformedCookieException
Cookie
validation
validate
in interface CookieSpec
validate
in class CookieSpecBase
host
- the host from which the
Cookie
was receivedport
- the port from which the
Cookie
was receivedpath
- the path from which the
Cookie
was receivedsecure
- true when the
Cookie
was received using a
secure connectioncookie
- The cookie to validate
MalformedCookieException
- if an exception occurs during validationpublic boolean match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)
match
in interface CookieSpec
match
in class CookieSpecBase
host
- the host to which the request is being submittedport
- the port to which the request is being submitted (ignored)path
- the path to which the request is being submittedsecure
- true if the request is using a secure connectioncookie
- Cookie
to be matched
public java.lang.String formatCookie(Cookie cookie)
formatCookie
in interface CookieSpec
formatCookie
in class CookieSpecBase
cookie
- a Cookie
to be formatted as
string
public java.lang.String formatCookies(Cookie[] cookies)
Cookie
s suitable for sending in a
"Cookie" header
formatCookies
in interface CookieSpec
formatCookies
in class CookieSpecBase
cookies
- an array of Cookie
s to be
formatted
public boolean domainMatch(java.lang.String host, java.lang.String domain)
Host A's name domain-matches host B's if
domainMatch
in interface CookieSpec
domainMatch
in class CookieSpecBase
host
- host name where cookie is received from or being sent to.domain
- The cookie domain attribute.
public int getVersion()
getVersion
in interface CookieVersionSupport
public Header getVersionHeader()
getVersionHeader
in interface CookieVersionSupport
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |