Interface CookieSpec
- All Known Implementing Classes:
CookieSpecBase, IgnoreCookiesSpec, NetscapeDraftSpec, RFC2109Spec, RFC2965Spec
public interface CookieSpec
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
- Since:
- 2.0
- Author:
- Oleg Kalnichevski, Jeff Dever
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPath delimiterstatic final charPath delimiting charachter -
Method Summary
Modifier and TypeMethodDescriptionbooleandomainMatch(String host, String domain) Performs domain-match as defined by the cookie specification.formatCookie(Cookie cookie) Create a "Cookie" header value for an array of cookies.formatCookieHeader(Cookie cookie) Create a "Cookie" Header for single Cookie.formatCookieHeader(Cookie[] cookies) Create a "Cookie" Header for an array of Cookies.formatCookies(Cookie[] cookies) Create a "Cookie" header value for an array of cookies.Returns theCollectionof date patterns used for parsing.booleanDetermines if a Cookie matches a location.Cookie[]Determines which of an array of Cookies matches a location.Cookie[]Parse the "Set-Cookie" header value into Cookie array.Cookie[]Parse the "Set-Cookie" Header into an array of Cookies.voidparseAttribute(NameValuePair attribute, Cookie cookie) Parse the cookie attribute and update the corresponsing Cookie properties.booleanPerforms path-match as defined by the cookie specification.voidsetValidDateFormats(Collection datepatterns) Sets theCollectionof date patterns used for parsing.voidValidate the cookie according to validation rules defined by the cookie specification.
-
Field Details
-
PATH_DELIM
-
PATH_DELIM_CHAR
static final char PATH_DELIM_CHARPath delimiting charachter
-
-
Method Details
-
parse
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
Cookies- Parameters:
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- Returns:
- an array of Cookies parsed from the Set-Cookie value
- Throws:
MalformedCookieException- if an exception occurs during parsingIllegalArgumentException- if an input parameter is illegal- See Also:
-
parse
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
Cookies- Parameters:
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- Returns:
- an array of Cookies parsed from the header
- Throws:
MalformedCookieException- if an exception occurs during parsingIllegalArgumentException- if an input parameter is illegal- See Also:
-
parseAttribute
void parseAttribute(NameValuePair attribute, Cookie cookie) throws MalformedCookieException, IllegalArgumentException Parse the cookie attribute and update the corresponsing Cookie properties.- Parameters:
attribute- cookie attribute from the Set-Cookiecookie- the to be updated- Throws:
MalformedCookieException- if an exception occurs during parsingIllegalArgumentException- if an input parameter is illegal
-
validate
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.- Parameters:
host- the host from which theCookiewas receivedport- the port from which theCookiewas receivedpath- the path from which theCookiewas receivedsecure- true when theCookiewas received using a secure connectioncookie- the Cookie to validate- Throws:
MalformedCookieException- if the cookie is invalidIllegalArgumentException- if an input parameter is illegal
-
setValidDateFormats
Sets theCollectionof date patterns used for parsing. The String patterns must be compatible withSimpleDateFormat.- Parameters:
datepatterns- collection of date patterns
-
getValidDateFormats
Collection getValidDateFormats()Returns theCollectionof date patterns used for parsing. The String patterns are compatible with theSimpleDateFormat.- Returns:
- collection of date patterns
-
match
Determines if a Cookie matches a location.- Parameters:
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- Returns:
- true if the cookie should be submitted with a request with given attributes, false otherwise.
-
match
Determines which of an array of Cookies matches a location.- Parameters:
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 protocolcookies- an array of Cookies to be matched- Returns:
- true if the cookie should be submitted with a request with given attributes, false otherwise.
-
domainMatch
-
pathMatch
-
formatCookie
-
formatCookies
Create a "Cookie" header value for an array of cookies.- Parameters:
cookies- the Cookies to be formatted- Returns:
- a string suitable for sending in a Cookie header.
- Throws:
IllegalArgumentException- if an input parameter is illegal
-
formatCookieHeader
Create a "Cookie" Header for an array of Cookies.- Parameters:
cookies- the Cookies format into a Cookie header- Returns:
- a Header for the given Cookies.
- Throws:
IllegalArgumentException- if an input parameter is illegal
-
formatCookieHeader
Create a "Cookie" Header for single Cookie.- Parameters:
cookie- the Cookie format as a Cookie header- Returns:
- a Cookie header.
- Throws:
IllegalArgumentException- if an input parameter is illegal
-