Lines Matching refs:cookie

42  * An HttpCookie object represents an http cookie, which carries state
46 * <p>There are 3 http cookie specifications:
64 // The value of the cookie itself.
71 // Attributes encoded in the header's cookie fields.
74 private String comment; // Comment=VALUE ... describes cookie's use
75 private String commentURL; // CommentURL="http URL" ... describes cookie's use
76 private boolean toDiscard; // Discard ... discard cookie unconditionally
77 private String domain; // Domain=VALUE ... domain that sees cookie
79 private String path; // Path=VALUE ... URLs that see the cookie
80 private String portlist; // Port[="portlist"] ... the port cookie may be returned to
85 // The original header this cookie was consructed from, if it was
90 // Hold the creation time (in seconds) of the http cookie for later
104 // date formats used by Netscape's cookie draft
117 // constant strings represent set-cookie header token
119 private final static String SET_COOKIE = "set-cookie:";
126 * Constructs a cookie with a specified name and value.
130 * semicolons, or white space or begin with a $ character. The cookie's
134 * value is probably of interest only to the server. The cookie's
139 * cookie specification. The version can be changed with the
143 * @param name a <code>String</code> specifying the name of the cookie
145 * @param value a <code>String</code> specifying the value of the cookie
147 * @throws IllegalArgumentException if the cookie name contains illegal characters
149 * by the cookie protocol
163 throw new IllegalArgumentException("Illegal cookie name");
178 * Constructs cookies from set-cookie or set-cookie2 header string.
180 * may contain more than one cookie definitions, so this is a static
183 * @param header a <tt>String</tt> specifying the set-cookie header.
184 * The header should start with "set-cookie", or "set-cookie2"
186 * @return a List of cookie parsed from header line string
187 * @throws IllegalArgumentException if header string violates the cookie
188 * specification's syntax, or the cookie
190 * the cookie name is one of the tokens
191 * reserved for use by the cookie protocol
199 // create the cookie, in the cookie itself. This can be useful for filtering
206 // if header start with set-cookie or set-cookie2, strip it off
215 // The Netscape cookie may have a comma in its expires attribute,
216 // while the comma is the delimiter in rfc 2965/2109 cookie header string.
219 // Netscape draft cookie
220 HttpCookie cookie = parseInternal(header, retainHeader);
221 cookie.setVersion(0);
222 cookies.add(cookie);
224 // rfc2965/2109 cookie
225 // if header string contains more than one cookie,
229 HttpCookie cookie = parseInternal(cookieStr, retainHeader);
230 cookie.setVersion(1);
231 cookies.add(cookie);
245 * Reports whether this http cookie has expired or not.
247 * @return <tt>true</tt> to indicate this http cookie has expired;
253 // if not specify max-age, this cookie should be
267 * Specifies a comment that describes a cookie's purpose.
268 * The comment is useful if the browser presents the cookie
287 * Returns the comment describing the purpose of this cookie, or
288 * <code>null</code> if the cookie has no comment.
304 * Specifies a comment url that describes a cookie's purpose.
305 * The comment url is useful if the browser presents the cookie
323 * Returns the comment url describing the purpose of this cookie, or
324 * <code>null</code> if the cookie has no comment url.
339 * Specify whether user agent should discard the cookie unconditionally.
342 * @param discard <tt>true</tt> indicates to discard cookie unconditionally
355 * Return the discard attribute of the cookie
357 * @return a <tt>boolean</tt> to represent this cookie's discard attribute
368 * Specify the portlist of the cookie, which restricts the port(s)
369 * to which a cookie may be sent back in a Cookie header.
384 * Return the port list attribute of the cookie
397 * Specifies the domain within which this cookie should be presented.
401 * the cookie is visible to servers in a specified Domain Name System
408 * within which this cookie is visible;
427 * Returns the domain name set for this cookie. The form of
442 * Sets the maximum age of the cookie in seconds.
444 * <p>A positive value indicates that the cookie will expire
446 * the <i>maximum</i> age when the cookie will expire, not the cookie's
450 * that the cookie is not stored persistently and will be deleted
451 * when the Web browser exits. A zero value causes the cookie
455 * cookie in seconds; if zero, the cookie
457 * otherwise, the cookie's max age is unspecified.
470 * Returns the maximum age of the cookie, specified in seconds.
471 * By default, <code>-1</code> indicating the cookie will persist
476 * cookie in seconds
491 * Specifies a path for the cookie
492 * to which the client should return the cookie.
494 * <p>The cookie is visible to all the pages in the directory
496 * A cookie's path must include the servlet that set the cookie,
497 * for example, <i>/catalog</i>, which makes the cookie
520 * to which the browser returns this cookie. The
521 * cookie is visible to all subpaths on the server.
540 * Indicates whether the cookie should only be sent using a secure protocol,
545 * @param flag If <code>true</code>, the cookie can only be sent over
561 * Returns <code>true</code> if sending this cookie should be
565 * @return <code>false</code> if the cookie can be sent over
581 * Returns the name of the cookie. The name cannot be changed after
584 * @return a <code>String</code> specifying the cookie's name
598 * Assigns a new value to a cookie after the cookie is created.
622 * Returns the value of the cookie.
624 * @return a <code>String</code> containing the cookie's
639 * Returns the version of the protocol this cookie complies
642 * cookie specification drafted by Netscape. Cookies provided
643 * by a browser use and identify the browser's cookie version.
646 * @return 0 if the cookie complies with the
648 * if the cookie complies with RFC 2965/2109
662 * Sets the version of the cookie protocol this cookie complies
663 * with. Version 0 complies with the original Netscape cookie
667 * @param v 0 if the cookie should comply with
669 * 1 if the cookie should comply with RFC 2965/2109
679 throw new IllegalArgumentException("cookie version should be 0 or 1");
686 * Returns {@code true} if this cookie contains the <i>HttpOnly</i>
687 * attribute. This means that the cookie should not be accessible to
690 * @return {@code true} if this cookie should be considered http only.
699 * Indicates whether the cookie should be considered HTTP Only. If set to
700 * {@code true} it means the cookie should not be accessible to scripting
703 * @param httpOnly if {@code true} make the cookie HTTP only, i.e.
716 * <p>This concept is described in the cookie specification.
803 * Constructs a cookie header string representation of this cookie,
804 * which is in the format defined by corresponding cookie specification,
807 * @return a string form of the cookie. The string has the defined format
838 // One http cookie equals to another cookie (RFC 2965 sec. 3.3.3) if:
849 * Return hash code of this http cookie. The result is the sum of
850 * hash code value of three significant components of this cookie:
859 * @return this http cookie's hash code
873 * @return a clone of this http cookie
917 * Parse header string to cookie object.
923 * @throws IllegalArgumentException if header string violates the cookie
929 HttpCookie cookie = null;
935 // it's cookie's name
943 cookie = new HttpCookie(name,
947 cookie = new HttpCookie(name,
951 throw new IllegalArgumentException("Invalid cookie name-value pair");
954 throw new IllegalArgumentException("Empty cookie header string");
957 // remaining name-value pairs are cookie's attributes
970 // assign attribute to cookie
971 assignAttribute(cookie, name, value);
974 return cookie;
979 * assign cookie attribute value to attribute name;
983 public void assign(HttpCookie cookie, String attrName, String attrValue);
989 public void assign(HttpCookie cookie, String attrName, String attrValue) {
990 if (cookie.getComment() == null) cookie.setComment(attrValue);
994 public void assign(HttpCookie cookie, String attrName, String attrValue) {
995 if (cookie.getCommentURL() == null) cookie.setCommentURL(attrValue);
999 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1000 cookie.setDiscard(true);
1004 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1005 if (cookie.getDomain() == null) cookie.setDomain(attrValue);
1009 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1012 if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) cookie.setMaxAge(maxage);
1014 throw new IllegalArgumentException("Illegal cookie max-age attribute");
1019 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1020 if (cookie.getPath() == null) cookie.setPath(attrValue);
1024 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1025 if (cookie.getPortlist() == null) cookie.setPortlist(attrValue == null ? "" : attrValue);
1029 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1030 cookie.setSecure(true);
1034 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1035 cookie.setHttpOnly(true);
1039 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1042 cookie.setVersion(version);
1049 public void assign(HttpCookie cookie, String attrName, String attrValue) {
1050 if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) {
1051 cookie.setMaxAge(cookie.expiryDate2DeltaSeconds(attrValue));
1056 private static void assignAttribute(HttpCookie cookie,
1065 assignor.assign(cookie, attrName, attrValue);
1078 public String header(HttpCookie cookie) {
1079 return cookie.header;
1086 * Returns the original header this cookie was consructed from, if it was
1094 * Constructs a string representation of this cookie. The string format is
1106 * Constructs a string representation of this cookie. The string format is
1127 * defined in Netscape cookie spec
1129 * @return delta seconds between this cookie's creation
1165 * try to guess the cookie version through set-cookie header string
1172 // only netscape cookie using 'expires'
1175 // version is mandatory for rfc 2965/2109 cookie
1181 // only rfc 2965 cookie starts with 'set-cookie2'
1220 * Split cookie header string according to rfc 2965:
1225 * @param header the cookie header string to split