diff --git a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/MigrateUserFedToComponent.java b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/MigrateUserFedToComponent.java
index 8d22fbde8f..bb298300cc 100644
--- a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/MigrateUserFedToComponent.java
+++ b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/MigrateUserFedToComponent.java
@@ -29,19 +29,17 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
- * @author Marek Posolda
+ * @author Bill Burke
*/
public class MigrateUserFedToComponent extends AbstractUserFedToComponent {
@Override
protected void generateStatementsImpl() throws CustomChangeException {
- String providerId = LDAPConstants.LDAP_PROVIDER;
- convertFedProviderToComponent(LDAPConstants.LDAP_PROVIDER, "org.keycloak.storage.ldap.mappers.LDAPStorageMapper");
convertFedProviderToComponent("kerberos", null);
}
@Override
protected String getTaskId() {
- return "Update 2.4.0.Final";
+ return "Update 2.4.1.Final";
}
}
diff --git a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/PortLdapUserFedToComponentModel.java b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/PortLdapUserFedToComponentModel.java
new file mode 100644
index 0000000000..dc9e6073c3
--- /dev/null
+++ b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/PortLdapUserFedToComponentModel.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.keycloak.connections.jpa.updater.liquibase.custom;
+
+import liquibase.exception.CustomChangeException;
+import org.keycloak.models.LDAPConstants;
+
+/**
+ * @author Bill Burke
+ */
+public class PortLdapUserFedToComponentModel extends AbstractUserFedToComponent {
+
+ @Override
+ protected void generateStatementsImpl() throws CustomChangeException {
+ String providerId = LDAPConstants.LDAP_PROVIDER;
+ convertFedProviderToComponent(LDAPConstants.LDAP_PROVIDER, "org.keycloak.storage.ldap.mappers.LDAPStorageMapper");
+ }
+
+ @Override
+ protected String getTaskId() {
+ return "Update 2.4.0.Final";
+ }
+}
diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.0.xml
index e8af8daac3..0aebd9a0d2 100755
--- a/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.0.xml
+++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.0.xml
@@ -19,7 +19,7 @@
-
+
\ No newline at end of file
diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml
new file mode 100755
index 0000000000..216ce651c8
--- /dev/null
+++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml
index ebe8cf3d54..4fe18b6857 100755
--- a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml
+++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml
@@ -44,4 +44,5 @@
+
diff --git a/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/DefaultMongoUpdaterProvider.java b/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/DefaultMongoUpdaterProvider.java
index c7f5be8d52..78adfb70c0 100755
--- a/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/DefaultMongoUpdaterProvider.java
+++ b/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/DefaultMongoUpdaterProvider.java
@@ -35,6 +35,7 @@ import org.keycloak.connections.mongo.updater.impl.updates.Update1_8_0;
import org.keycloak.connections.mongo.updater.impl.updates.Update1_9_2;
import org.keycloak.connections.mongo.updater.impl.updates.Update2_3_0;
import org.keycloak.connections.mongo.updater.impl.updates.Update2_4_0;
+import org.keycloak.connections.mongo.updater.impl.updates.Update2_4_1;
import org.keycloak.models.KeycloakSession;
import java.util.Date;
@@ -61,7 +62,8 @@ public class DefaultMongoUpdaterProvider implements MongoUpdaterProvider {
Update1_8_0.class,
Update1_9_2.class,
Update2_3_0.class,
- Update2_4_0.class
+ Update2_4_0.class,
+ Update2_4_1.class
};
@Override
diff --git a/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/updates/AbstractMigrateUserFedToComponent.java b/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/updates/AbstractMigrateUserFedToComponent.java
new file mode 100644
index 0000000000..d4db6d3209
--- /dev/null
+++ b/model/mongo/src/main/java/org/keycloak/connections/mongo/updater/impl/updates/AbstractMigrateUserFedToComponent.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.keycloak.connections.mongo.updater.impl.updates;
+
+import com.mongodb.BasicDBList;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import org.jboss.logging.Logger;
+import org.keycloak.storage.UserStorageProvider;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Bill Burke
+ * @version $Revision: 1 $
+ */
+public abstract class AbstractMigrateUserFedToComponent extends Update {
+ private final Logger logger = Logger.getLogger(getClass());
+
+ public void portUserFedToComponent(String providerId) {
+ DBCollection realms = db.getCollection("realms");
+ DBCursor cursor = realms.find();
+ while (cursor.hasNext()) {
+ BasicDBObject realm = (BasicDBObject) cursor.next();
+
+ String realmId = realm.getString("_id");
+ Set removedProviders = new HashSet<>();
+
+ BasicDBList componentEntities = (BasicDBList) realm.get("componentEntities");
+ BasicDBList federationProviders = (BasicDBList) realm.get("userFederationProviders");
+ for (Object obj : federationProviders) {
+ BasicDBObject fedProvider = (BasicDBObject)obj;
+ if (fedProvider.getString("providerName").equals(providerId)) {
+ String id = fedProvider.getString("id");
+ removedProviders.add(id);
+ int priority = fedProvider.getInt("priority");
+ String displayName = fedProvider.getString("displayName");
+ int fullSyncPeriod = fedProvider.getInt("fullSyncPeriod");
+ int changedSyncPeriod = fedProvider.getInt("changedSyncPeriod");
+ int lastSync = fedProvider.getInt("lastSync");
+ BasicDBObject component = new BasicDBObject();
+ component.put("id", id);
+ component.put("name", displayName);
+ component.put("providerType", UserStorageProvider.class.getName());
+ component.put("providerId", providerId);
+ component.put("parentId", realmId);
+
+ BasicDBObject config = new BasicDBObject();
+ config.put("priority", Collections.singletonList(Integer.toString(priority)));
+ config.put("fullSyncPeriod", Collections.singletonList(Integer.toString(fullSyncPeriod)));
+ config.put("changedSyncPeriod", Collections.singletonList(Integer.toString(changedSyncPeriod)));
+ config.put("lastSync", Collections.singletonList(Integer.toString(lastSync)));
+
+ BasicDBObject fedConfig = (BasicDBObject)fedProvider.get("config");
+ if (fedConfig != null) {
+ for (Map.Entry attr : new HashSet<>(fedConfig.entrySet())) {
+ String attrName = attr.getKey();
+ String attrValue = attr.getValue().toString();
+ config.put(attrName, Collections.singletonList(attrValue));
+
+ }
+ }
+
+
+ component.put("config", config);
+
+ componentEntities.add(component);
+
+ }
+ }
+ Iterator