Java Code Examples for org.keycloak.models.RealmModel#getRequiredActionProviderByAlias()
The following examples show how to use
org.keycloak.models.RealmModel#getRequiredActionProviderByAlias() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticationManager.java From keycloak with Apache License 2.0 | 6 votes |
private static List<RequiredActionProviderModel> sortRequiredActionsByPriority(RealmModel realm, Set<String> requiredActions) { List<RequiredActionProviderModel> actions = new ArrayList<>(); for (String action : requiredActions) { RequiredActionProviderModel model = realm.getRequiredActionProviderByAlias(action); if (model == null) { logger.warnv("Could not find configuration for Required Action {0}, did you forget to register it?", action); continue; } if (!model.isEnabled()) { continue; } actions.add(model); } Collections.sort(actions, RequiredActionProviderModel.RequiredActionComparator.SINGLETON); return actions; }
Example 2
Source File: Authenticator.java From keycloak with Apache License 2.0 | 5 votes |
/** * Checks if all required actions are configured in the realm and are enabled * @return */ default boolean areRequiredActionsEnabled(KeycloakSession session, RealmModel realm) { for (RequiredActionFactory raf : getRequiredActions(session)) { RequiredActionProviderModel rafpm = realm.getRequiredActionProviderByAlias(raf.getId()); if (rafpm == null) { return false; } if (!rafpm.isEnabled()) { return false; } } return true; }
Example 3
Source File: DefaultRequiredActions.java From keycloak with Apache License 2.0 | 5 votes |
public static void addUpdateLocaleAction(RealmModel realm) { if (realm.getRequiredActionProviderByAlias("update_user_locale") == null) { RequiredActionProviderModel updateUserLocale = new RequiredActionProviderModel(); updateUserLocale.setEnabled(true); updateUserLocale.setAlias("update_user_locale"); updateUserLocale.setName("Update User Locale"); updateUserLocale.setProviderId("update_user_locale"); updateUserLocale.setDefaultAction(false); updateUserLocale.setPriority(1000); realm.addRequiredActionProvider(updateUserLocale); } }
Example 4
Source File: DefaultRequiredActions.java From keycloak with Apache License 2.0 | 4 votes |
public static void addActions(RealmModel realm) { if (realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.VERIFY_EMAIL.name()) == null) { RequiredActionProviderModel verifyEmail = new RequiredActionProviderModel(); verifyEmail.setEnabled(true); verifyEmail.setAlias(UserModel.RequiredAction.VERIFY_EMAIL.name()); verifyEmail.setName("Verify Email"); verifyEmail.setProviderId(UserModel.RequiredAction.VERIFY_EMAIL.name()); verifyEmail.setDefaultAction(false); verifyEmail.setPriority(50); realm.addRequiredActionProvider(verifyEmail); } if (realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.UPDATE_PROFILE.name()) == null) { RequiredActionProviderModel updateProfile = new RequiredActionProviderModel(); updateProfile.setEnabled(true); updateProfile.setAlias(UserModel.RequiredAction.UPDATE_PROFILE.name()); updateProfile.setName("Update Profile"); updateProfile.setProviderId(UserModel.RequiredAction.UPDATE_PROFILE.name()); updateProfile.setDefaultAction(false); updateProfile.setPriority(40); realm.addRequiredActionProvider(updateProfile); } if (realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.CONFIGURE_TOTP.name()) == null) { RequiredActionProviderModel totp = new RequiredActionProviderModel(); totp.setEnabled(true); totp.setAlias(UserModel.RequiredAction.CONFIGURE_TOTP.name()); totp.setName("Configure OTP"); totp.setProviderId(UserModel.RequiredAction.CONFIGURE_TOTP.name()); totp.setDefaultAction(false); totp.setPriority(10); realm.addRequiredActionProvider(totp); } if (realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.UPDATE_PASSWORD.name()) == null) { RequiredActionProviderModel updatePassword = new RequiredActionProviderModel(); updatePassword.setEnabled(true); updatePassword.setAlias(UserModel.RequiredAction.UPDATE_PASSWORD.name()); updatePassword.setName("Update Password"); updatePassword.setProviderId(UserModel.RequiredAction.UPDATE_PASSWORD.name()); updatePassword.setDefaultAction(false); updatePassword.setPriority(30); realm.addRequiredActionProvider(updatePassword); } if (realm.getRequiredActionProviderByAlias("terms_and_conditions") == null) { RequiredActionProviderModel termsAndConditions = new RequiredActionProviderModel(); termsAndConditions.setEnabled(false); termsAndConditions.setAlias("terms_and_conditions"); termsAndConditions.setName("Terms and Conditions"); termsAndConditions.setProviderId("terms_and_conditions"); termsAndConditions.setDefaultAction(false); termsAndConditions.setPriority(20); realm.addRequiredActionProvider(termsAndConditions); } addUpdateLocaleAction(realm); }
Example 5
Source File: MigrateTo2_1_0.java From keycloak with Apache License 2.0 | 3 votes |
private void migrateDefaultRequiredAction(RealmModel realm) { RequiredActionProviderModel otpAction = realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.CONFIGURE_TOTP.name()); MigrationUtils.updateOTPRequiredAction(otpAction); realm.updateRequiredActionProvider(otpAction); }