Lines Matching refs:cookie

48  * An HttpCookie object represents an http cookie, which carries state
52 * <p>There are 3 http cookie specifications:
88 // The value of the cookie itself.
95 // Attributes encoded in the header's cookie fields.
98 private String comment; // Comment=VALUE ... describes cookie's use
99 private String commentURL; // CommentURL="http URL" ... describes cookie's use
100 private boolean toDiscard; // Discard ... discard cookie unconditionally
101 private String domain; // Domain=VALUE ... domain that sees cookie
103 private String path; // Path=VALUE ... URLs that see the cookie
104 private String portlist; // Port[="portlist"] ... the port cookie may be returned to
110 * The original header this cookie was consructed from, if it was
118 // Hold the creation time (in seconds) of the http cookie for later
132 // date formats used by Netscape's cookie draft
145 // constant strings represent set-cookie header token
147 private final static String SET_COOKIE = "set-cookie:";
154 * Constructs a cookie with a specified name and value.
158 * semicolons, or white space or begin with a $ character. The cookie's
162 * value is probably of interest only to the server. The cookie's
167 * cookie specification. The version can be changed with the
171 * @param name a <code>String</code> specifying the name of the cookie
173 * @param value a <code>String</code> specifying the value of the cookie
175 * @throws IllegalArgumentException if the cookie name contains illegal characters
177 * by the cookie protocol
191 throw new IllegalArgumentException("Illegal cookie name");
206 * Constructs cookies from set-cookie or set-cookie2 header string.
208 * may contain more than one cookie definitions, so this is a static
211 * @param header a <tt>String</tt> specifying the set-cookie header.
212 * The header should start with "set-cookie", or "set-cookie2"
214 * @return a List of cookie parsed from header line string
215 * @throws IllegalArgumentException if header string violates the cookie
216 * specification's syntax, or the cookie
218 * the cookie name is one of the tokens
219 * reserved for use by the cookie protocol
227 // create the cookie, in the cookie itself. This can be useful for filtering
236 // if header start with set-cookie or set-cookie2, strip it off
245 // The Netscape cookie may have a comma in its expires attribute,
246 // while the comma is the delimiter in rfc 2965/2109 cookie header string.
249 // Netscape draft cookie
250 HttpCookie cookie = parseInternal(header, retainHeader);
251 cookie.setVersion(0);
252 cookies.add(cookie);
254 // rfc2965/2109 cookie
255 // if header string contains more than one cookie,
259 HttpCookie cookie = parseInternal(cookieStr, retainHeader);
260 cookie.setVersion(1);
261 cookies.add(cookie);
275 * Reports whether this http cookie has expired or not.
277 * @return <tt>true</tt> to indicate this http cookie has expired;
283 // if not specify max-age, this cookie should be
297 * Specifies a comment that describes a cookie's purpose.
298 * The comment is useful if the browser presents the cookie
317 * Returns the comment describing the purpose of this cookie, or
318 * <code>null</code> if the cookie has no comment.
334 * Specifies a comment url that describes a cookie's purpose.
335 * The comment url is useful if the browser presents the cookie
353 * Returns the comment url describing the purpose of this cookie, or
354 * <code>null</code> if the cookie has no comment url.
369 * Specify whether user agent should discard the cookie unconditionally.
372 * @param discard <tt>true</tt> indicates to discard cookie unconditionally
385 * Return the discard attribute of the cookie
387 * @return a <tt>boolean</tt> to represent this cookie's discard attribute
398 * Specify the portlist of the cookie, which restricts the port(s)
399 * to which a cookie may be sent back in a Cookie header.
414 * Return the port list attribute of the cookie
427 * Specifies the domain within which this cookie should be presented.
431 * the cookie is visible to servers in a specified Domain Name System
438 * within which this cookie is visible;
457 * Returns the domain name set for this cookie. The form of
472 * Sets the maximum age of the cookie in seconds.
474 * <p>A positive value indicates that the cookie will expire
476 * the <i>maximum</i> age when the cookie will expire, not the cookie's
480 * that the cookie is not stored persistently and will be deleted
481 * when the Web browser exits. A zero value causes the cookie
485 * cookie in seconds; if zero, the cookie
487 * otherwise, the cookie's max age is unspecified.
500 * Returns the maximum age of the cookie, specified in seconds.
501 * By default, <code>-1</code> indicating the cookie will persist
506 * cookie in seconds
521 * Specifies a path for the cookie
522 * to which the client should return the cookie.
524 * <p>The cookie is visible to all the pages in the directory
526 * A cookie's path must include the servlet that set the cookie,
527 * for example, <i>/catalog</i>, which makes the cookie
550 * to which the browser returns this cookie. The
551 * cookie is visible to all subpaths on the server.
570 * Indicates whether the cookie should only be sent using a secure protocol,
575 * @param flag If <code>true</code>, the cookie can only be sent over
591 * Returns <code>true</code> if sending this cookie should be
595 * @return <code>false</code> if the cookie can be sent over
611 * Returns the name of the cookie. The name cannot be changed after
614 * @return a <code>String</code> specifying the cookie's name
628 * Assigns a new value to a cookie after the cookie is created.
652 * Returns the value of the cookie.
654 * @return a <code>String</code> containing the cookie's
669 * Returns the version of the protocol this cookie complies
672 * cookie specification drafted by Netscape. Cookies provided
673 * by a browser use and identify the browser's cookie version.
676 * @return 0 if the cookie complies with the
678 * if the cookie complies with RFC 2965/2109
692 * Sets the version of the cookie protocol this cookie complies
693 * with. Version 0 complies with the original Netscape cookie
697 * @param v 0 if the cookie should comply with
699 * 1 if the cookie should comply with RFC 2965/2109
709 throw new IllegalArgumentException("cookie version should be 0 or 1");
716 * Returns {@code true} if this cookie contains the <i>HttpOnly</i>
717 * attribute. This means that the cookie should not be accessible to
720 * @return {@code true} if this cookie should be considered http only.
729 * Indicates whether the cookie should be considered HTTP Only. If set to
730 * {@code true} it means the cookie should not be accessible to scripting
733 * @param httpOnly if {@code true} make the cookie HTTP only, i.e.
746 * <p>This concept is described in the cookie specification.
843 * Constructs a cookie header string representation of this cookie,
844 * which is in the format defined by corresponding cookie specification,
847 * @return a string form of the cookie. The string has the defined format
878 // One http cookie equals to another cookie (RFC 2965 sec. 3.3.3) if:
889 * Return hash code of this http cookie. The result is the sum of
890 * hash code value of three significant components of this cookie:
899 * @return this http cookie's hash code
913 * @return a clone of this http cookie
966 * Parse header string to cookie object.
972 * @throws IllegalArgumentException if header string violates the cookie
978 HttpCookie cookie = null;
984 // it's cookie's name
992 cookie = new HttpCookie(name,
996 cookie = new HttpCookie(name,
1000 throw new IllegalArgumentException("Invalid cookie name-value pair");
1003 throw new IllegalArgumentException("Empty cookie header string");
1006 // remaining name-value pairs are cookie's attributes
1019 // assign attribute to cookie
1020 assignAttribute(cookie, name, value);
1023 return cookie;
1028 * assign cookie attribute value to attribute name;
1032 public void assign(HttpCookie cookie, String attrName, String attrValue);
1038 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1039 if (cookie.getComment() == null) cookie.setComment(attrValue);
1043 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1044 if (cookie.getCommentURL() == null) cookie.setCommentURL(attrValue);
1048 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1049 cookie.setDiscard(true);
1053 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1054 if (cookie.getDomain() == null) cookie.setDomain(attrValue);
1058 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1061 if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) cookie.setMaxAge(maxage);
1063 throw new IllegalArgumentException("Illegal cookie max-age attribute");
1068 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1069 if (cookie.getPath() == null) cookie.setPath(attrValue);
1073 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1074 if (cookie.getPortlist() == null) cookie.setPortlist(attrValue == null ? "" : attrValue);
1078 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1079 cookie.setSecure(true);
1083 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1084 cookie.setHttpOnly(true);
1088 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1091 cookie.setVersion(version);
1098 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1099 if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) {
1100 cookie.setMaxAge(cookie.expiryDate2DeltaSeconds(attrValue));
1105 private static void assignAttribute(HttpCookie cookie,
1114 assignor.assign(cookie, attrName, attrValue);
1121 * Returns the original header this cookie was consructed from, if it was
1129 * Constructs a string representation of this cookie. The string format is
1141 * Constructs a string representation of this cookie. The string format is
1162 * defined in Netscape cookie spec
1164 * @return delta seconds between this cookie's creation
1200 * try to guess the cookie version through set-cookie header string
1207 // only netscape cookie using 'expires'
1210 // version is mandatory for rfc 2965/2109 cookie
1216 // only rfc 2965 cookie starts with 'set-cookie2'
1255 * Split cookie header string according to rfc 2965:
1260 * @param header the cookie header string to split