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.SameSitevalues that should be used for the givenCookie.static CookieSameSiteSupplierof(Cookie.SameSite sameSite) Return a newCookieSameSiteSupplierthat always returns the givenCookie.SameSitevalue.static CookieSameSiteSupplierofLax()Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.LAX.static CookieSameSiteSupplierofNone()Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.NONE.static CookieSameSiteSupplierofStrict()Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.STRICT.default CookieSameSiteSupplierLimit this supplier so that it's only called if the predicate accepts the Cookie.default CookieSameSiteSupplierwhenHasName(String name) Limit this supplier so that it's only called if the Cookie has the given name.default CookieSameSiteSupplierwhenHasName(Supplier<String> nameSupplier) Limit this supplier so that it's only called if the Cookie has the given name.default CookieSameSiteSupplierwhenHasNameMatching(String regex) Limit this supplier so that it's only called if the Cookie name matches the given regex.default CookieSameSiteSupplierwhenHasNameMatching(Pattern pattern) Limit this supplier so that it's only called if the Cookie name matches the givenPattern.
-
Method Details
-
getSameSite
Get theCookie.SameSitevalues that should be used for the givenCookie.- Parameters:
cookie- the cookie to check- Returns:
- the
Cookie.SameSitevalue to use ornullif 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
CookieSameSiteSupplierthat 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
CookieSameSiteSupplierthat 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
CookieSameSiteSupplierthat 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
CookieSameSiteSupplierthat 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
CookieSameSiteSupplierthat only calls this supplier when the cookie matches the predicate
-
ofNone
Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.NONE.- Returns:
- the supplier instance
-
ofLax
Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.LAX.- Returns:
- the supplier instance
-
ofStrict
Return a newCookieSameSiteSupplierthat always returnsCookie.SameSite.STRICT.- Returns:
- the supplier instance
-
of
Return a newCookieSameSiteSupplierthat always returns the givenCookie.SameSitevalue.- Parameters:
sameSite- the value to return- Returns:
- the supplier instance
-