Package org.eclipse.jetty.http
Class HttpCookie
java.lang.Object
org.eclipse.jetty.http.HttpCookie
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringString used in theCommentattribute ofHttpCookie, parsed withisHttpOnlyInComment(String), to support theHttpOnlyattribute.static final StringString used in theCommentattribute ofHttpCookie, parsed withisPartitionedInComment(String), to support thePartitionedattribute.static final StringName of context attribute with default SameSite cookie valuestatic final Stringstatic final Stringstatic 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) HttpCookie(String name, String value, String domain, String path, long maxAge, boolean httpOnly, boolean secure, String comment, int version, HttpCookie.SameSite sameSite, boolean partitioned) -
Method Summary
Modifier and TypeMethodDescriptionasString()static StringgetCommentWithAttributes(String comment, boolean httpOnly, HttpCookie.SameSite sameSite) static StringgetCommentWithAttributes(String comment, boolean httpOnly, HttpCookie.SameSite sameSite, boolean partitioned) static StringgetCommentWithoutAttributes(String comment) longgetName()getPath()static HttpCookie.SameSitegetSameSiteDefault(Attributes contextAttributes) Get the default value for SameSite cookie attribute, if one has been set for the given context.static HttpCookie.SameSitegetSameSiteFromComment(String comment) getSetCookie(CookieCompliance compliance) getValue()intbooleanisExpired(long timeNanos) booleanstatic booleanisHttpOnlyInComment(String comment) booleanstatic booleanisPartitionedInComment(String comment) booleanisSecure()
-
Field Details
-
HTTP_ONLY_COMMENT
String used in theCommentattribute ofHttpCookie, parsed withisHttpOnlyInComment(String), to support theHttpOnlyattribute.- See Also:
-
PARTITIONED_COMMENT
String used in theCommentattribute ofHttpCookie, parsed withisPartitionedInComment(String), to support thePartitionedattribute.- 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
-
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
-
isPartitioned
public boolean isPartitioned()- Returns:
- whether this cookie is partitioned
-
asString
- Returns:
- a string representation of this cookie
-
getSetCookie
-
getRFC2965SetCookie
-
getRFC6265SetCookie
-
isHttpOnlyInComment
-
isPartitionedInComment
-
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) -
getCommentWithAttributes
public static String getCommentWithAttributes(String comment, boolean httpOnly, HttpCookie.SameSite sameSite, boolean partitioned)
-