Package org.keycloak.services.managers
Class AuthenticationSessionManager
java.lang.Object
org.keycloak.services.managers.AuthenticationSessionManager
- Author:
- Marek Posolda
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.keycloak.sessions.RootAuthenticationSessionModelcreateAuthenticationSession(org.keycloak.models.RealmModel realm, boolean browserCookie) Creates a fresh authentication session for the given realm .decodeBase64AndValidateSignature(String encodedBase64AuthSessionId) org.keycloak.sessions.AuthenticationSessionModelgetAuthenticationSessionByEncodedIdAndClient(org.keycloak.models.RealmModel realm, String encodedAuthSessionId, org.keycloak.models.ClientModel client, String tabId) org.keycloak.sessions.AuthenticationSessionModelgetAuthenticationSessionByIdAndClient(org.keycloak.models.RealmModel realm, String authSessionId, org.keycloak.models.ClientModel client, String tabId) org.keycloak.sessions.AuthenticationSessionModelgetCurrentAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, String tabId) org.keycloak.sessions.RootAuthenticationSessionModelgetCurrentRootAuthenticationSession(org.keycloak.models.RealmModel realm) org.keycloak.models.UserSessionModelgetUserSession(org.keycloak.sessions.AuthenticationSessionModel authSession) org.keycloak.models.UserSessionModelgetUserSessionFromAuthenticationCookie(org.keycloak.models.RealmModel realm) voidremoveAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession, boolean expireRestartCookie) booleanremoveTabIdInAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession) Remove authentication session from root session.voidsetAuthSessionCookie(String authSessionId) voidsetAuthSessionIdHashCookie(String authSessionId) signAndEncodeToBase64AuthSessionId(String authSessionId) voidupdateAuthenticationSessionAfterSuccessfulAuthentication(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession) This happens when one browser tab successfully finished authentication (including required actions and consent screen if applicable) Just authenticationSession of the current browser tab is removed from "root authentication session" and other tabs are kept, so authentication can be automatically finished in other browser tabs (typically with authChecker.js javascript)
-
Constructor Details
-
AuthenticationSessionManager
public AuthenticationSessionManager(org.keycloak.models.KeycloakSession session)
-
-
Method Details
-
createAuthenticationSession
public org.keycloak.sessions.RootAuthenticationSessionModel createAuthenticationSession(org.keycloak.models.RealmModel realm, boolean browserCookie) Creates a fresh authentication session for the given realm . Optionally sets the browser authentication session cookie with the ID of the new session.- Parameters:
browserCookie- Set the cookie in the browser for the
-
getCurrentRootAuthenticationSession
public org.keycloak.sessions.RootAuthenticationSessionModel getCurrentRootAuthenticationSession(org.keycloak.models.RealmModel realm) -
getCurrentAuthenticationSession
public org.keycloak.sessions.AuthenticationSessionModel getCurrentAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, String tabId) - Returns:
- The current authentication session if it exists, otherwise returns
null.
-
setAuthSessionCookie
- Parameters:
authSessionId- decoded authSessionId (without route info attached)
-
setAuthSessionIdHashCookie
- Parameters:
authSessionId- decoded authSessionId (without route info attached)
-
decodeBase64AndValidateSignature
-
signAndEncodeToBase64AuthSessionId
-
removeAuthenticationSession
public void removeAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession, boolean expireRestartCookie) -
removeTabIdInAuthenticationSession
public boolean removeTabIdInAuthenticationSession(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession) Remove authentication session from root session. Possibly remove whole root authentication session if there are no other browser tabs- Returns:
- true if whole root authentication session was removed. False just if single tab was removed
-
updateAuthenticationSessionAfterSuccessfulAuthentication
public void updateAuthenticationSessionAfterSuccessfulAuthentication(org.keycloak.models.RealmModel realm, org.keycloak.sessions.AuthenticationSessionModel authSession) This happens when one browser tab successfully finished authentication (including required actions and consent screen if applicable) Just authenticationSession of the current browser tab is removed from "root authentication session" and other tabs are kept, so authentication can be automatically finished in other browser tabs (typically with authChecker.js javascript) -
getUserSession
public org.keycloak.models.UserSessionModel getUserSession(org.keycloak.sessions.AuthenticationSessionModel authSession) -
getAuthenticationSessionByIdAndClient
-
getAuthenticationSessionByEncodedIdAndClient
-
getUserSessionFromAuthenticationCookie
public org.keycloak.models.UserSessionModel getUserSessionFromAuthenticationCookie(org.keycloak.models.RealmModel realm)
-