KEYCLOAK-18137 Fix introduced SPI name

This commit is contained in:
vramik 2021-05-18 09:59:31 +02:00 committed by Hynek Mlnařík
parent 008fa8c2b1
commit 4d776cd780
18 changed files with 46 additions and 45 deletions

View file

@ -21,8 +21,8 @@ embed-server
/subsystem=keycloak-server/spi=group:add(default-provider=map)
/subsystem=keycloak-server/spi=realm:add(default-provider=map)
/subsystem=keycloak-server/spi=role:add(default-provider=map)
/subsystem=keycloak-server/spi=serverInfo:add(default-provider=map)
/subsystem=keycloak-server/spi=serverInfo/provider=map:add(enabled=true,properties={resourcesVersionSeed=1JZ379bzyOCFA})
/subsystem=keycloak-server/spi=deploymentState:add(default-provider=map)
/subsystem=keycloak-server/spi=deploymentState/provider=map:add(enabled=true,properties={resourcesVersionSeed=1JZ379bzyOCFA})
/subsystem=keycloak-server/spi=user:add(default-provider=map)
## For dev and single-node purposes, these are set to "map".

View file

@ -22,12 +22,12 @@ import org.keycloak.Config;
import org.keycloak.connections.jpa.JpaConnectionProvider;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.ServerInfoProvider;
import org.keycloak.models.ServerInfoProviderFactory;
import static org.keycloak.models.jpa.JpaRealmProviderFactory.PROVIDER_ID;
import static org.keycloak.models.jpa.JpaRealmProviderFactory.PROVIDER_PRIORITY;
import org.keycloak.models.DeploymentStateProvider;
import org.keycloak.models.DeploymentStateProviderFactory;
public class JpaServerInfoProviderFactory implements ServerInfoProviderFactory {
public class JpaDeploymentStateProviderFactory implements DeploymentStateProviderFactory {
@Override
public void init(Config.Scope config) {
@ -43,7 +43,7 @@ public class JpaServerInfoProviderFactory implements ServerInfoProviderFactory {
}
@Override
public ServerInfoProvider create(KeycloakSession session) {
public DeploymentStateProvider create(KeycloakSession session) {
EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();
return new JpaRealmProvider(session, em, null);
}

View file

@ -48,6 +48,7 @@ import org.keycloak.models.ClientModel;
import org.keycloak.models.ClientProvider;
import org.keycloak.models.ClientScopeModel;
import org.keycloak.models.ClientScopeProvider;
import org.keycloak.models.DeploymentStateProvider;
import org.keycloak.models.GroupModel;
import org.keycloak.models.GroupProvider;
import org.keycloak.models.KeycloakSession;
@ -59,10 +60,8 @@ import org.keycloak.models.RoleContainerModel;
import org.keycloak.models.RoleContainerModel.RoleRemovedEvent;
import org.keycloak.models.RoleModel;
import org.keycloak.models.RoleProvider;
import org.keycloak.models.ServerInfoProvider;
import org.keycloak.models.jpa.entities.ClientAttributeEntity;
import org.keycloak.models.jpa.entities.ClientEntity;
import org.keycloak.models.jpa.entities.ClientInitialAccessEntity;
import org.keycloak.models.jpa.entities.ClientScopeClientMappingEntity;
import org.keycloak.models.jpa.entities.ClientScopeEntity;
import org.keycloak.models.jpa.entities.GroupEntity;
@ -76,7 +75,7 @@ import org.keycloak.models.utils.KeycloakModelUtils;
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientScopeProvider, GroupProvider, RoleProvider, ServerInfoProvider {
public class JpaRealmProvider implements RealmProvider, ClientProvider, ClientScopeProvider, GroupProvider, RoleProvider, DeploymentStateProvider {
protected static final Logger logger = Logger.getLogger(JpaRealmProvider.class);
private final KeycloakSession session;
protected EntityManager em;

View file

@ -15,4 +15,4 @@
# limitations under the License.
#
org.keycloak.models.jpa.JpaServerInfoProviderFactory
org.keycloak.models.jpa.JpaDeploymentStateProviderFactory

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.keycloak.models.map.serverinfo;
package org.keycloak.models.map.deploymentState;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -29,18 +29,19 @@ import org.keycloak.migration.MigrationModel;
import org.keycloak.migration.ModelVersion;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.ServerInfoProvider;
import org.keycloak.models.ServerInfoProviderFactory;
import org.keycloak.models.DeploymentStateProvider;
import org.keycloak.models.DeploymentStateProviderFactory;
import org.keycloak.models.DeploymentStateSpi;
import org.keycloak.provider.EnvironmentDependentProviderFactory;
public class MapServerInfoProviderFactory implements ServerInfoProviderFactory, EnvironmentDependentProviderFactory {
public class MapDeploymentStateProviderFactory implements DeploymentStateProviderFactory, EnvironmentDependentProviderFactory {
public static final String PROVIDER_ID = "map";
private static final String RESOURCES_VERSION_SEED = "resourcesVersionSeed";
@Override
public ServerInfoProvider create(KeycloakSession session) {
public DeploymentStateProvider create(KeycloakSession session) {
return INSTANCE;
}
@ -48,7 +49,8 @@ public class MapServerInfoProviderFactory implements ServerInfoProviderFactory,
public void init(Config.Scope config) {
String seed = config.get(RESOURCES_VERSION_SEED);
if (seed == null) {
Logger.getLogger(ServerInfoProviderFactory.class).warnf("It is recommended to set '%s' property in the %s provider config of serverInfo SPI", RESOURCES_VERSION_SEED, PROVIDER_ID);
Logger.getLogger(DeploymentStateProviderFactory.class)
.warnf("It is recommended to set '%s' property in the %s provider config of %s SPI", RESOURCES_VERSION_SEED, PROVIDER_ID, DeploymentStateSpi.NAME);
//generate random string for this installation
seed = RandomString.randomCode(10);
}
@ -79,7 +81,7 @@ public class MapServerInfoProviderFactory implements ServerInfoProviderFactory,
return Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE);
}
private static final ServerInfoProvider INSTANCE = new ServerInfoProvider() {
private static final DeploymentStateProvider INSTANCE = new DeploymentStateProvider() {
private final MigrationModel INSTANCE = new MigrationModel() {
@Override

View file

@ -15,4 +15,4 @@
# limitations under the License.
#
org.keycloak.models.map.serverinfo.MapServerInfoProviderFactory
org.keycloak.models.map.deploymentState.MapDeploymentStateProviderFactory

View file

@ -53,9 +53,9 @@ import org.keycloak.migration.migrators.MigrateTo9_0_0;
import org.keycloak.migration.migrators.MigrateTo9_0_4;
import org.keycloak.migration.migrators.Migration;
import org.keycloak.models.Constants;
import org.keycloak.models.DeploymentStateProvider;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.ServerInfoProvider;
import org.keycloak.representations.idm.RealmRepresentation;
/**
@ -100,7 +100,7 @@ public class MigrationModelManager {
public static void migrate(KeycloakSession session) {
session.setAttribute(Constants.STORAGE_BATCH_ENABLED, Boolean.getBoolean("keycloak.migration.batch-enabled"));
session.setAttribute(Constants.STORAGE_BATCH_SIZE, Integer.getInteger("keycloak.migration.batch-size"));
MigrationModel model = session.getProvider(ServerInfoProvider.class).getMigrationModel();
MigrationModel model = session.getProvider(DeploymentStateProvider.class).getMigrationModel();
ModelVersion currentVersion = new ModelVersion(Version.VERSION_KEYCLOAK);
ModelVersion latestUpdate = migrations[migrations.length-1].getVersion();

View file

@ -20,7 +20,7 @@ package org.keycloak.models;
import org.keycloak.migration.MigrationModel;
import org.keycloak.provider.Provider;
public interface ServerInfoProvider extends Provider {
public interface DeploymentStateProvider extends Provider {
MigrationModel getMigrationModel();

View file

@ -19,5 +19,5 @@ package org.keycloak.models;
import org.keycloak.provider.ProviderFactory;
public interface ServerInfoProviderFactory extends ProviderFactory<ServerInfoProvider> {
public interface DeploymentStateProviderFactory extends ProviderFactory<DeploymentStateProvider> {
}

View file

@ -21,9 +21,9 @@ import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.provider.Spi;
public class ServerInfoSpi implements Spi {
public class DeploymentStateSpi implements Spi {
public static final String NAME = "serverInfo";
public static final String NAME = "deploymentState";
@Override
public boolean isInternal() {
@ -37,12 +37,12 @@ public class ServerInfoSpi implements Spi {
@Override
public Class<? extends Provider> getProviderClass() {
return ServerInfoProvider.class;
return DeploymentStateProvider.class;
}
@Override
public Class<? extends ProviderFactory> getProviderFactoryClass() {
return ServerInfoProviderFactory.class;
return DeploymentStateProviderFactory.class;
}
}

View file

@ -24,7 +24,7 @@ org.keycloak.models.ClientScopeSpi
org.keycloak.models.GroupSpi
org.keycloak.models.RealmSpi
org.keycloak.models.RoleSpi
org.keycloak.models.ServerInfoSpi
org.keycloak.models.DeploymentStateSpi
org.keycloak.models.ActionTokenStoreSpi
org.keycloak.models.CodeToTokenStoreSpi
org.keycloak.models.OAuth2DeviceTokenStoreSpi

View file

@ -1194,7 +1194,7 @@
<keycloak.group.provider>map</keycloak.group.provider>
<keycloak.role.provider>map</keycloak.role.provider>
<keycloak.user.provider>map</keycloak.user.provider>
<keycloak.serverInfo.provider>map</keycloak.serverInfo.provider>
<keycloak.deploymentState.provider>map</keycloak.deploymentState.provider>
<keycloak.authSession.provider>map</keycloak.authSession.provider>
<keycloak.userSession.provider>map</keycloak.userSession.provider>
<keycloak.loginFailure.provider>map</keycloak.loginFailure.provider>

View file

@ -36,8 +36,8 @@
"event-queue": {}
},
"serverInfo": {
"provider": "${keycloak.serverInfo.provider:jpa}",
"deploymentState": {
"provider": "${keycloak.deploymentState.provider:jpa}",
"map": {
"resourcesVersionSeed": "1JZ379bzyOCFA"
}

View file

@ -35,8 +35,7 @@ import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RealmSpi;
import org.keycloak.models.RoleSpi;
import org.keycloak.models.ServerInfoProviderFactory;
import org.keycloak.models.ServerInfoSpi;
import org.keycloak.models.DeploymentStateSpi;
import org.keycloak.models.UserLoginFailureSpi;
import org.keycloak.models.UserSessionSpi;
import org.keycloak.models.UserSpi;
@ -83,6 +82,7 @@ import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.keycloak.models.DeploymentStateProviderFactory;
/**
* Base of testcases that operate on session level. The tests derived from this class
@ -203,7 +203,7 @@ public abstract class KeycloakModelTest {
.add(GroupSpi.class)
.add(RealmSpi.class)
.add(RoleSpi.class)
.add(ServerInfoSpi.class)
.add(DeploymentStateSpi.class)
.add(StoreFactorySpi.class)
.add(TimerSpi.class)
.add(UserLoginFailureSpi.class)
@ -215,7 +215,7 @@ public abstract class KeycloakModelTest {
.add(ComponentFactoryProviderFactory.class)
.add(DefaultAuthorizationProviderFactory.class)
.add(DefaultExecutorsProviderFactory.class)
.add(ServerInfoProviderFactory.class)
.add(DeploymentStateProviderFactory.class)
.build();
protected static final List<KeycloakModelParameters> MODEL_PARAMETERS;

View file

@ -31,8 +31,8 @@ import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RealmProvider;
import org.keycloak.models.ServerInfoProvider;
import org.keycloak.models.jpa.entities.MigrationModelEntity;
import org.keycloak.models.DeploymentStateProvider;
@RequireProvider(value=RealmProvider.class, only="jpa")
@RequireProvider(value=ClientProvider.class, only="jpa")
@ -67,13 +67,13 @@ public class MigrationModelTest extends KeycloakModelTest {
Assert.assertTrue(l.get(0).getId().matches("[\\da-z]{5}"));
Assert.assertEquals(currentVersion, l.get(0).getVersion());
MigrationModel m = session.getProvider(ServerInfoProvider.class).getMigrationModel();
MigrationModel m = session.getProvider(DeploymentStateProvider.class).getMigrationModel();
Assert.assertEquals(currentVersion, m.getStoredVersion());
Assert.assertEquals(m.getResourcesTag(), l.get(0).getId());
Time.setOffset(-60000);
session.getProvider(ServerInfoProvider.class).getMigrationModel().setStoredVersion("6.0.0");
session.getProvider(DeploymentStateProvider.class).getMigrationModel().setStoredVersion("6.0.0");
em.flush();
Time.setOffset(0);
@ -88,7 +88,7 @@ public class MigrationModelTest extends KeycloakModelTest {
Assert.assertTrue(l.get(1).getId().matches("[\\da-z]{5}"));
Assert.assertEquals("6.0.0", l.get(1).getVersion());
m = session.getProvider(ServerInfoProvider.class).getMigrationModel();
m = session.getProvider(DeploymentStateProvider.class).getMigrationModel();
Assert.assertEquals(l.get(0).getId(), m.getResourcesTag());
Assert.assertEquals(currentVersion, m.getStoredVersion());

View file

@ -104,7 +104,7 @@ public class Jpa extends KeycloakModelParameters {
.spi("role").defaultProvider("jpa")
.spi("user").defaultProvider("jpa")
.spi("realm").defaultProvider("jpa")
.spi("serverInfo").defaultProvider("jpa")
.spi("deploymentState").defaultProvider("jpa")
;
}
}

View file

@ -17,7 +17,7 @@
package org.keycloak.testsuite.model.parameters;
import org.keycloak.authorization.store.StoreFactorySpi;
import org.keycloak.models.ServerInfoSpi;
import org.keycloak.models.DeploymentStateSpi;
import org.keycloak.models.UserLoginFailureSpi;
import org.keycloak.models.UserSessionSpi;
import org.keycloak.models.map.authSession.MapRootAuthenticationSessionProviderFactory;
@ -30,7 +30,7 @@ import org.keycloak.models.map.clientscope.MapClientScopeProviderFactory;
import org.keycloak.models.map.group.MapGroupProviderFactory;
import org.keycloak.models.map.realm.MapRealmProviderFactory;
import org.keycloak.models.map.role.MapRoleProviderFactory;
import org.keycloak.models.map.serverinfo.MapServerInfoProviderFactory;
import org.keycloak.models.map.deploymentState.MapDeploymentStateProviderFactory;
import org.keycloak.models.map.storage.MapStorageProviderFactory;
import org.keycloak.models.map.storage.MapStorageSpi;
import org.keycloak.models.map.user.MapUserProviderFactory;
@ -60,7 +60,7 @@ public class Map extends KeycloakModelParameters {
.add(MapRealmProviderFactory.class)
.add(MapRoleProviderFactory.class)
.add(MapRootAuthenticationSessionProviderFactory.class)
.add(MapServerInfoProviderFactory.class)
.add(MapDeploymentStateProviderFactory.class)
.add(MapUserProviderFactory.class)
.add(MapUserSessionProviderFactory.class)
.add(MapUserLoginFailureProviderFactory.class)
@ -80,7 +80,7 @@ public class Map extends KeycloakModelParameters {
.spi("group").defaultProvider(MapGroupProviderFactory.PROVIDER_ID)
.spi("realm").defaultProvider(MapRealmProviderFactory.PROVIDER_ID)
.spi("role").defaultProvider(MapRoleProviderFactory.PROVIDER_ID)
.spi(ServerInfoSpi.NAME).defaultProvider(MapServerInfoProviderFactory.PROVIDER_ID)
.spi(DeploymentStateSpi.NAME).defaultProvider(MapDeploymentStateProviderFactory.PROVIDER_ID)
.spi(StoreFactorySpi.NAME).defaultProvider(MapAuthorizationStoreFactory.PROVIDER_ID)
.spi("user").defaultProvider(MapUserProviderFactory.PROVIDER_ID)
.spi(UserSessionSpi.NAME).defaultProvider(MapUserSessionProviderFactory.PROVIDER_ID)

View file

@ -14,8 +14,8 @@
"provider": "${keycloak.eventsStore.provider:}"
},
"serverInfo": {
"provider": "${keycloak.serverInfo.provider:jpa}",
"deploymentState": {
"provider": "${keycloak.deploymentState.provider:jpa}",
"map": {
"resourcesVersionSeed": "1JZ379bzyOCFA"
}