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 TypeFieldDescriptionstatic final String
If this string is found within the comment parsed withisHttpOnlyInComment(String)
the check will return truestatic 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
(Attributes contextAttributes) 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) boolean
isSecure()
-
Field Details
-
HTTP_ONLY_COMMENT
If this string is found within the comment parsed withisHttpOnlyInComment(String)
the check will return true- 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:
-
-
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
-
getSetCookie
-
getRFC2965SetCookie
-
getRFC6265SetCookie
-
isHttpOnlyInComment
-
getSameSiteFromComment
-
getSameSiteDefault
Get the default value for SameSite cookie attribute, if one has been set for the given context.- Parameters:
contextAttributes
- 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)
-