Class ResponseCookie

Object
se.curity.identityserver.sdk.web.cookie.ResponseCookie
All Implemented Interfaces:
Cookie
Direct Known Subclasses:
ExpirableResponseCookie, StandardResponseCookie

public abstract class ResponseCookie extends Object implements Cookie
A HTTP Cookie that can be set on a Response.

Use the Response.cookies() method to obtain the cookies builder, then ResponseCookies.add(StandardResponseCookie) or ResponseCookies.add(StandardResponseCookie, ValueTransformation) to add ths cookie to the response.

Since:
2.1.0
See Also:
  • Method Details

    • setValue

      public void setValue(String value)
      Sets the value of the cookie.
      Parameters:
      value - the new value of the cookie
      Throws:
      NullPointerException - if the value is null
    • setComment

      public void setComment(@Nullable String comment)
      Sets a comment describing the purpose of this cookie.

      Notice that comments are not sent by the server to the HTTP client in the Set-Cookie header, hence should only be used to communicate intent internally.

      Parameters:
      comment - describing this cookie
    • setDomain

      public void setDomain(@Nullable String domain)
      Sets the domain name of this cookie.

      The name should be formatted according to RFC 2109.

      Parameters:
      domain - the domain to set this cookie on
    • setPath

      public void setPath(@Nullable String path)
      Sets the path under which this cookie is visible.
      Parameters:
      path - for this cookie
    • setVersion

      public void setVersion(int version)
      Sets the version of this cookie.

      Note: version 1 refers to RFC 2109, version 0 is the original Netscape specification).

      Parameters:
      version - the version of the cookie (e.g., 0 for the old Netscape version of cookies)
    • setHttpOnly

      public void setHttpOnly(boolean httpOnly)
      Sets whether this cookie is http-only.
      Parameters:
      httpOnly - true if this cookie is http-only, false otherwise
    • getName

      public String getName()
      Get the name of this cookie.
      Specified by:
      getName in interface Cookie
      Returns:
      the name of this cookie
    • getValue

      @Nullable public @Nullable String getValue()
      Get the value of this cookie. May be null.
      Specified by:
      getValue in interface Cookie
      Returns:
      the value of this cookie. May be null.
    • getPath

      @Nullable public @Nullable String getPath()
      Get the path this cookie should be set on.
      Returns:
      the path this cookie should be set on.
    • getComment

      @Nullable public @Nullable String getComment()
      Return the comment (if any) describing this cookie.
      Returns:
      a comment describing this cookie.
    • getDomain

      @Nullable public @Nullable String getDomain()
      Get the domain of this cookie. The default is for a cookie to be set on the domain of the request sent by the client.
      Returns:
      the domain this cookie is set on, or null if the default is used.
    • getVersion

      public int getVersion()
      Get the version of this cookie. See setVersion(int) for details.
      Returns:
      the version of this cookie.
    • isHttpOnly

      public boolean isHttpOnly()
      Answer whether this cookie is http-only. If a cookie is http-only, it cannot be accessed through client side scripting.
      Returns:
      whether this cookie is http-only.