Class CookieSetting

  • All Implemented Interfaces:
    NamedValue<java.lang.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:
    Response.getCookieSettings()
    • Constructor Summary

      Constructors 
      Constructor Description
      CookieSetting()
      Default constructor.
      CookieSetting​(int version, java.lang.String name, java.lang.String value)
      Constructor.
      CookieSetting​(int version, java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)
      Constructor.
      CookieSetting​(int version, java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, java.lang.String comment, int maxAge, boolean secure)
      Constructor.
      CookieSetting​(int version, java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, java.lang.String comment, int maxAge, boolean secure, boolean accessRestricted)
      Constructor.
      CookieSetting​(java.lang.String name, java.lang.String value)
      Preferred constructor.
    • Constructor Detail

      • CookieSetting

        public CookieSetting()
        Default constructor.
      • CookieSetting

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

        public CookieSetting​(int version,
                             java.lang.String name,
                             java.lang.String value,
                             java.lang.String path,
                             java.lang.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,
                             java.lang.String name,
                             java.lang.String value,
                             java.lang.String path,
                             java.lang.String domain,
                             java.lang.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,
                             java.lang.String name,
                             java.lang.String value,
                             java.lang.String path,
                             java.lang.String domain,
                             java.lang.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​(java.lang.String name,
                             java.lang.String value)
        Preferred constructor.
        Parameters:
        name - The cookie's name.
        value - The cookie's value.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class Cookie
      • getComment

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

        public java.lang.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​(java.lang.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 java.lang.String toString()
        Overrides:
        toString in class Cookie