Package org.keycloak.services.managers
Class AuthenticationManager
- java.lang.Object
- 
- org.keycloak.services.managers.AuthenticationManager
 
- 
- Direct Known Subclasses:
- AppAuthManager
 
 public class AuthenticationManager extends Object Stateless object that manages authentication- Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAuthenticationManager.AuthenticationStatusstatic classAuthenticationManager.AuthResult
 - 
Field SummaryFields Modifier and Type Field Description static StringAUTH_TIMEstatic StringAUTH_TIME_BROKERstatic StringCLIENT_LOGOUT_STATEAuth session note on client logout state (when logging out)static StringEND_AFTER_REQUIRED_ACTIONSstatic StringFORCED_REAUTHENTICATIONstatic StringFORM_USERNAMEstatic StringINITIATING_IDP_PARAMstatic StringINVALIDATE_ACTION_TOKENstatic StringKEYCLOAK_IDENTITY_COOKIEstatic StringKEYCLOAK_LOGOUT_PROTOCOLstatic StringKEYCLOAK_REMEMBER_MEstatic StringKEYCLOAK_SESSION_COOKIEprotected static org.jboss.logging.Loggerloggerstatic StringLOGOUT_INITIATING_IDPstatic StringLOGOUT_WITH_SYSTEM_CLIENTstatic StringSET_REDIRECT_URI_AFTER_REQUIRED_ACTIONSstatic StringSSO_AUTHstatic StringUSER_SESSION_PERSISTENT_STATEAuth session note, which indicates if user session will be persistent (Saved to real persistent store) or transient (transient session will be scoped to single request and hence there is no need to save it in the underlying store)
 - 
Constructor SummaryConstructors Constructor Description AuthenticationManager()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static javax.ws.rs.core.ResponseactionRequired(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event)AuthenticationManager.AuthResultauthenticateIdentityCookie(KeycloakSession session, RealmModel realm)static AuthenticationManager.AuthResultauthenticateIdentityCookie(KeycloakSession session, RealmModel realm, boolean checkActive)static BackchannelLogoutResponsebackchannelLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers, boolean logoutBroker)static BackchannelLogoutResponsebackchannelLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers, boolean logoutBroker, boolean offlineSession)static voidbackchannelLogout(KeycloakSession session, UserSessionModel userSession, boolean logoutBroker)static voidbackchannelLogoutUserFromClient(KeycloakSession session, RealmModel realm, UserModel user, ClientModel client, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.HttpHeaders headers)Logout all clientSessions of this user and clientstatic javax.ws.rs.core.ResponsebrowserLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers)static IdentityCookieTokencreateIdentityToken(KeycloakSession keycloakSession, RealmModel realm, UserModel user, UserSessionModel session, String issuer)static voidcreateLoginCookie(KeycloakSession keycloakSession, RealmModel realm, UserModel user, UserSessionModel session, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection)static AuthenticationSessionModelcreateOrJoinLogoutSession(KeycloakSession session, RealmModel realm, AuthenticationSessionManager asm, UserSessionModel userSession, boolean browserCookie)static voidcreateRememberMeCookie(String username, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session)static RequiredActionProvidercreateRequiredAction(RequiredActionContextResult context)static voidevaluateRequiredActionTriggers(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event, RealmModel realm, UserModel user)protected static javax.ws.rs.core.ResponseexecutionActions(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event, RealmModel realm, UserModel user, Stream<String> requiredActions)static voidexpireCookie(RealmModel realm, String cookieName, String path, boolean httpOnly, ClientConnection connection, ServerCookie.SameSiteAttributeValue sameSite, KeycloakSession session)static voidexpireIdentityCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session)static voidexpireOldAuthSessionCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session)static voidexpireOldIdentityCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session)static voidexpireRememberMeCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session)static booleanexpireUserSessionCookie(KeycloakSession session, UserSessionModel userSession, RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.HttpHeaders headers, ClientConnection connection)static javax.ws.rs.core.ResponsefinishBrowserLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers)static javax.ws.rs.core.ResponsefinishedRequiredActions(KeycloakSession session, AuthenticationSessionModel authSession, UserSessionModel userSession, ClientConnection clientConnection, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, EventBuilder event)static voidfinishUnconfirmedUserSession(KeycloakSession session, RealmModel realm, UserSessionModel userSessionModel)static StringgetAccountCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo)static CommonClientSessionModel.ActiongetClientLogoutAction(AuthenticationSessionModel logoutAuthSession, String clientUuid)Returns the logout state of the particular client as per thelogoutAuthSessionprotected static StringgetIdentityCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo)static StringgetOldCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo)static StringgetRealmCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo)static StringgetRememberMeUsername(RealmModel realm, javax.ws.rs.core.HttpHeaders headers)static StringgetSessionIdFromSessionCookie(KeycloakSession session)static booleanisOfflineSessionValid(RealmModel realm, UserSessionModel userSession)static booleanisSessionValid(RealmModel realm, UserSessionModel userSession)static booleanisSSOAuthentication(AuthenticatedClientSessionModel clientSession)static voidlogSuccess(KeycloakSession session, AuthenticationSessionModel authSession)static UserModellookupUserForBruteForceLog(KeycloakSession session, RealmModel realm, AuthenticationSessionModel authenticationSession)static javax.ws.rs.core.ResponsenextActionAfterAuthentication(KeycloakSession session, AuthenticationSessionModel authSession, ClientConnection clientConnection, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, EventBuilder event)static StringnextRequiredAction(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event)static javax.ws.rs.core.ResponseredirectAfterSuccessfulFlow(KeycloakSession session, RealmModel realm, UserSessionModel userSession, ClientSessionContext clientSessionCtx, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, ClientConnection clientConnection, EventBuilder event, AuthenticationSessionModel authSession)static javax.ws.rs.core.ResponseredirectAfterSuccessfulFlow(KeycloakSession session, RealmModel realm, UserSessionModel userSession, ClientSessionContext clientSessionCtx, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, ClientConnection clientConnection, EventBuilder event, AuthenticationSessionModel authSession, LoginProtocol protocol)static javax.ws.rs.core.ResponseredirectToRequiredActions(KeycloakSession session, RealmModel realm, AuthenticationSessionModel authSession, javax.ws.rs.core.UriInfo uriInfo, String requiredAction)static voidsetClientLogoutAction(AuthenticationSessionModel logoutAuthSession, String clientUuid, CommonClientSessionModel.Action action)Sets logout state of the particular client into thelogoutAuthSessionstatic voidsetClientScopesInSession(AuthenticationSessionModel authSession)static voidsetKcActionStatus(String executedProviderId, RequiredActionContext.KcActionStatus status, AuthenticationSessionModel authSession)static AuthenticationManager.AuthResultverifyIdentityToken(KeycloakSession session, RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, boolean checkActive, boolean checkTokenType, String checkAudience, boolean isCookie, String tokenString, javax.ws.rs.core.HttpHeaders headers, TokenVerifier.Predicate<? super AccessToken>... additionalChecks)
 
