Defines the cookie management specification.
Cookie management specification must define
- rules of parsing "Set-Cookie" header
- rules of validation of parsed cookies
- formatting of "Cookie" header
for a given host, port and path of origin
domainMatch
public boolean domainMatch(String host,
String domain)
Performs domain-match as defined by the cookie specification.
host
- The target host.domain
- The cookie domain attribute.
- true if the specified host matches the given domain.
formatCookie
public String formatCookie(Cookie cookie)
Create a "Cookie" header value for an array of cookies.
cookie
- the cookie to be formatted as string
- a string suitable for sending in a "Cookie" header.
formatCookieHeader
public Header formatCookieHeader(Cookie cookie)
throws IllegalArgumentException
Create a "Cookie" Header for single Cookie.
cookie
- the Cookie format as a Cookie header
formatCookieHeader
public Header formatCookieHeader(Cookie[] cookies)
throws IllegalArgumentException
Create a "Cookie" Header for an array of Cookies.
cookies
- the Cookies format into a Cookie header
- a Header for the given Cookies.
formatCookies
public String formatCookies(Cookie[] cookies)
throws IllegalArgumentException
Create a "Cookie" header value for an array of cookies.
cookies
- the Cookies to be formatted
- a string suitable for sending in a Cookie header.
getValidDateFormats
public Collection getValidDateFormats()
Returns the Collection
of date patterns used for parsing. The String patterns are compatible
with the java.text.SimpleDateFormat
.
- collection of date patterns
match
public Cookie[] match(String host,
int port,
String path,
boolean secure,
cookies[] )
Determines which of an array of Cookies matches a location.
host
- the host to which the request is being submittedport
- the port to which the request is being submitted
(currenlty ignored)path
- the path to which the request is being submittedsecure
- true if the request is using a secure protocol
- true if the cookie should be submitted with a request
with given attributes, false otherwise.
match
public boolean match(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Determines if a Cookie matches a location.
host
- the host to which the request is being submittedport
- the port to which the request is being submittedpath
- the path to which the request is being submittedsecure
- true if the request is using a secure connectioncookie
- the Cookie to be matched
- true if the cookie should be submitted with a request
with given attributes, false otherwise.
parse
public Cookie[] parse(String host,
int port,
String path,
boolean secure,
String header)
throws MalformedCookieException,
IllegalArgumentException
Parse the
"Set-Cookie" header value into Cookie array.
This method will not perform the validation of the resultant
Cookie
s
host
- the host which sent the Set-Cookie headerport
- the port which sent the Set-Cookie headerpath
- the path which sent the Set-Cookie headersecure
- true when the Set-Cookie header
was received over secure conectionheader
- the Set-Cookie received from the server
- an array of Cookies parsed from the Set-Cookie value
parse
public Cookie[] parse(String host,
int port,
String path,
boolean secure,
Header header)
throws MalformedCookieException,
IllegalArgumentException
Parse the
"Set-Cookie" Header into an array of Cookies.
This method will not perform the validation of the resultant
Cookie
s
host
- the host which sent the Set-Cookie headerport
- the port which sent the Set-Cookie headerpath
- the path which sent the Set-Cookie headersecure
- true when the Set-Cookie header
was received over secure conectionheader
- the Set-Cookie received from the server
- an array of Cookies parsed from the header
parseAttribute
public void parseAttribute(NameValuePair attribute,
Cookie cookie)
throws MalformedCookieException,
IllegalArgumentException
Parse the cookie attribute and update the corresponsing Cookie
properties.
attribute
- cookie attribute from the Set-Cookiecookie
- the to be updated
pathMatch
public boolean pathMatch(String path,
String topmostPath)
Performs path-match as defined by the cookie specification.
path
- The target path.topmostPath
- The cookie path attribute.
setValidDateFormats
public void setValidDateFormats(Collection datepatterns)
Sets the Collection
of date patterns used for parsing. The String patterns must be
compatible with java.text.SimpleDateFormat
.
datepatterns
- collection of date patterns
validate
public void validate(String host,
int port,
String path,
boolean secure,
Cookie cookie)
throws MalformedCookieException,
IllegalArgumentException
Validate the cookie according to validation rules defined by the
cookie specification.
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