diff --git a/common/src/main/java/org/keycloak/common/Profile.java b/common/src/main/java/org/keycloak/common/Profile.java index 0f0d09e1af..86bc94e1bf 100755 --- a/common/src/main/java/org/keycloak/common/Profile.java +++ b/common/src/main/java/org/keycloak/common/Profile.java @@ -55,7 +55,8 @@ public class Profile { UPLOAD_SCRIPTS(DEPRECATED), WEB_AUTHN(Type.DEFAULT, Type.PREVIEW), CLIENT_POLICIES(Type.PREVIEW), - CIBA(Type.PREVIEW); + CIBA(Type.PREVIEW), + MAP_STORAGE(Type.EXPERIMENTAL); private Type typeProject; private Type typeProduct; diff --git a/common/src/test/java/org/keycloak/common/ProfileTest.java b/common/src/test/java/org/keycloak/common/ProfileTest.java index 6ded20aecf..cb7b68df50 100644 --- a/common/src/test/java/org/keycloak/common/ProfileTest.java +++ b/common/src/test/java/org/keycloak/common/ProfileTest.java @@ -21,7 +21,7 @@ public class ProfileTest { @Test public void checkDefaultsKeycloak() { Assert.assertEquals("community", Profile.getName()); - assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA); + assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA, Profile.Feature.MAP_STORAGE); assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA); assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS); @@ -37,7 +37,7 @@ public class ProfileTest { Profile.init(); Assert.assertEquals("product", Profile.getName()); - assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.WEB_AUTHN, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA); + assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.WEB_AUTHN, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA, Profile.Feature.MAP_STORAGE); assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.WEB_AUTHN, Profile.Feature.CLIENT_POLICIES, Profile.Feature.CIBA); assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS); diff --git a/distribution/server-dist/src/main/docs/examples/map-storage-concurrenthashmap.cli b/distribution/server-dist/src/main/docs/examples/map-storage-concurrenthashmap.cli index edcc742199..863c658075 100644 --- a/distribution/server-dist/src/main/docs/examples/map-storage-concurrenthashmap.cli +++ b/distribution/server-dist/src/main/docs/examples/map-storage-concurrenthashmap.cli @@ -13,6 +13,8 @@ embed-server +/system-property=keycloak.profile.feature.map_storage:add(value=enabled) + /subsystem=keycloak-server/spi=authorizationPersister:add(default-provider=map) /subsystem=keycloak-server/spi=client:add(default-provider=map) /subsystem=keycloak-server/spi=clientScope:add(default-provider=map) diff --git a/model/map/src/main/java/org/keycloak/models/map/authorization/MapAuthorizationStoreFactory.java b/model/map/src/main/java/org/keycloak/models/map/authorization/MapAuthorizationStoreFactory.java index 0c6c12990c..f5420da2a3 100644 --- a/model/map/src/main/java/org/keycloak/models/map/authorization/MapAuthorizationStoreFactory.java +++ b/model/map/src/main/java/org/keycloak/models/map/authorization/MapAuthorizationStoreFactory.java @@ -26,6 +26,7 @@ import org.keycloak.authorization.model.ResourceServer; import org.keycloak.authorization.model.Scope; import org.keycloak.authorization.store.AuthorizationStoreFactory; import org.keycloak.authorization.store.StoreFactory; +import org.keycloak.common.Profile; import org.keycloak.component.AmphibianProviderFactory; import org.keycloak.models.KeycloakSession; import org.keycloak.models.map.authorization.entity.MapPermissionTicketEntity; @@ -38,12 +39,13 @@ import org.keycloak.models.map.storage.MapStorage; import org.keycloak.models.map.storage.MapStorageProvider; import org.keycloak.models.map.storage.MapStorageProviderFactory; import org.keycloak.models.map.storage.MapStorageSpi; +import org.keycloak.provider.EnvironmentDependentProviderFactory; import static org.keycloak.models.utils.KeycloakModelUtils.getComponentFactory; /** * @author mhajas */ -public class MapAuthorizationStoreFactory implements AmphibianProviderFactory, AuthorizationStoreFactory { +public class MapAuthorizationStoreFactory implements AmphibianProviderFactory, AuthorizationStoreFactory, EnvironmentDependentProviderFactory { public static final String PROVIDER_ID = AbstractMapProviderFactory.PROVIDER_ID; @@ -98,4 +100,9 @@ public class MapAuthorizationStoreFactory implements AmphibianProviderFactory public String getHelpText() { return "Authorization store provider"; } + + @Override + public boolean isSupported() { + return Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE); + } } diff --git a/model/map/src/main/java/org/keycloak/models/map/common/AbstractMapProviderFactory.java b/model/map/src/main/java/org/keycloak/models/map/common/AbstractMapProviderFactory.java index 565dd4d852..ed5f0078af 100644 --- a/model/map/src/main/java/org/keycloak/models/map/common/AbstractMapProviderFactory.java +++ b/model/map/src/main/java/org/keycloak/models/map/common/AbstractMapProviderFactory.java @@ -17,6 +17,7 @@ package org.keycloak.models.map.common; import org.keycloak.Config.Scope; +import org.keycloak.common.Profile; import org.keycloak.models.KeycloakSession; import org.keycloak.models.map.storage.MapStorage; import org.keycloak.models.map.storage.MapStorageProvider; @@ -24,6 +25,7 @@ import org.keycloak.models.map.storage.MapStorageProviderFactory; import org.keycloak.models.map.storage.MapStorageSpi; import org.keycloak.component.AmphibianProviderFactory; import org.keycloak.models.KeycloakSessionFactory; +import org.keycloak.provider.EnvironmentDependentProviderFactory; import org.keycloak.provider.Provider; import org.jboss.logging.Logger; import static org.keycloak.models.utils.KeycloakModelUtils.getComponentFactory; @@ -32,7 +34,7 @@ import static org.keycloak.models.utils.KeycloakModelUtils.getComponentFactory; * * @author hmlnarik */ -public abstract class AbstractMapProviderFactory, M> implements AmphibianProviderFactory { +public abstract class AbstractMapProviderFactory, M> implements AmphibianProviderFactory, EnvironmentDependentProviderFactory { public static final String PROVIDER_ID = "map"; @@ -74,4 +76,9 @@ public abstract class AbstractMapProviderFactory,MapStorageProviderFactory { +public class ConcurrentHashMapStorageProviderFactory implements AmphibianProviderFactory, MapStorageProviderFactory, EnvironmentDependentProviderFactory { public static final String PROVIDER_ID = "concurrenthashmap"; @@ -262,4 +264,8 @@ public class ConcurrentHashMapStorageProviderFactory implements AmphibianProvide return Collections.emptyList(); } + @Override + public boolean isSupported() { + return Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE); + } } diff --git a/model/map/src/main/java/org/keycloak/models/map/userSession/MapUserSessionProviderFactory.java b/model/map/src/main/java/org/keycloak/models/map/userSession/MapUserSessionProviderFactory.java index 8eeaf49082..88e8037c7a 100644 --- a/model/map/src/main/java/org/keycloak/models/map/userSession/MapUserSessionProviderFactory.java +++ b/model/map/src/main/java/org/keycloak/models/map/userSession/MapUserSessionProviderFactory.java @@ -17,6 +17,7 @@ package org.keycloak.models.map.userSession; import org.keycloak.Config.Scope; +import org.keycloak.common.Profile; import org.keycloak.component.AmphibianProviderFactory; import org.keycloak.models.AuthenticatedClientSessionModel; import org.keycloak.models.KeycloakSession; @@ -31,6 +32,7 @@ import org.keycloak.models.map.storage.MapStorageProvider; import org.keycloak.models.map.storage.MapStorageProviderFactory; import org.keycloak.models.map.storage.MapStorageSpi; +import org.keycloak.provider.EnvironmentDependentProviderFactory; import org.keycloak.provider.ProviderEvent; import org.keycloak.provider.ProviderEventListener; import static org.keycloak.models.utils.KeycloakModelUtils.getComponentFactory; @@ -38,7 +40,7 @@ import static org.keycloak.models.utils.KeycloakModelUtils.getComponentFactory; /** * @author Martin Kanis */ -public class MapUserSessionProviderFactory implements AmphibianProviderFactory, UserSessionProviderFactory, ProviderEventListener { +public class MapUserSessionProviderFactory implements AmphibianProviderFactory, UserSessionProviderFactory, ProviderEventListener, EnvironmentDependentProviderFactory { public static final String CONFIG_STORAGE_USER_SESSIONS = "storage-user-sessions"; public static final String CONFIG_STORAGE_CLIENT_SESSIONS = "storage-client-sessions"; @@ -105,4 +107,9 @@ public class MapUserSessionProviderFactory implements AmphibianProviderF provider.removeUserSessions(userRemovedEvent.getRealm(), userRemovedEvent.getUser()); } } + + @Override + public boolean isSupported() { + return Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE); + } } diff --git a/testsuite/integration-arquillian/tests/base/pom.xml b/testsuite/integration-arquillian/tests/base/pom.xml index 17275e9b12..31c75e6c2e 100644 --- a/testsuite/integration-arquillian/tests/base/pom.xml +++ b/testsuite/integration-arquillian/tests/base/pom.xml @@ -1185,6 +1185,8 @@ maven-surefire-plugin + enabled + concurrenthashmap map map map diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json b/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json index a51d4a56a5..bfcb82d1de 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json @@ -80,7 +80,7 @@ }, "mapStorage": { - "provider": "${keycloak.mapStorage.provider:concurrenthashmap}", + "provider": "${keycloak.mapStorage.provider:}", "concurrenthashmap": { "dir": "${project.build.directory:target}", "keyType.realms": "string", diff --git a/testsuite/model/pom.xml b/testsuite/model/pom.xml index c5a3b4770c..11791f870f 100644 --- a/testsuite/model/pom.xml +++ b/testsuite/model/pom.xml @@ -24,6 +24,7 @@ h2 ${h2.version} file:${project.build.directory}/dependency/log4j.properties + disabled @@ -108,6 +109,7 @@ ${keycloak.connectionsJpa.password} ${keycloak.connectionsJpa.url} file:${project.build.directory}/test-classes/log4j.properties + ${keycloak.profile.feature.map_storage} @@ -194,6 +196,7 @@ map+infinispan + enabled Infinispan,Jpa,Map,ConcurrentHashMapStorage @@ -201,6 +204,7 @@ map + enabled Jpa,Map,ConcurrentHashMapStorage diff --git a/testsuite/utils/src/main/resources/META-INF/keycloak-server.json b/testsuite/utils/src/main/resources/META-INF/keycloak-server.json index c66523adda..c95a3fd8ce 100755 --- a/testsuite/utils/src/main/resources/META-INF/keycloak-server.json +++ b/testsuite/utils/src/main/resources/META-INF/keycloak-server.json @@ -54,7 +54,7 @@ }, "mapStorage": { - "provider": "${keycloak.mapStorage.provider:concurrenthashmap}", + "provider": "${keycloak.mapStorage.provider:}", "concurrenthashmap": { "dir": "${project.build.directory:target}" }