Migration fix

This commit is contained in:
mposolda 2016-08-01 17:12:50 +02:00
parent 9688880837
commit a5cbe113fd
3 changed files with 14 additions and 4 deletions

View file

@ -52,11 +52,9 @@ public class MigrateTo2_1_0 {
private void migrateDefaultRequiredAction(RealmModel realm) {
RequiredActionProviderModel otpAction = realm.getRequiredActionProviderByAlias(UserModel.RequiredAction.CONFIGURE_TOTP.name());
if (otpAction == null) return;
if (!otpAction.getProviderId().equals(UserModel.RequiredAction.CONFIGURE_TOTP.name())) return;
if (!otpAction.getName().equals("Configure Totp")) return;
MigrationUtils.updateOTPRequiredAction(otpAction);
otpAction.setName("Configure OTP");
realm.updateRequiredActionProvider(otpAction);
}
// KEYCLOAK-3338: Changes to how role policy config is stored"

View file

@ -47,4 +47,12 @@ public class MigrationUtils {
}
}
public static void updateOTPRequiredAction(RequiredActionProviderModel otpAction) {
if (otpAction == null) return;
if (!otpAction.getProviderId().equals(UserModel.RequiredAction.CONFIGURE_TOTP.name())) return;
if (!otpAction.getName().equals("Configure Totp")) return;
otpAction.setName("Configure OTP");
}
}

View file

@ -21,6 +21,7 @@ import org.keycloak.authorization.AuthorizationProvider;
import org.keycloak.authorization.model.ResourceServer;
import org.keycloak.authorization.store.ResourceServerStore;
import org.keycloak.hash.Pbkdf2PasswordHashProvider;
import org.keycloak.migration.migrators.MigrationUtils;
import org.keycloak.models.ClientTemplateModel;
import org.keycloak.models.Constants;
import org.keycloak.common.util.Base64;
@ -204,6 +205,9 @@ public class RepresentationToModel {
if (rep.getRequiredActions() != null) {
for (RequiredActionProviderRepresentation action : rep.getRequiredActions()) {
RequiredActionProviderModel model = toModel(action);
MigrationUtils.updateOTPRequiredAction(model);
newRealm.addRequiredActionProvider(model);
}
} else {