Package org.keycloak.services.util
Class CookieHelper
- java.lang.Object
-
- org.keycloak.services.util.CookieHelper
-
public class CookieHelper extends Object
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Field Summary
Fields Modifier and Type Field Description static String
LEGACY_COOKIE
-
Constructor Summary
Constructors Constructor Description CookieHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCookie(String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly, org.keycloak.common.util.ServerCookie.SameSiteAttributeValue sameSite, org.keycloak.models.KeycloakSession session)
Set a response cookie.static void
addCookie(String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly, org.keycloak.models.KeycloakSession session)
Set a response cookie avoiding SameSite parameterstatic void
addCookiesAtEndOfTransaction(org.keycloak.models.KeycloakSession session)
Adding cookies at the end of the transaction helps when retrying a transaction might add the cookie multiple times.static javax.ws.rs.core.Cookie
getCookie(Map<String,javax.ws.rs.core.Cookie> cookies, String name)
static Set<String>
getCookieValue(org.keycloak.models.KeycloakSession session, String name)
static Set<String>
parseCookie(String header, String name)
-
-
-
Field Detail
-
LEGACY_COOKIE
public static final String LEGACY_COOKIE
- See Also:
- Constant Field Values
-
-
Method Detail
-
addCookie
public static void addCookie(String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly, org.keycloak.common.util.ServerCookie.SameSiteAttributeValue sameSite, org.keycloak.models.KeycloakSession session)
Set a response cookie. This solely exists because JAX-RS 1.1 does not support setting HttpOnly cookies- Parameters:
name
-value
-path
-domain
-comment
-maxAge
-secure
-httpOnly
-sameSite
-
-
addCookiesAtEndOfTransaction
public static void addCookiesAtEndOfTransaction(org.keycloak.models.KeycloakSession session)
Adding cookies at the end of the transaction helps when retrying a transaction might add the cookie multiple times. In some scenarios it must not be added at the end of the transaction, as at that time the response has already been sent to the caller ("committed"), so the code needs to make a choice. As retrying transactions is the exception, adding cookies at the end of the transaction is also the exception and needs to be switched on where necessary.
-
addCookie
public static void addCookie(String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly, org.keycloak.models.KeycloakSession session)
Set a response cookie avoiding SameSite parameter- Parameters:
name
-value
-path
-domain
-comment
-maxAge
-secure
-httpOnly
-
-
getCookieValue
public static Set<String> getCookieValue(org.keycloak.models.KeycloakSession session, String name)
-
-