@FunctionalInterface public interface CookieSameSiteSupplier
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");
ConfigurableServletWebServerFactory.addCookieSameSiteSuppliers(CookieSameSiteSupplier...)
Modifier and Type | Method and Description |
---|---|
Cookie.SameSite |
getSameSite(Cookie cookie)
Get the
Cookie.SameSite values that should be used for the given Cookie . |
static CookieSameSiteSupplier |
of(Cookie.SameSite sameSite)
Return a new
CookieSameSiteSupplier that always returns the given
Cookie.SameSite value. |
static CookieSameSiteSupplier |
ofLax()
Return a new
CookieSameSiteSupplier that always returns
Cookie.SameSite.LAX . |
static CookieSameSiteSupplier |
ofNone()
Return a new
CookieSameSiteSupplier that always returns
Cookie.SameSite.NONE . |
static CookieSameSiteSupplier |
ofStrict()
Return a new
CookieSameSiteSupplier that always returns
Cookie.SameSite.STRICT . |
default CookieSameSiteSupplier |
when(Predicate<Cookie> predicate)
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(Pattern pattern)
Limit this supplier so that it's only called if the Cookie name matches the given
Pattern . |
default CookieSameSiteSupplier |
whenHasNameMatching(String regex)
Limit this supplier so that it's only called if the Cookie name matches the given
regex.
|
Cookie.SameSite getSameSite(Cookie cookie)
Cookie.SameSite
values that should be used for the given Cookie
.cookie
- the cookie to checkCookie.SameSite
value to use or null
if the next supplier
should be checkeddefault CookieSameSiteSupplier whenHasName(String name)
name
- the name to checkCookieSameSiteSupplier
that only calls this supplier when the
name matchesdefault CookieSameSiteSupplier whenHasName(Supplier<String> nameSupplier)
nameSupplier
- a supplier providing the name to checkCookieSameSiteSupplier
that only calls this supplier when the
name matchesdefault CookieSameSiteSupplier whenHasNameMatching(String regex)
regex
- the regex pattern that must matchCookieSameSiteSupplier
that only calls this supplier when the
name matches the regexdefault CookieSameSiteSupplier whenHasNameMatching(Pattern pattern)
Pattern
.pattern
- the regex pattern that must matchCookieSameSiteSupplier
that only calls this supplier when the
name matches the patterndefault CookieSameSiteSupplier when(Predicate<Cookie> predicate)
predicate
- the predicate used to match the cookieCookieSameSiteSupplier
that only calls this supplier when the
cookie matches the predicatestatic CookieSameSiteSupplier ofNone()
CookieSameSiteSupplier
that always returns
Cookie.SameSite.NONE
.static CookieSameSiteSupplier ofLax()
CookieSameSiteSupplier
that always returns
Cookie.SameSite.LAX
.static CookieSameSiteSupplier ofStrict()
CookieSameSiteSupplier
that always returns
Cookie.SameSite.STRICT
.static CookieSameSiteSupplier of(Cookie.SameSite sameSite)
CookieSameSiteSupplier
that always returns the given
Cookie.SameSite
value.sameSite
- the value to return