Class KeycloakCookieBasedRedirect
java.lang.Object
org.keycloak.adapters.springsecurity.authentication.KeycloakCookieBasedRedirect
Utility class that provides methods to create and retrieve cookies used for login redirects.
- Author:
- Sjoerd Cranen
-
Method Summary
Modifier and TypeMethodDescriptionstatic javax.servlet.http.Cookie
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 Details
-
getRedirectUrlFromCookie
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
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.
-