Interface CookieSameSiteSupplier
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy interface that can be used with
ConfigurableServletWebServerFactory
implementations in order to supply custom Cookie.SameSite
values for specific
cookies
.
Basic CookieSameSiteSupplier implementations can be constructed using the of...
factory methods, typically combined with name matching. For example:
CookieSameSiteSupplier.ofLax().whenHasName("mycookie");
- Since:
- 2.6.0
- Author:
- Phillip Webb
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetSameSite
(Cookie cookie) Get theCookie.SameSite
values that should be used for the givenCookie
.static CookieSameSiteSupplier
of
(Cookie.SameSite sameSite) Return a newCookieSameSiteSupplier
that always returns the givenCookie.SameSite
value.static CookieSameSiteSupplier
ofLax()
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.LAX
.static CookieSameSiteSupplier
ofNone()
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.NONE
.static CookieSameSiteSupplier
ofStrict()
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.STRICT
.default CookieSameSiteSupplier
Limit this supplier so that it's only called if the predicate accepts the Cookie.default CookieSameSiteSupplier
whenHasName
(String name) Limit this supplier so that it's only called if the Cookie has the given name.default CookieSameSiteSupplier
whenHasName
(Supplier<String> nameSupplier) Limit this supplier so that it's only called if the Cookie has the given name.default CookieSameSiteSupplier
whenHasNameMatching
(String regex) Limit this supplier so that it's only called if the Cookie name matches the given regex.default CookieSameSiteSupplier
whenHasNameMatching
(Pattern pattern) Limit this supplier so that it's only called if the Cookie name matches the givenPattern
.
-
Method Details
-
getSameSite
Get theCookie.SameSite
values that should be used for the givenCookie
.- Parameters:
cookie
- the cookie to check- Returns:
- the
Cookie.SameSite
value to use ornull
if the next supplier should be checked
-
whenHasName
Limit this supplier so that it's only called if the Cookie has the given name.- Parameters:
name
- the name to check- Returns:
- a new
CookieSameSiteSupplier
that only calls this supplier when the name matches
-
whenHasName
Limit this supplier so that it's only called if the Cookie has the given name.- Parameters:
nameSupplier
- a supplier providing the name to check- Returns:
- a new
CookieSameSiteSupplier
that only calls this supplier when the name matches
-
whenHasNameMatching
Limit this supplier so that it's only called if the Cookie name matches the given regex.- Parameters:
regex
- the regex pattern that must match- Returns:
- a new
CookieSameSiteSupplier
that only calls this supplier when the name matches the regex
-
whenHasNameMatching
Limit this supplier so that it's only called if the Cookie name matches the givenPattern
.- Parameters:
pattern
- the regex pattern that must match- Returns:
- a new
CookieSameSiteSupplier
that only calls this supplier when the name matches the pattern
-
when
Limit this supplier so that it's only called if the predicate accepts the Cookie.- Parameters:
predicate
- the predicate used to match the cookie- Returns:
- a new
CookieSameSiteSupplier
that only calls this supplier when the cookie matches the predicate
-
ofNone
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.NONE
.- Returns:
- the supplier instance
-
ofLax
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.LAX
.- Returns:
- the supplier instance
-
ofStrict
Return a newCookieSameSiteSupplier
that always returnsCookie.SameSite.STRICT
.- Returns:
- the supplier instance
-
of
Return a newCookieSameSiteSupplier
that always returns the givenCookie.SameSite
value.- Parameters:
sameSite
- the value to return- Returns:
- the supplier instance
-