@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(javax.servlet.http.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(java.util.function.Predicate<javax.servlet.http.Cookie> predicate)
Limit this supplier so that it's only called if the predicate accepts the Cookie.
|
default CookieSameSiteSupplier |
whenHasName(java.lang.String name)
Limit this supplier so that it's only called if the Cookie has the given name.
|
default CookieSameSiteSupplier |
whenHasName(java.util.function.Supplier<java.lang.String> nameSupplier)
Limit this supplier so that it's only called if the Cookie has the given name.
|
default CookieSameSiteSupplier |
whenHasNameMatching(java.util.regex.Pattern pattern)
Limit this supplier so that it's only called if the Cookie name matches the given
Pattern . |
default CookieSameSiteSupplier |
whenHasNameMatching(java.lang.String regex)
Limit this supplier so that it's only called if the Cookie name matches the given
regex.
|
Cookie.SameSite getSameSite(javax.servlet.http.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(java.lang.String name)
name
- the name to checkCookieSameSiteSupplier
that only calls this supplier when the
name matchesdefault CookieSameSiteSupplier whenHasName(java.util.function.Supplier<java.lang.String> nameSupplier)
nameSupplier
- a supplier providing the name to checkCookieSameSiteSupplier
that only calls this supplier when the
name matchesdefault CookieSameSiteSupplier whenHasNameMatching(java.lang.String regex)
regex
- the regex pattern that must matchCookieSameSiteSupplier
that only calls this supplier when the
name matches the regexdefault CookieSameSiteSupplier whenHasNameMatching(java.util.regex.Pattern pattern)
Pattern
.pattern
- the regex pattern that must matchCookieSameSiteSupplier
that only calls this supplier when the
name matches the patterndefault CookieSameSiteSupplier when(java.util.function.Predicate<javax.servlet.http.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