Merge pull request #3623 from patriot1burke/master

KEYCLOAK-3973
This commit is contained in:
Bill Burke 2016-12-07 17:00:52 -05:00 committed by GitHub
commit 379d5e3228
6 changed files with 25 additions and 13 deletions

View file

@ -21,7 +21,6 @@ import liquibase.statement.core.DeleteStatement;
import liquibase.statement.core.InsertStatement; import liquibase.statement.core.InsertStatement;
import liquibase.structure.core.Table; import liquibase.structure.core.Table;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.models.LDAPConstants;
import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.storage.UserStorageProvider; import org.keycloak.storage.UserStorageProvider;
@ -57,7 +56,7 @@ public abstract class AbstractUserFedToComponent extends CustomKeycloakTask {
.addColumnValue("REALM_ID", realmId) .addColumnValue("REALM_ID", realmId)
.addColumnValue("PARENT_ID", realmId) .addColumnValue("PARENT_ID", realmId)
.addColumnValue("NAME", displayName) .addColumnValue("NAME", displayName)
.addColumnValue("PROVIDER_ID", LDAPConstants.LDAP_PROVIDER) .addColumnValue("PROVIDER_ID", providerId)
.addColumnValue("PROVIDER_TYPE", UserStorageProvider.class.getName()); .addColumnValue("PROVIDER_TYPE", UserStorageProvider.class.getName());
statements.add(insertComponent); statements.add(insertComponent);

View file

@ -21,12 +21,15 @@ import liquibase.exception.CustomChangeException;
import liquibase.statement.core.InsertStatement; import liquibase.statement.core.InsertStatement;
import liquibase.structure.core.Table; import liquibase.structure.core.Table;
import org.keycloak.keys.KeyProvider; import org.keycloak.keys.KeyProvider;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.LDAPConstants; import org.keycloak.models.LDAPConstants;
import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.storage.UserStorageProvider; import org.keycloak.storage.UserStorageProvider;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List;
/** /**
* @author <a href="mailto:bburke@redhat.com">Bill Burke</a> * @author <a href="mailto:bburke@redhat.com">Bill Burke</a>
@ -35,11 +38,14 @@ public class MigrateUserFedToComponent extends AbstractUserFedToComponent {
@Override @Override
protected void generateStatementsImpl() throws CustomChangeException { protected void generateStatementsImpl() throws CustomChangeException {
convertFedProviderToComponent("kerberos", null); List<ProviderFactory> factories = kcSession.getKeycloakSessionFactory().getProviderFactories(UserStorageProvider.class);
for (ProviderFactory factory : factories) {
convertFedProviderToComponent(factory.getId(), null);
}
} }
@Override @Override
protected String getTaskId() { protected String getTaskId() {
return "Update 2.4.1.Final"; return "Update 2.5.0.Final";
} }
} }

View file

@ -18,11 +18,11 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="bburke@redhat.com" id="2.4.1"> <changeSet author="bburke@redhat.com" id="2.5.0">
<customChange class="org.keycloak.connections.jpa.updater.liquibase.custom.MigrateUserFedToComponent"/> <customChange class="org.keycloak.connections.jpa.updater.liquibase.custom.MigrateUserFedToComponent"/>
</changeSet> </changeSet>
<changeSet author="hmlnarik@redhat.com" id="2.4.1-unicode-oracle"> <changeSet author="hmlnarik@redhat.com" id="2.5.0-unicode-oracle">
<preConditions onSqlOutput="TEST" onFail="MARK_RAN"> <preConditions onSqlOutput="TEST" onFail="MARK_RAN">
<dbms type="oracle" /> <dbms type="oracle" />
</preConditions> </preConditions>
@ -59,7 +59,7 @@
<modifyDataType tableName="KEYCLOAK_ROLE" columnName="DESCRIPTION" newDataType="NVARCHAR(255)"/> <modifyDataType tableName="KEYCLOAK_ROLE" columnName="DESCRIPTION" newDataType="NVARCHAR(255)"/>
</changeSet> </changeSet>
<changeSet author="hmlnarik@redhat.com" id="2.4.1-unicode-other-dbs"> <changeSet author="hmlnarik@redhat.com" id="2.5.0-unicode-other-dbs">
<preConditions onSqlOutput="TEST" onFail="MARK_RAN"> <preConditions onSqlOutput="TEST" onFail="MARK_RAN">
<not> <not>
<dbms type="oracle" /> <dbms type="oracle" />

View file

@ -44,5 +44,5 @@
<include file="META-INF/jpa-changelog-2.2.0.xml"/> <include file="META-INF/jpa-changelog-2.2.0.xml"/>
<include file="META-INF/jpa-changelog-2.3.0.xml"/> <include file="META-INF/jpa-changelog-2.3.0.xml"/>
<include file="META-INF/jpa-changelog-2.4.0.xml"/> <include file="META-INF/jpa-changelog-2.4.0.xml"/>
<include file="META-INF/jpa-changelog-2.4.1.xml"/> <include file="META-INF/jpa-changelog-2.5.0.xml"/>
</databaseChangeLog> </databaseChangeLog>

View file

@ -35,7 +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.Update1_9_2;
import org.keycloak.connections.mongo.updater.impl.updates.Update2_3_0; 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_0;
import org.keycloak.connections.mongo.updater.impl.updates.Update2_4_1; import org.keycloak.connections.mongo.updater.impl.updates.Update2_5_0;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import java.util.Date; import java.util.Date;
@ -63,7 +63,7 @@ public class DefaultMongoUpdaterProvider implements MongoUpdaterProvider {
Update1_9_2.class, Update1_9_2.class,
Update2_3_0.class, Update2_3_0.class,
Update2_4_0.class, Update2_4_0.class,
Update2_4_1.class Update2_5_0.class
}; };
@Override @Override

View file

@ -19,20 +19,27 @@ package org.keycloak.connections.mongo.updater.impl.updates;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import org.keycloak.models.LDAPConstants; import org.keycloak.models.LDAPConstants;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.storage.UserStorageProvider;
import java.util.List;
/** /**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/ */
public class Update2_4_1 extends AbstractMigrateUserFedToComponent { public class Update2_5_0 extends AbstractMigrateUserFedToComponent {
@Override @Override
public String getId() { public String getId() {
return "2.4.1"; return "2.5.0";
} }
@Override @Override
public void update(KeycloakSession session) { public void update(KeycloakSession session) {
portUserFedToComponent("kerberos"); List<ProviderFactory> factories = session.getKeycloakSessionFactory().getProviderFactories(UserStorageProvider.class);
for (ProviderFactory factory : factories) {
portUserFedToComponent(factory.getId());
}
} }
} }