Class ResponseCookie
Object
se.curity.identityserver.sdk.web.cookie.ResponseCookie
- All Implemented Interfaces:
Cookie
- Direct Known Subclasses:
ExpirableResponseCookie,StandardResponseCookie
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 Summary
Modifier and TypeMethodDescriptionReturn the comment (if any) describing this cookie.Get the domain of this cookie.getName()Get the name of this cookie.getPath()Get the path this cookie should be set on.getValue()Get the value of this cookie.intGet the version of this cookie.booleanAnswer whether this cookie is http-only.voidsetComment(@Nullable String comment) Sets a comment describing the purpose of this cookie.voidSets the domain name of this cookie.voidsetHttpOnly(boolean httpOnly) Sets whether this cookie is http-only.voidSets the path under which this cookie is visible.voidSets the value of the cookie.voidsetVersion(int version) Sets the version of this cookie.
-
Method Details
-
setValue
Sets the value of the cookie.- Parameters:
value- the new value of the cookie- Throws:
NullPointerException- if the value is null
-
setComment
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
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
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
Get the name of this cookie. -
getValue
Get the value of this cookie. May be null. -
getPath
Get the path this cookie should be set on.- Returns:
- the path this cookie should be set on.
-
getComment
Return the comment (if any) describing this cookie.- Returns:
- a comment describing this cookie.
-
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. SeesetVersion(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.
-