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 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, Map<String, String> attributes) 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 HttpCookie
checkSameSite
(HttpCookie cookie, org.eclipse.jetty.util.Attributes attributes) Check that samesite is set on the cookie.extractBasics
(String setCookieHeader) Extract the bare minimum of info from a Set-Cookie header string.static String
getCommentWithAttributes
(String comment, boolean httpOnly, HttpCookie.SameSite sameSite) Deprecated.We should not need to do this nowstatic String
getCommentWithoutAttributes
(String comment) Deprecated.We should not need to do this nowlong
getName()
getPath()
static HttpCookie.SameSite
getSameSiteDefault
(org.eclipse.jetty.util.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()
static boolean
Check if the Set-Cookie header represented as a string is for the name, domain and path given.static boolean
match
(HttpCookie cookie, String name, String domain, String path) Check if the HttpCookie is for the given name, domain and path.toString()
-
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
-
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
-
toString
-
getSetCookie
-
getRFC2965SetCookie
-
getRFC6265SetCookie
-
isHttpOnlyInComment
-
getSameSiteFromComment
-
getSameSiteDefault
public static HttpCookie.SameSite getSameSiteDefault(org.eclipse.jetty.util.Attributes contextAttributes) 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
-
extractBasics
Extract the bare minimum of info from a Set-Cookie header string. Ideally this method should not be necessary, however as java.net.HttpCookie does not yet support generic attributes, we have to use it in a minimal fashion. When it supports attributes, we could look at reverting to a constructor on o.e.j.h.HttpCookie to take the set-cookie header string.- Parameters:
setCookieHeader
- the header as a string- Returns:
- a map containing the name, value, domain, path. max-age of the set cookie header
-
match
Check if the Set-Cookie header represented as a string is for the name, domain and path given.- Parameters:
setCookieHeader
- a Set-Cookie headername
- the cookie name to checkdomain
- the cookie domain to checkpath
- the cookie path to check- Returns:
- true if all of the name, domain and path match the Set-Cookie header, false otherwise
-
match
Check if the HttpCookie is for the given name, domain and path.- Parameters:
cookie
- the jetty HttpCookie to checkname
- the cookie name to checkdomain
- the cookie domain to checkpath
- the cookie path to check- Returns:
- true if all of the name, domain and path all match the HttpCookie, false otherwise
-
getCommentWithoutAttributes
Deprecated.We should not need to do this now -
getCommentWithAttributes
@Deprecated public static String getCommentWithAttributes(String comment, boolean httpOnly, HttpCookie.SameSite sameSite) Deprecated.We should not need to do this now -
checkSameSite
public static HttpCookie checkSameSite(HttpCookie cookie, org.eclipse.jetty.util.Attributes attributes) Check that samesite is set on the cookie. If not, use a context default value, if one has been set.- Parameters:
cookie
- the cookie to checkattributes
- the context to check settings- Returns:
- either the original cookie, or a new one that has the samesit default set
-