public class RFC2965Spec extends CookieSpecBase implements CookieVersionSupport
RFC 2965 specific cookie management functions.
| Modifier and Type | Field and Description |
|---|---|
static String |
SET_COOKIE2_KEY
Cookie Response Header name for cookies processed
by this spec.
|
LOGPATH_DELIM, PATH_DELIM_CHAR| Constructor and Description |
|---|
RFC2965Spec()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
domainMatch(String host,
String domain)
Performs domain-match as defined by the RFC2965.
|
protected CookieAttributeHandler |
findAttribHandler(String name)
Finds an attribute handler
CookieAttributeHandler for the
given attribute. |
String |
formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header as
defined in RFC 2965
|
String |
formatCookies(Cookie[] cookies)
Create a RFC 2965 compliant "Cookie" header value containing all
Cookies suitable for
sending in a "Cookie" header |
protected CookieAttributeHandler |
getAttribHandler(String name)
Gets attribute handler
CookieAttributeHandler for the
given attribute. |
protected Iterator |
getAttribHandlerIterator() |
int |
getVersion() |
Header |
getVersionHeader() |
boolean |
match(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Return true if the cookie should be submitted with a request
with given attributes, false otherwise.
|
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
Header header)
Parses the Set-Cookie2 value into an array of Cookies.
|
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
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(String name,
CookieAttributeHandler handler) |
void |
validate(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Performs RFC 2965 compliant
Cookie validation |
formatCookieHeader, formatCookieHeader, getValidDateFormats, match, pathMatch, setValidDateFormatspublic static final String SET_COOKIE2_KEY
protected void registerAttribHandler(String name, CookieAttributeHandler handler)
protected CookieAttributeHandler findAttribHandler(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(String name)
CookieAttributeHandler for the
given attribute.name - attribute name. e.g. Domain, Path, etc.IllegalStateException - if handler not found for the
specified attribute.protected Iterator getAttribHandlerIterator()
public Cookie[] parse(String host, int port, 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 CookieSpecparse in class CookieSpecBasehost - 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 serverMalformedCookieException - if an exception occurs during parsingCookieSpec.validate(String, int, String, boolean, Cookie)public Cookie[] parse(String host, int port, String path, boolean secure, String header) throws MalformedCookieException
CookieSpecBaseThe 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 CookieSpecparse in class CookieSpecBasehost - 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 serverMalformedCookieException - if an exception occurs during parsingparse(String, int, String, boolean, edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.Header)public void parseAttribute(NameValuePair attribute, Cookie cookie) throws MalformedCookieException
Cookie properties.parseAttribute in interface CookieSpecparseAttribute in class CookieSpecBaseattribute - NameValuePair cookie attribute from the
Set-Cookie2 header.cookie - Cookie to be updatedMalformedCookieException - if an exception occurs during parsingpublic void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException
Cookie validationvalidate in interface CookieSpecvalidate in class CookieSpecBasehost - 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 validateMalformedCookieException - if an exception occurs during
validationpublic boolean match(String host, int port, String path, boolean secure, Cookie cookie)
match in interface CookieSpecmatch in class CookieSpecBasehost - 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 matchedpublic String formatCookie(Cookie cookie)
formatCookie in interface CookieSpecformatCookie in class CookieSpecBasecookie - a Cookie to be formatted as stringpublic String formatCookies(Cookie[] cookies)
Cookies suitable for
sending in a "Cookie" headerformatCookies in interface CookieSpecformatCookies in class CookieSpecBasecookies - an array of Cookies to be formattedpublic boolean domainMatch(String host, String domain)
Host A's name domain-matches host B's if
domainMatch in interface CookieSpecdomainMatch in class CookieSpecBasehost - host name where cookie is received from or being sent to.domain - The cookie domain attribute.public int getVersion()
getVersion in interface CookieVersionSupportpublic Header getVersionHeader()
getVersionHeader in interface CookieVersionSupportCopyright © 2020 Internet2. All rights reserved.