diff --git a/model/api/src/main/java/org/keycloak/models/IdentityProviderModel.java b/model/api/src/main/java/org/keycloak/models/IdentityProviderModel.java index 12501bba61..11a95a27c1 100644 --- a/model/api/src/main/java/org/keycloak/models/IdentityProviderModel.java +++ b/model/api/src/main/java/org/keycloak/models/IdentityProviderModel.java @@ -28,6 +28,8 @@ import java.util.Map; */ public class IdentityProviderModel { + private String internalId; + /** *

An user-defined identifier to unique identify an identity provider instance.

*/ @@ -58,6 +60,7 @@ public class IdentityProviderModel { } public IdentityProviderModel(IdentityProviderModel model) { + this.internalId = model.getInternalId(); this.providerId = model.getProviderId(); this.id = model.getId(); this.name = model.getName(); @@ -66,6 +69,14 @@ public class IdentityProviderModel { this.updateProfileFirstLogin = model.isUpdateProfileFirstLogin(); } + public String getInternalId() { + return this.internalId; + } + + public void setInternalId(String internalId) { + this.internalId = internalId; + } + public String getId() { return this.id; } diff --git a/model/api/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java b/model/api/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java index 71109a4fc5..964a12c8eb 100644 --- a/model/api/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java +++ b/model/api/src/main/java/org/keycloak/models/entities/IdentityProviderEntity.java @@ -25,6 +25,7 @@ import java.util.Map; */ public class IdentityProviderEntity { + private String internalId; private String name; private boolean enabled; private boolean updateProfileFirstLogin; @@ -32,6 +33,14 @@ public class IdentityProviderEntity { private String id; private Map config = new HashMap(); + public String getInternalId() { + return this.internalId; + } + + public void setInternalId(String internalId) { + this.internalId = internalId; + } + public String getName() { return this.name; } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java index af73db6c91..6cd1d0aa83 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java @@ -1115,6 +1115,7 @@ public class RealmAdapter implements RealmModel { identityProviderModel.setProviderId(entity.getProviderId()); identityProviderModel.setId(entity.getId()); + identityProviderModel.setInternalId(entity.getInternalId()); identityProviderModel.setName(entity.getName()); identityProviderModel.setConfig(entity.getConfig()); identityProviderModel.setEnabled(entity.isEnabled()); @@ -1168,7 +1169,8 @@ public class RealmAdapter implements RealmModel { @Override public void updateIdentityProvider(IdentityProviderModel identityProvider) { for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) { - if (entity.getId().equals(identityProvider.getId())) { + if (entity.getInternalId().equals(identityProvider.getInternalId())) { + entity.setId(identityProvider.getId()); entity.setName(identityProvider.getName()); entity.setEnabled(identityProvider.isEnabled()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin()); diff --git a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java index 3bb71132db..de0a0cc8b5 100755 --- a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java +++ b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java @@ -791,6 +791,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme identityProviderModel.setProviderId(entity.getProviderId()); identityProviderModel.setId(entity.getId()); + identityProviderModel.setInternalId(entity.getInternalId()); identityProviderModel.setName(entity.getName()); identityProviderModel.setConfig(entity.getConfig()); identityProviderModel.setEnabled(entity.isEnabled()); @@ -817,6 +818,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme public void addIdentityProvider(IdentityProviderModel identityProvider) { IdentityProviderEntity entity = new IdentityProviderEntity(); + entity.setInternalId(KeycloakModelUtils.generateId()); entity.setId(identityProvider.getId()); entity.setProviderId(identityProvider.getProviderId()); entity.setName(identityProvider.getName()); @@ -843,7 +845,8 @@ public class RealmAdapter extends AbstractMongoAdapter impleme @Override public void updateIdentityProvider(IdentityProviderModel identityProvider) { for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) { - if (entity.getId().equals(identityProvider.getId())) { + if (entity.getInternalId().equals(identityProvider.getInternalId())) { + entity.setId(identityProvider.getId()); entity.setName(identityProvider.getName()); entity.setEnabled(identityProvider.isEnabled()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin());