Package org.eclipse.jetty.server
Class HttpCookieUtils
java.lang.Object
org.eclipse.jetty.server.HttpCookieUtils
Utility methods for server-side HTTP cookie handling.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
AHttpField
that holds anHttpHeader.SET_COOKIE
as aHttpCookie
instance, delaying any value generation untilHttpCookieUtils.SetCookieHttpField.getValue()
is called. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of context attribute with default SameSite cookie value -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpCookie
checkSameSite
(HttpCookie cookie, Attributes attributes) Check that samesite is set on the cookie.static String
getRFC2965SetCookie
(HttpCookie httpCookie) static String
getRFC6265SetCookie
(HttpCookie httpCookie) static HttpCookie.SameSite
getSameSiteDefault
(Attributes contextAttributes) Get the default value for SameSite cookie attribute, if one has been set for the given context.static String
getSetCookie
(HttpCookie httpCookie, CookieCompliance compliance) 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.
-
Field Details
-
SAME_SITE_DEFAULT_ATTRIBUTE
Name of context attribute with default SameSite cookie value- See Also:
-
-
Method Details
-
checkSameSite
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
-
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
-
getSetCookie
-
getRFC2965SetCookie
-
getRFC6265SetCookie
-
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 name, domain, and path, match all match the HttpCookie, false otherwise
-