Package org.eclipse.jetty.http
Class HttpCookie
java.lang.Object
org.eclipse.jetty.http.HttpCookie
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final String
private final String
private final long
private final boolean
private final long
private final String
private final String
private final HttpCookie.SameSite
private final boolean
private final String
private final int
static final String
If this string is found within the comment parsed withisHttpOnlyInComment(String)
the check will return trueprivate static final Logger
private static final String
These strings are used bygetSameSiteFromComment(String)
to check for a SameSite specifier in the commentstatic final String
Name of context attribute with default SameSite cookie valuestatic final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionHttpCookie
(String setCookie) HttpCookie
(String name, String value) HttpCookie
(String name, String value, long maxAge) HttpCookie
(String name, String value, String domain, String path) HttpCookie
(String name, String value, String domain, String path, long maxAge, boolean httpOnly, boolean secure) HttpCookie
(String name, String value, String domain, String path, long maxAge, boolean httpOnly, boolean secure, String comment, int version) HttpCookie
(String name, String value, String domain, String path, long maxAge, boolean httpOnly, boolean secure, String comment, int version, HttpCookie.SameSite sameSite) -
Method Summary
Modifier and TypeMethodDescriptionasString()
static String
getCommentWithAttributes
(String comment, boolean httpOnly, HttpCookie.SameSite sameSite) static String
getCommentWithoutAttributes
(String comment) long
getName()
getPath()
static HttpCookie.SameSite
getSameSiteDefault
(javax.servlet.ServletContext context) Get the default value for SameSite cookie attribute, if one has been set for the given context.static HttpCookie.SameSite
getSameSiteFromComment
(String comment) getSetCookie
(CookieCompliance compliance) getValue()
int
boolean
isExpired
(long timeNanos) boolean
static boolean
isHttpOnlyInComment
(String comment) private static boolean
Does a cookie value need to be quoted?boolean
isSecure()
private static void
quoteOnlyOrAppend
(StringBuilder buf, String s, boolean quote)
-
Field Details
-
LOG
-
__COOKIE_DELIM
- See Also:
-
__01Jan1970_COOKIE
-
HTTP_ONLY_COMMENT
If this string is found within the comment parsed withisHttpOnlyInComment(String)
the check will return true- See Also:
-
SAME_SITE_COMMENT
These strings are used bygetSameSiteFromComment(String)
to check for a SameSite specifier in the comment- See Also:
-
SAME_SITE_NONE_COMMENT
- See Also:
-
SAME_SITE_LAX_COMMENT
- See Also:
-
SAME_SITE_STRICT_COMMENT
- See Also:
-
SAME_SITE_DEFAULT_ATTRIBUTE
Name of context attribute with default SameSite cookie value- See Also:
-
_name
-
_value
-
_comment
-
_domain
-
_maxAge
private final long _maxAge -
_path
-
_secure
private final boolean _secure -
_version
private final int _version -
_httpOnly
private final boolean _httpOnly -
_expiration
private final long _expiration -
_sameSite
-
-
Constructor Details
-
HttpCookie
-
HttpCookie
-
HttpCookie
-
HttpCookie
-
HttpCookie
-
HttpCookie
-
HttpCookie
-
-
Method Details
-
getName
- Returns:
- the cookie name
-
getValue
- Returns:
- the cookie value
-
getComment
- Returns:
- the cookie comment
-
getDomain
- Returns:
- the cookie domain
-
getMaxAge
public long getMaxAge()- Returns:
- the cookie max age in seconds
-
getPath
- Returns:
- the cookie path
-
isSecure
public boolean isSecure()- Returns:
- whether the cookie is valid for secure domains
-
getVersion
public int getVersion()- Returns:
- the cookie version
-
getSameSite
- Returns:
- the cookie SameSite enum attribute
-
isHttpOnly
public boolean isHttpOnly()- Returns:
- whether the cookie is valid for the http protocol only
-
isExpired
public boolean isExpired(long timeNanos) - Parameters:
timeNanos
- the time to check for cookie expiration, in nanoseconds- Returns:
- whether the cookie is expired by the given time
-
asString
- Returns:
- a string representation of this cookie
-
quoteOnlyOrAppend
-
isQuoteNeededForCookie
Does a cookie value need to be quoted?- Parameters:
s
- value string- Returns:
- true if quoted;
- Throws:
IllegalArgumentException
- If there a control characters in the string
-
getSetCookie
-
getRFC2965SetCookie
-
getRFC6265SetCookie
-
isHttpOnlyInComment
-
getSameSiteFromComment
-
getSameSiteDefault
Get the default value for SameSite cookie attribute, if one has been set for the given context.- Parameters:
context
- the context to check for default SameSite value- Returns:
- the default SameSite value or null if one does not exist
- Throws:
IllegalStateException
- if the default value is not a permitted value
-
getCommentWithoutAttributes
-
getCommentWithAttributes
public static String getCommentWithAttributes(String comment, boolean httpOnly, HttpCookie.SameSite sameSite)
-