Class AuthenticatorUtil

java.lang.Object
org.keycloak.authentication.AuthenticatorUtil

public class AuthenticatorUtil extends Object
  • Field Details

    • CALLBACKS_FACTORY_IDS_NOTE

      public static String CALLBACKS_FACTORY_IDS_NOTE
  • Constructor Details

    • AuthenticatorUtil

      public AuthenticatorUtil()
  • Method Details

    • isSSOAuthentication

      public static boolean isSSOAuthentication(AuthenticationSessionModel authSession) throws AuthenticationFlowException
      Throws:
      AuthenticationFlowException
    • isForcedReauthentication

      public static boolean isForcedReauthentication(AuthenticationSessionModel authSession)
    • isPasswordValidated

      public static boolean isPasswordValidated(AuthenticationSessionModel authSession)
    • isForkedFlow

      public static boolean isForkedFlow(AuthenticationSessionModel authSession)
    • setAuthCallbacksFactoryIds

      public static void setAuthCallbacksFactoryIds(AuthenticationSessionModel authSession, String authFactoryId)
      Set authentication session note for callbacks defined for {@link AuthenticationFlowCallbackFactory) factories
      Parameters:
      authSession - authentication session
      authFactoryId - authentication factory ID which should be added to the authentication session note
    • getAuthCallbacksFactoryIds

      public static Set<String> getAuthCallbacksFactoryIds(AuthenticationSessionModel authSession)
      Get set of Authentication factories IDs defined in authentication session as CALLBACKS_FACTORY_IDS_NOTE
      Parameters:
      authSession - authentication session
      Returns:
      set of factories IDs
    • getExecutionsByType

      public static List<AuthenticationExecutionModel> getExecutionsByType(RealmModel realm, String flowId, String providerId)
      Parameters:
      realm -
      flowId -
      providerId -
      Returns:
      all executions of given "provider_id" type. This is deep (recursive) obtain of executions of the particular flow
    • getTopParentFlow

      public static AuthenticationFlowModel getTopParentFlow(RealmModel realm, AuthenticationExecutionModel executionModel)
      Useful if we need to find top-level flow from executionModel
      Parameters:
      realm -
      executionModel -
      Returns:
      Top parent flow corresponding to given executionModel.
    • checkExecutionBelongsToFlow

      public static boolean checkExecutionBelongsToFlow(RealmModel realm, String flowId, AuthenticationExecutionModel executionModel)
      Checks if the execution belongs to the passed flowId. It searches recursively to see if the execution is under that specific flow.
      Parameters:
      realm - The realm
      flowId - The flow ID to check if has the execution model
      executionModel - The executionModel to check if it belongs to the passed flow ID
      Returns:
      true if the execution belongs to the flowId, false if not
    • logoutOtherSessions

      public static void logoutOtherSessions(RequiredActionContext context)
      Logouts all sessions that are different to the current authentication session managed in the action context.
      Parameters:
      context - The required action context
    • logoutOtherSessions

      public static void logoutOtherSessions(DefaultActionToken token, ActionTokenContext<? extends DefaultActionToken> context)
      Logouts all sessions that are different to the current authentication session managed in the action token context.
      Parameters:
      token - The action token
      context - The required action token context
    • getCredentialProviders

      public static Stream<CredentialProvider> getCredentialProviders(KeycloakSession session)
      Parameters:
      session -
      Returns:
      all credential providers available
    • getAuthnCredentials

      public static List<String> getAuthnCredentials(AuthenticationSessionModel authSession)
      Get the list of credentials used in the authentication.
      Parameters:
      authSession - The authentication session
      Returns:
      The immutable list of credentials (empty returned if none)
    • addAuthCredential

      public static void addAuthCredential(AuthenticationSessionModel authSession, String credential)
      Adds the credentials to the credentials used in the authentication session.
      Parameters:
      authSession - The authentication session
      credential - The credential to add