- 
- 
- 
Field Detail- 
SET_REDIRECT_URI_AFTER_REQUIRED_ACTIONSpublic static final String SET_REDIRECT_URI_AFTER_REQUIRED_ACTIONS - See Also:
- Constant Field Values
 
 - 
END_AFTER_REQUIRED_ACTIONSpublic static final String END_AFTER_REQUIRED_ACTIONS - See Also:
- Constant Field Values
 
 - 
INVALIDATE_ACTION_TOKENpublic static final String INVALIDATE_ACTION_TOKEN - See Also:
- Constant Field Values
 
 - 
USER_SESSION_PERSISTENT_STATEpublic static final String USER_SESSION_PERSISTENT_STATE Auth session note, which indicates if user session will be persistent (Saved to real persistent store) or transient (transient session will be scoped to single request and hence there is no need to save it in the underlying store)- See Also:
- Constant Field Values
 
 - 
CLIENT_LOGOUT_STATEpublic static final String CLIENT_LOGOUT_STATE Auth session note on client logout state (when logging out)- See Also:
- Constant Field Values
 
 - 
AUTH_TIMEpublic static final String AUTH_TIME - See Also:
- Constant Field Values
 
 - 
AUTH_TIME_BROKERpublic static final String AUTH_TIME_BROKER - See Also:
- Constant Field Values
 
 - 
SSO_AUTHpublic static final String SSO_AUTH - See Also:
- Constant Field Values
 
 - 
FORCED_REAUTHENTICATIONpublic static final String FORCED_REAUTHENTICATION - See Also:
- Constant Field Values
 
 - 
loggerprotected static final org.jboss.logging.Logger logger 
 - 
FORM_USERNAMEpublic static final String FORM_USERNAME - See Also:
- Constant Field Values
 
 - 
KEYCLOAK_IDENTITY_COOKIEpublic static final String KEYCLOAK_IDENTITY_COOKIE - See Also:
- Constant Field Values
 
 - 
KEYCLOAK_SESSION_COOKIEpublic static final String KEYCLOAK_SESSION_COOKIE - See Also:
- Constant Field Values
 
 - 
