public class Cookie extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Cookie.SameSite
Indicates the SameSite
value of the cookie.
|
Constructor and Description |
---|
Cookie()
Creates a new uninitialized cookie.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getComment()
Returns the intended use of a cookie.
|
String |
getCommentURL()
Returns the URL identifying the intended use of a cookie.
|
Boolean |
getDiscard()
Returns
true if the user agent should discard the cookie
unconditionally when it terminates. |
String |
getDomain()
Returns the domain for which the cookie is valid.
|
Date |
getExpires()
Returns the lifetime of the cookie, expressed as the date and time of
expiration.
|
Integer |
getMaxAge()
Returns the lifetime of the cookie, expressed in seconds.
|
String |
getName()
Returns name of the cookie.
|
String |
getPath()
Returns the subset of URLs on the origin server to which this cookie
applies.
|
List<Integer> |
getPort()
Returns the restricted list of port(s) to which a cookie may be returned.
|
Cookie.SameSite |
getSameSite()
Returns the value of the
SameSite attribute.
|
String |
getValue()
Returns the value of the cookie.
|
Integer |
getVersion()
Returns the version of the state management mechanism to which this
cookie conforms.
|
int |
hashCode() |
Boolean |
isHttpOnly()
Returns
true if the user agent should make the cookie
inaccessible to client side script. |
Boolean |
isSecure()
Returns
true if the user agent should use only secure means to
send back this cookie. |
Cookie |
setComment(String comment)
Sets the intended use of a cookie.
|
Cookie |
setCommentURL(String commentURL)
Sets the URL identifying the intended use of a cookie.
|
Cookie |
setDiscard(Boolean discard)
Sets the value indicating whether the user agent should discard the
cookie unconditionally when it terminates.
|
Cookie |
setDomain(String domain)
Sets the domain for which the cookie is valid.
|
Cookie |
setExpires(Date expires)
Sets the lifetime of the cookie, expressed as the date and time of
expiration.
|
Cookie |
setHttpOnly(Boolean httpOnly)
Sets the value indicating whether the user agent should make the cookie
inaccessible to client side script.
|
Cookie |
setMaxAge(Integer maxAge)
Sets the lifetime of the cookie, expressed in seconds.
|
Cookie |
setName(String name)
Sets the name of the cookie.
|
Cookie |
setPath(String path)
Sets the subset of URLs on the origin server to which this cookie
applies.
|
Cookie |
setPort(List<Integer> port)
Set the Port attribute as defined per RFC 2965 for
Set-Cookie2 . |
Cookie |
setSameSite(Cookie.SameSite sameSite)
Sets the value of the
SameSite attribute.
|
Cookie |
setSecure(Boolean secure)
Sets the value indicating whether the user agent should use only secure
means to send back this cookie.
|
Cookie |
setValue(String value)
Sets the value of the cookie.
|
Cookie |
setValueWasQuoted(boolean valueWasQuoted)
Sets the valueWasQuoted flag to indicate if the original cookie value was enclosed in "", used when recreating
the cookie header.
|
Cookie |
setVersion(Integer version)
Sets the version of the state management mechanism to which this cookie
conforms.
|
String |
toString() |
boolean |
valueWasQuoted()
Returns true if the cookie value was enclosed in "" when it was parsed, false otherwise.
|
public String getComment()
public String getCommentURL()
public Boolean getDiscard()
true
if the user agent should discard the cookie
unconditionally when it terminates.true
if the user agent should discard the cookie
unconditionally when it terminates.public String getDomain()
public Date getExpires()
public Boolean isHttpOnly()
true
if the user agent should make the cookie
inaccessible to client side script.true
if the user agent should make the cookie
inaccessible to client side script.public Integer getMaxAge()
public String getName()
public String getPath()
public List<Integer> getPort()
public Boolean isSecure()
true
if the user agent should use only secure means to
send back this cookie.true
if the user agent should use only secure means to
send back this cookie.public String getValue()
public Integer getVersion()
public boolean valueWasQuoted()
public Cookie.SameSite getSameSite()
null
if not set.public Cookie setComment(String comment)
comment
- The intended use of a cookie.public Cookie setCommentURL(String commentURL)
commentURL
- The URL identifying the intended use of a cookie.public Cookie setDiscard(Boolean discard)
discard
- true
if the user agent should discard the cookie
unconditionally when it terminates.public Cookie setDomain(String domain)
domain
- The domain for which the cookie is valid.public Cookie setExpires(Date expires)
expires
- The lifetime of the cookie, expressed as the date and time of
expiration.public Cookie setHttpOnly(Boolean httpOnly)
httpOnly
- true
if the user agent should make the cookie
inaccessible to client side script.public Cookie setMaxAge(Integer maxAge)
maxAge
- The lifetime of the cookie, expressed in seconds.public Cookie setName(String name)
name
- The name of the cookie.public Cookie setPath(String path)
path
- The subset of URLs on the origin server to which this cookie
applies.public Cookie setPort(List<Integer> port)
Set-Cookie2
.
The port attribute restricts the port to which a cookie may be returned
in a Cookie request header.port
- The list of port numbers.public Cookie setSecure(Boolean secure)
secure
- true
if the user agent should use only secure means to
send back this cookie.public Cookie setSameSite(Cookie.SameSite sameSite)
sameSite
- the samesite policy value.public Cookie setValue(String value)
value
- The value of the cookie.public Cookie setVersion(Integer version)
version
- The version of the state management mechanism to which this
cookie conforms.public Cookie setValueWasQuoted(boolean valueWasQuoted)
valueWasQuoted
- Set to true if the original cookie value was enclosed in quotes when the cookie was parsed, used
when recreating the cookie header.Copyright © 2010-2018, ForgeRock All Rights Reserved.