Class KeycloakCookieBasedRedirect
- java.lang.Object
-
- org.keycloak.adapters.springsecurity.authentication.KeycloakCookieBasedRedirect
-
public final class KeycloakCookieBasedRedirect extends Object
Utility class that provides methods to create and retrieve cookies used for login redirects.- Author:
- Sjoerd Cranen
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.servlet.http.Cookie
createCookieFromRedirectUrl(String url)
Creates a cookie with name "KC_REDIRECT" and the given URL as value.static String
getRedirectUrlFromCookie(javax.servlet.http.HttpServletRequest request)
Checks if a cookie with name "KC_REDIRECT" exists, and if so, returns its value.
-
-
-
Method Detail
-
getRedirectUrlFromCookie
public static String getRedirectUrlFromCookie(javax.servlet.http.HttpServletRequest request)
Checks if a cookie with name "KC_REDIRECT" exists, and if so, returns its value. If multiple cookies of the same name exist, the value of the first cookie is returned.- Parameters:
request
- the request to retrieve the cookie from.- Returns:
- the value of the cookie, if it exists, or else
null
.
-
createCookieFromRedirectUrl
public static javax.servlet.http.Cookie createCookieFromRedirectUrl(String url)
Creates a cookie with name "KC_REDIRECT" and the given URL as value.- Parameters:
url
- the value that the cookie should have. Ifnull
, a cookie is created that expires immediately and has an empty string as value.- Returns:
- a cookie that can be added to a response.
-
-