KEYCLOAK_REMEMBER_MEpublic static final String KEYCLOAK_REMEMBER_ME - See Also:
- Constant Field Values
 
 - 
LOGOUT_WITH_SYSTEM_CLIENTpublic static final String LOGOUT_WITH_SYSTEM_CLIENT - See Also:
- Constant Field Values
 
 - 
KEYCLOAK_LOGOUT_PROTOCOLpublic static final String KEYCLOAK_LOGOUT_PROTOCOL - See Also:
- Constant Field Values
 
 - 
LOGOUT_INITIATING_IDPpublic static final String LOGOUT_INITIATING_IDP - See Also:
- Constant Field Values
 
 - 
INITIATING_IDP_PARAMpublic static final String INITIATING_IDP_PARAM - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
isSessionValidpublic static boolean isSessionValid(RealmModel realm, UserSessionModel userSession) 
 - 
isOfflineSessionValidpublic static boolean isOfflineSessionValid(RealmModel realm, UserSessionModel userSession) 
 - 
expireUserSessionCookiepublic static boolean expireUserSessionCookie(KeycloakSession session, UserSessionModel userSession, RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.HttpHeaders headers, ClientConnection connection) 
 - 
backchannelLogoutpublic static void backchannelLogout(KeycloakSession session, UserSessionModel userSession, boolean logoutBroker) 
 - 
backchannelLogoutpublic static BackchannelLogoutResponse backchannelLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers, boolean logoutBroker) 
 - 
backchannelLogoutpublic static BackchannelLogoutResponse backchannelLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers, boolean logoutBroker, boolean offlineSession) - Parameters:
- session-
- realm-
- userSession-
- uriInfo-
- connection-
- headers-
- logoutBroker-
- offlineSession-
- Returns:
- BackchannelLogoutResponse with logout information
 
 - 
createOrJoinLogoutSessionpublic static AuthenticationSessionModel createOrJoinLogoutSession(KeycloakSession session, RealmModel realm, AuthenticationSessionManager asm, UserSessionModel userSession, boolean browserCookie) 
 - 
setClientLogoutActionpublic static void setClientLogoutAction(AuthenticationSessionModel logoutAuthSession, String clientUuid, CommonClientSessionModel.Action action) Sets logout state of the particular client into thelogoutAuthSession- Parameters:
- logoutAuthSession- logoutAuthSession. May be- nullin which case this is a no-op.
- clientUuid- Client. Must not be- null
- action-
 
 - 
getClientLogoutActionpublic static CommonClientSessionModel.Action getClientLogoutAction(AuthenticationSessionModel logoutAuthSession, String clientUuid) Returns the logout state of the particular client as per thelogoutAuthSession- Parameters:
- logoutAuthSession- logoutAuthSession. May be- nullin which case this is a no-op.
- clientUuid- Internal ID of the client. Must not be- null
- Returns:
- State if it can be determined, nullotherwise.
 
 - 
backchannelLogoutUserFromClientpublic static void backchannelLogoutUserFromClient(KeycloakSession session, RealmModel realm, UserModel user, ClientModel client, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.HttpHeaders headers) Logout all clientSessions of this user and client- Parameters:
- session-
- realm-
- user-
- client-
- uriInfo-
- headers-
 
 - 
browserLogoutpublic static javax.ws.rs.core.Response browserLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers) 
 - 
finishBrowserLogoutpublic static javax.ws.rs.core.Response finishBrowserLogout(KeycloakSession session, RealmModel realm, UserSessionModel userSession, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, javax.ws.rs.core.HttpHeaders headers) 
 - 
finishUnconfirmedUserSessionpublic static void finishUnconfirmedUserSession(KeycloakSession session, RealmModel realm, UserSessionModel userSessionModel) 
 - 
createIdentityTokenpublic static IdentityCookieToken createIdentityToken(KeycloakSession keycloakSession, RealmModel realm, UserModel user, UserSessionModel session, String issuer) 
 - 
createLoginCookiepublic static void createLoginCookie(KeycloakSession keycloakSession, RealmModel realm, UserModel user, UserSessionModel session, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection) 
 - 
createRememberMeCookiepublic static void createRememberMeCookie(String username, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session) 
 - 
getRememberMeUsernamepublic static String getRememberMeUsername(RealmModel realm, javax.ws.rs.core.HttpHeaders headers) 
 - 
expireIdentityCookiepublic static void expireIdentityCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session) 
 - 
expireOldIdentityCookiepublic static void expireOldIdentityCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session) 
 - 
expireRememberMeCookiepublic static void expireRememberMeCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session) 
 - 
