Class CookieSetting

java.lang.Object
org.restlet.data.Cookie
org.restlet.data.CookieSetting
All Implemented Interfaces:
NamedValue<String>

public final class CookieSetting extends Cookie
Cookie setting provided by a server. This allows a server side application to add, modify or remove a cookie on the client.

Note that when used with HTTP connectors, this class maps to the "Set-Cookie" and "Set-Cookie2" headers.
Author:
Jerome Louvel
See Also:
  • Constructor Details

    • CookieSetting

      public CookieSetting()
      Default constructor.
    • CookieSetting

      public CookieSetting(int version, String name, String value)
      Constructor.
      Parameters:
      version - The cookie's version.
      name - The cookie's name.
      value - The cookie's value.
    • CookieSetting

      public CookieSetting(int version, String name, String value, String path, String domain)
      Constructor.
      Parameters:
      version - The cookie's version.
      name - The cookie's name.
      value - The cookie's value.
      path - The cookie's path.
      domain - The cookie's domain name.
    • CookieSetting

      public CookieSetting(int version, String name, String value, String path, String domain, String comment, int maxAge, boolean secure)
      Constructor.
      Parameters:
      version - The cookie's version.
      name - The cookie's name.
      value - The cookie's value.
      path - The cookie's path.
      domain - The cookie's domain name.
      comment - The cookie's comment.
      maxAge - Sets the maximum age in seconds.
      Use 0 to immediately discard an existing cookie.
      Use -1 to discard the cookie at the end of the session (default).
      secure - Indicates if cookie should only be transmitted by secure means.
    • CookieSetting

      public CookieSetting(int version, String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean accessRestricted)
      Constructor.
      Parameters:
      version - The cookie's version.
      name - The cookie's name.
      value - The cookie's value.
      path - The cookie's path.
      domain - The cookie's domain name.
      comment - The cookie's comment.
      maxAge - Sets the maximum age in seconds.
      Use 0 to immediately discard an existing cookie.
      Use -1 to discard the cookie at the end of the session (default).
      secure - Indicates if cookie should only be transmitted by secure means.
      accessRestricted - Indicates whether to restrict cookie access to untrusted parties. Currently this toggles the non-standard but widely supported HttpOnly cookie parameter.
    • CookieSetting

      public CookieSetting(String name, String value)
      Preferred constructor.
      Parameters:
      name - The cookie's name.
      value - The cookie's value.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Cookie
    • getComment

      public String getComment()
      Returns the comment for the user.
      Returns:
      The comment for the user.
    • getDescription

      public String getDescription()
      Returns the description of this REST element.
      Returns:
      The description of this REST element.
    • getMaxAge

      public int getMaxAge()
      Returns the maximum age in seconds. Use 0 to immediately discard an existing cookie. Use -1 to discard the cookie at the end of the session (default).
      Returns:
      The maximum age in seconds.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Cookie
    • isAccessRestricted

      public boolean isAccessRestricted()
      Indicates if cookie access is restricted for untrusted parties. Currently this toggles the non-standard but widely supported HttpOnly cookie parameter.
      Returns:
      accessRestricted True if cookie access should be restricted
    • isSecure

      public boolean isSecure()
      Indicates if cookie should only be transmitted by secure means.
      Returns:
      True if cookie should only be transmitted by secure means.
    • setAccessRestricted

      public void setAccessRestricted(boolean accessRestricted)
      Indicates whether to restrict cookie access to untrusted parties. Currently this toggles the non-standard but widely supported HttpOnly cookie parameter.
      Parameters:
      accessRestricted - True if cookie access should be restricted
    • setComment

      public void setComment(String comment)
      Sets the comment for the user.
      Parameters:
      comment - The comment for the user.
    • setMaxAge

      public void setMaxAge(int maxAge)
      Sets the maximum age in seconds. Use 0 to immediately discard an existing cookie. Use -1 to discard the cookie at the end of the session (default).
      Parameters:
      maxAge - The maximum age in seconds.
    • setSecure

      public void setSecure(boolean secure)
      Indicates if cookie should only be transmitted by secure means.
      Parameters:
      secure - True if cookie should only be transmitted by secure means.
    • toString

      public String toString()
      Overrides:
      toString in class Cookie