expireOldAuthSessionCookiepublic static void expireOldAuthSessionCookie(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, KeycloakSession session) 
 - 
getIdentityCookiePathprotected static String getIdentityCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo) 
 - 
getRealmCookiePathpublic static String getRealmCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo) 
 - 
getOldCookiePathpublic static String getOldCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo) 
 - 
getAccountCookiePathpublic static String getAccountCookiePath(RealmModel realm, javax.ws.rs.core.UriInfo uriInfo) 
 - 
expireCookiepublic static void expireCookie(RealmModel realm, String cookieName, String path, boolean httpOnly, ClientConnection connection, ServerCookie.SameSiteAttributeValue sameSite, KeycloakSession session) 
 - 
authenticateIdentityCookiepublic AuthenticationManager.AuthResult authenticateIdentityCookie(KeycloakSession session, RealmModel realm) 
 - 
authenticateIdentityCookiepublic static AuthenticationManager.AuthResult authenticateIdentityCookie(KeycloakSession session, RealmModel realm, boolean checkActive) 
 - 
redirectAfterSuccessfulFlowpublic static javax.ws.rs.core.Response redirectAfterSuccessfulFlow(KeycloakSession session, RealmModel realm, UserSessionModel userSession, ClientSessionContext clientSessionCtx, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, ClientConnection clientConnection, EventBuilder event, AuthenticationSessionModel authSession) 
 - 
redirectAfterSuccessfulFlowpublic static javax.ws.rs.core.Response redirectAfterSuccessfulFlow(KeycloakSession session, RealmModel realm, UserSessionModel userSession, ClientSessionContext clientSessionCtx, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, ClientConnection clientConnection, EventBuilder event, AuthenticationSessionModel authSession, LoginProtocol protocol) 
 - 
getSessionIdFromSessionCookiepublic static String getSessionIdFromSessionCookie(KeycloakSession session) 
 - 
isSSOAuthenticationpublic static boolean isSSOAuthentication(AuthenticatedClientSessionModel clientSession) 
 - 
nextActionAfterAuthenticationpublic static javax.ws.rs.core.Response nextActionAfterAuthentication(KeycloakSession session, AuthenticationSessionModel authSession, ClientConnection clientConnection, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, EventBuilder event) 
 - 
redirectToRequiredActionspublic static javax.ws.rs.core.Response redirectToRequiredActions(KeycloakSession session, RealmModel realm, AuthenticationSessionModel authSession, javax.ws.rs.core.UriInfo uriInfo, String requiredAction) 
 - 
finishedRequiredActionspublic static javax.ws.rs.core.Response finishedRequiredActions(KeycloakSession session, AuthenticationSessionModel authSession, UserSessionModel userSession, ClientConnection clientConnection, HttpRequest request, javax.ws.rs.core.UriInfo uriInfo, EventBuilder event) 
 - 
nextRequiredActionpublic static String nextRequiredAction(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event) 
 - 
actionRequiredpublic static javax.ws.rs.core.Response actionRequired(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event) 
 - 
setClientScopesInSessionpublic static void setClientScopesInSession(AuthenticationSessionModel authSession) 
 - 
createRequiredActionpublic static RequiredActionProvider createRequiredAction(RequiredActionContextResult context) 
 - 
executionActionsprotected static javax.ws.rs.core.Response executionActions(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event, RealmModel realm, UserModel user, Stream<String> requiredActions) 
 - 
evaluateRequiredActionTriggerspublic static void evaluateRequiredActionTriggers(KeycloakSession session, AuthenticationSessionModel authSession, HttpRequest request, EventBuilder event, RealmModel realm, UserModel user) 
 - 
verifyIdentityTokenpublic static AuthenticationManager.AuthResult verifyIdentityToken(KeycloakSession session, RealmModel realm, javax.ws.rs.core.UriInfo uriInfo, ClientConnection connection, boolean checkActive, boolean checkTokenType, String checkAudience, boolean isCookie, String tokenString, javax.ws.rs.core.HttpHeaders headers, TokenVerifier.Predicate<? super AccessToken>... additionalChecks) 
 - 
setKcActionStatuspublic static void setKcActionStatus(String executedProviderId, RequiredActionContext.KcActionStatus status, AuthenticationSessionModel authSession) 
 - 
logSuccesspublic static void logSuccess(KeycloakSession session, AuthenticationSessionModel authSession) 
 - 
lookupUserForBruteForceLogpublic static UserModel lookupUserForBruteForceLog(KeycloakSession session, RealmModel realm, AuthenticationSessionModel authenticationSession) 
 
- 
 
-