diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json b/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json index ee56f78dc8..6ee6adb848 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json @@ -26,14 +26,6 @@ "provider" : "infinispan" }, - "realmCache": { - "provider": "infinispan" - }, - - "userCache": { - "provider": "infinispan" - }, - "timer": { "provider": "basic" }, @@ -48,18 +40,6 @@ } }, - "login": { - "provider": "freemarker" - }, - - "account": { - "provider": "freemarker" - }, - - "email": { - "provider": "freemarker" - }, - "scheduled": { "interval": 900 }, diff --git a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml index 8b4d6e53b0..5e99637862 100755 --- a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml +++ b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml @@ -82,13 +82,16 @@
Migrating to 1.5.0.Final - Infinispan set to default cache and user session providers + Realm and User cache providers - Infinispan is now the default cache and user session provider. + Infinispan is now the default realm and user cache provider. In non-clustered mode a local Infinispan cache is used. We've also removed our + custom in-memory cache and the no cache providers. If you have realmCache or userCache set in keycloak-server.json to mem or none please + remove these. As Infinispan is the only provider there's no longer any need for the realmCache and userCache objects so these can + be removed. - Mem user session provider + User Session provider The mem user session provider has been removed. Instead the Infinispan user session provider with a local cache should be used. diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java similarity index 97% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java index 5c6f382775..97914006dc 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java @@ -1,17 +1,11 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; -import org.keycloak.models.ClientModel; -import org.keycloak.models.ProtocolMapperModel; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleContainerModel; -import org.keycloak.models.RoleModel; +import org.keycloak.models.*; +import org.keycloak.models.cache.CacheRealmProvider; +import org.keycloak.models.cache.RealmCache; import org.keycloak.models.cache.entities.CachedClient; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheRealmProvider.java old mode 100755 new mode 100644 similarity index 92% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheRealmProvider.java index eca2572d00..b84079f25f --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheRealmProvider.java @@ -1,24 +1,11 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; import org.keycloak.migration.MigrationModel; -import org.keycloak.models.ClientModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakTransaction; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RealmProvider; -import org.keycloak.models.RoleModel; -import org.keycloak.models.cache.entities.CachedClient; -import org.keycloak.models.cache.entities.CachedClientRole; -import org.keycloak.models.cache.entities.CachedRealm; -import org.keycloak.models.cache.entities.CachedRealmRole; -import org.keycloak.models.cache.entities.CachedRole; +import org.keycloak.models.*; +import org.keycloak.models.cache.*; +import org.keycloak.models.cache.entities.*; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheUserProvider.java old mode 100755 new mode 100644 similarity index 94% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheUserProvider.java index 0702553741..a34d70ac45 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultCacheUserProvider.java @@ -1,24 +1,11 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; -import org.keycloak.models.ClientModel; -import org.keycloak.models.CredentialValidationOutput; -import org.keycloak.models.FederatedIdentityModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakTransaction; -import org.keycloak.models.ProtocolMapperModel; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleModel; -import org.keycloak.models.UserCredentialModel; -import org.keycloak.models.UserFederationProviderModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserProvider; +import org.keycloak.models.*; +import org.keycloak.models.cache.CacheUserProvider; +import org.keycloak.models.cache.UserCache; import org.keycloak.models.cache.entities.CachedUser; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke diff --git a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheRealmProviderFactory.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheRealmProviderFactory.java index dc571e762d..4b96241fbe 100755 --- a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheRealmProviderFactory.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheRealmProviderFactory.java @@ -7,7 +7,6 @@ import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.cache.CacheRealmProvider; import org.keycloak.models.cache.CacheRealmProviderFactory; -import org.keycloak.models.cache.DefaultCacheRealmProvider; import org.keycloak.models.cache.RealmCache; import java.util.concurrent.ConcurrentHashMap; diff --git a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheUserProviderFactory.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheUserProviderFactory.java index 30f4f43889..b046efc9c1 100755 --- a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheUserProviderFactory.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanCacheUserProviderFactory.java @@ -12,7 +12,6 @@ import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.cache.CacheUserProvider; import org.keycloak.models.cache.CacheUserProviderFactory; -import org.keycloak.models.cache.DefaultCacheUserProvider; import org.keycloak.models.cache.entities.CachedUser; import java.util.concurrent.ConcurrentHashMap; diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java similarity index 97% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java index 7526f50122..cbffaa08b9 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java @@ -1,21 +1,10 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; import org.keycloak.Config; import org.keycloak.enums.SslRequired; -import org.keycloak.models.AuthenticationExecutionModel; -import org.keycloak.models.AuthenticationFlowModel; -import org.keycloak.models.AuthenticatorConfigModel; -import org.keycloak.models.ClientModel; -import org.keycloak.models.IdentityProviderMapperModel; -import org.keycloak.models.IdentityProviderModel; -import org.keycloak.models.OTPPolicy; -import org.keycloak.models.PasswordPolicy; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RequiredActionProviderModel; -import org.keycloak.models.RequiredCredentialModel; -import org.keycloak.models.RoleModel; -import org.keycloak.models.UserFederationMapperModel; -import org.keycloak.models.UserFederationProviderModel; +import org.keycloak.models.*; +import org.keycloak.models.cache.CacheRealmProvider; +import org.keycloak.models.cache.RealmCache; import org.keycloak.models.cache.entities.CachedRealm; import org.keycloak.models.utils.KeycloakModelUtils; @@ -23,13 +12,7 @@ import java.security.Key; import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RoleAdapter.java similarity index 96% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RoleAdapter.java index 16cf5156d9..536c2ef316 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RoleAdapter.java @@ -1,8 +1,10 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleContainerModel; import org.keycloak.models.RoleModel; +import org.keycloak.models.cache.CacheRealmProvider; +import org.keycloak.models.cache.RealmCache; import org.keycloak.models.cache.entities.CachedClientRole; import org.keycloak.models.cache.entities.CachedRealmRole; import org.keycloak.models.cache.entities.CachedRole; diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java similarity index 94% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java rename to model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java index a4af54e2b7..5a74b01a35 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserAdapter.java @@ -1,22 +1,11 @@ -package org.keycloak.models.cache; +package org.keycloak.models.cache.infinispan; -import org.keycloak.models.ClientModel; -import org.keycloak.models.UserConsentModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleContainerModel; -import org.keycloak.models.RoleModel; -import org.keycloak.models.UserCredentialModel; -import org.keycloak.models.UserCredentialValueModel; -import org.keycloak.models.UserModel; +import org.keycloak.models.*; +import org.keycloak.models.cache.CacheUserProvider; import org.keycloak.models.cache.entities.CachedUser; import org.keycloak.models.utils.KeycloakModelUtils; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheRealmProviderFactory.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheRealmProviderFactory.java deleted file mode 100755 index db1faae67a..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheRealmProviderFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class MemoryCacheRealmProviderFactory implements CacheRealmProviderFactory { - protected RealmCache cache = new MemoryRealmCache(); - - @Override - public CacheRealmProvider create(KeycloakSession session) { - return new DefaultCacheRealmProvider(cache, session); - } - - @Override - public void init(Config.Scope config) { - config.get(""); - - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - - } - - @Override - public void close() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public String getId() { - return "mem"; - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheUserProviderFactory.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheUserProviderFactory.java deleted file mode 100755 index ff58e661cd..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryCacheUserProviderFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class MemoryCacheUserProviderFactory implements CacheUserProviderFactory { - protected MemoryUserCache cache; - - @Override - public CacheUserProvider create(KeycloakSession session) { - return new DefaultCacheUserProvider(cache, session); - } - - @Override - public void init(Config.Scope config) { - config.get(""); - cache = new MemoryUserCache(); - int size = config.getInt("maxSize", 10000); - cache.setMaxUserCacheSize(size); - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - - } - - @Override - public void close() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public String getId() { - return "mem"; - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryRealmCache.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryRealmCache.java deleted file mode 100755 index 4e6f483a27..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryRealmCache.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.models.cache.entities.CachedClient; -import org.keycloak.models.cache.entities.CachedRealm; -import org.keycloak.models.cache.entities.CachedRole; - -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class MemoryRealmCache implements RealmCache { - - protected ConcurrentHashMap realmCache = new ConcurrentHashMap(); - protected ConcurrentHashMap realmCacheByName = new ConcurrentHashMap(); - protected ConcurrentHashMap applicationCache = new ConcurrentHashMap(); - protected ConcurrentHashMap roleCache = new ConcurrentHashMap(); - protected volatile boolean enabled = true; - - @Override - public void clear() { - realmCache.clear(); - realmCacheByName.clear(); - applicationCache.clear(); - roleCache.clear(); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void setEnabled(boolean enabled) { - clear(); - this.enabled = enabled; - clear(); - } - - @Override - public CachedRealm getCachedRealm(String id) { - if (!enabled) return null; - return realmCache.get(id); - } - - @Override - public void invalidateCachedRealm(CachedRealm realm) { - realmCache.remove(realm.getId()); - realmCacheByName.remove(realm.getName()); - } - - @Override - public void invalidateCachedRealmById(String id) { - CachedRealm cached = realmCache.remove(id); - if (cached != null) realmCacheByName.remove(cached.getName()); - } - - - @Override - public void addCachedRealm(CachedRealm realm) { - if (!enabled) return; - realmCache.put(realm.getId(), realm); - realmCacheByName.put(realm.getName(), realm); - - } - - @Override - public CachedRealm getCachedRealmByName(String name) { - if (!enabled) return null; - return realmCacheByName.get(name); - } - - @Override - public CachedClient getApplication(String id) { - if (!enabled) return null; - return applicationCache.get(id); - } - - @Override - public void invalidateApplication(CachedClient app) { - applicationCache.remove(app.getId()); - } - - @Override - public void addCachedClient(CachedClient app) { - if (!enabled) return; - applicationCache.put(app.getId(), app); - } - - @Override - public void invalidateCachedApplicationById(String id) { - applicationCache.remove(id); - } - - @Override - public CachedRole getRole(String id) { - if (!enabled) return null; - return roleCache.get(id); - } - - @Override - public void invalidateRole(CachedRole role) { - roleCache.remove(role); - } - - @Override - public void invalidateRoleById(String id) { - roleCache.remove(id); - } - - @Override - public void addCachedRole(CachedRole role) { - if (!enabled) return; - roleCache.put(role.getId(), role); - } - - @Override - public void invalidateCachedRoleById(String id) { - roleCache.remove(id); - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryUserCache.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryUserCache.java deleted file mode 100755 index da7134221f..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/MemoryUserCache.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.models.cache.entities.CachedUser; - -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class MemoryUserCache implements UserCache { - - protected int maxUserCacheSize = 10000; - protected volatile boolean enabled = true; - - - protected class RealmUsers { - protected class LRUCache extends LinkedHashMap { - public LRUCache() { - super(1000, 1.1F, true); - } - - @Override - public CachedUser put(String key, CachedUser value) { - if (value.getUsername() != null) { - usersByUsername.put(value.getUsername(), value); - } - if (value.getEmail() != null) { - usersByEmail.put(value.getEmail(), value); - } - return super.put(key, value); - } - - @Override - public CachedUser remove(Object key) { - CachedUser user = super.remove(key); - if (user == null) return null; - removeUser(user); - return user; - } - - @Override - public void clear() { - super.clear(); - usersByUsername.clear(); - usersByEmail.clear(); - } - - @Override - protected boolean removeEldestEntry(Map.Entry eldest) { - boolean evict = size() > maxUserCacheSize; - if (evict) { - removeUser(eldest.getValue()); - } - return evict; - } - - private void removeUser(CachedUser value) { - if (value.getUsername() != null) usersByUsername.remove(value.getUsername()); - if (value.getEmail() != null) usersByEmail.remove(value.getEmail()); - } - } - - protected Map usersById = Collections.synchronizedMap(new LRUCache()); - protected Map usersByUsername = new ConcurrentHashMap(); - protected Map usersByEmail = new ConcurrentHashMap(); - - } - - protected ConcurrentHashMap realmUsers = new ConcurrentHashMap(); - - public int getMaxUserCacheSize() { - return maxUserCacheSize; - } - - public void setMaxUserCacheSize(int maxUserCacheSize) { - this.maxUserCacheSize = maxUserCacheSize; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void setEnabled(boolean enabled) { - clear(); - this.enabled = enabled; - clear(); - } - - @Override - public CachedUser getCachedUser(String realmId, String id) { - if (realmId == null || id == null) return null; - RealmUsers users = realmUsers.get(realmId); - if (users == null) return null; - return users.usersById.get(id); - } - - @Override - public void invalidateCachedUser(String realmId, CachedUser user) { - RealmUsers users = realmUsers.get(realmId); - if (users == null) return; - users.usersById.remove(user.getId()); - } - - @Override - public void invalidateCachedUserById(String realmId, String id) { - RealmUsers users = realmUsers.get(realmId); - if (users == null) return; - users.usersById.remove(id); - } - - @Override - public void addCachedUser(String realmId, CachedUser user) { - RealmUsers users = realmUsers.get(realmId); - if (users == null) { - users = new RealmUsers(); - realmUsers.put(realmId, users); - } - users.usersById.put(user.getId(), user); - } - - @Override - public CachedUser getCachedUserByUsername(String realmId, String name) { - if (realmId == null || name == null) return null; - RealmUsers users = realmUsers.get(realmId); - if (users == null) return null; - CachedUser user = users.usersByUsername.get(name); - if (user == null) return null; - users.usersById.get(user.getId()); // refresh cache entry age - return user; - } - - @Override - public CachedUser getCachedUserByEmail(String realmId, String email) { - if (realmId == null || email == null) return null; - RealmUsers users = realmUsers.get(realmId); - if (users == null) return null; - CachedUser user = users.usersByEmail.get(email); - if (user == null) return null; - users.usersById.get(user.getId()); // refresh cache entry age - return user; - } - - @Override - public void invalidateRealmUsers(String realmId) { - realmUsers.remove(realmId); - } - - @Override - public void clear() { - realmUsers.clear(); - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProvider.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProvider.java deleted file mode 100755 index 7f87bcd3e2..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProvider.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.migration.MigrationModel; -import org.keycloak.models.ClientModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RealmProvider; -import org.keycloak.models.RoleModel; - -import java.util.List; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class NoCacheRealmProvider implements CacheRealmProvider { - protected KeycloakSession session; - protected RealmProvider delegate; - - public NoCacheRealmProvider(KeycloakSession session) { - this.session = session; - } - - @Override - public boolean isEnabled() { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void setEnabled(boolean enabled) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public RealmProvider getDelegate() { - if (delegate != null) return delegate; - delegate = session.getProvider(RealmProvider.class); - return delegate; - } - - @Override - public void registerRealmInvalidation(String id) { - } - - @Override - public void registerApplicationInvalidation(String id) { - } - - @Override - public void registerRoleInvalidation(String id) { - } - - @Override - public MigrationModel getMigrationModel() { - return getDelegate().getMigrationModel(); - } - - @Override - public RealmModel createRealm(String name) { - return getDelegate().createRealm(name); - } - - @Override - public RealmModel createRealm(String id, String name) { - return getDelegate().createRealm(id, name); - } - - @Override - public RealmModel getRealm(String id) { - return getDelegate().getRealm(id); - } - - @Override - public RealmModel getRealmByName(String name) { - return getDelegate().getRealmByName(name); - } - - @Override - public List getRealms() { - // we don't cache this for now - return getDelegate().getRealms(); - } - - @Override - public boolean removeRealm(String id) { - return getDelegate().removeRealm(id); - } - - @Override - public void close() { - if (delegate != null) delegate.close(); - } - - @Override - public RoleModel getRoleById(String id, RealmModel realm) { - return getDelegate().getRoleById(id, realm); - } - - @Override - public ClientModel getClientById(String id, RealmModel realm) { - return getDelegate().getClientById(id, realm); - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProviderFactory.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProviderFactory.java deleted file mode 100755 index 7ee9329d91..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheRealmProviderFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class NoCacheRealmProviderFactory implements CacheRealmProviderFactory { - @Override - public CacheRealmProvider create(KeycloakSession session) { - return new NoCacheRealmProvider(session); - } - - @Override - public void close() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void init(Config.Scope config) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - - } - - @Override - public String getId() { - return "none"; - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProvider.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProvider.java deleted file mode 100755 index 8ed8b6a12b..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProvider.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.models.ClientModel; -import org.keycloak.models.CredentialValidationOutput; -import org.keycloak.models.FederatedIdentityModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.ProtocolMapperModel; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleModel; -import org.keycloak.models.UserCredentialModel; -import org.keycloak.models.UserFederationProviderModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserProvider; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class NoCacheUserProvider implements CacheUserProvider { - protected KeycloakSession session; - protected UserProvider delegate; - - public NoCacheUserProvider(KeycloakSession session) { - this.session = session; - } - - @Override - public boolean isEnabled() { - return false; - } - - @Override - public void setEnabled(boolean enabled) { - } - - @Override - public UserProvider getDelegate() { - if (delegate != null) return delegate; - delegate = session.getProvider(UserProvider.class); - return delegate; - } - - @Override - public void registerUserInvalidation(RealmModel realm, String id) { - } - - @Override - public UserModel getUserById(String id, RealmModel realm) { - return getDelegate().getUserById(id, realm); - } - - @Override - public UserModel getUserByUsername(String username, RealmModel realm) { - return getDelegate().getUserByUsername(username, realm); - } - - @Override - public UserModel getUserByEmail(String email, RealmModel realm) { - return getDelegate().getUserByEmail(email, realm); - } - - @Override - public void close() { - if (delegate != null) delegate.close(); - } - - @Override - public UserModel getUserByFederatedIdentity(FederatedIdentityModel socialLink, RealmModel realm) { - return getDelegate().getUserByFederatedIdentity(socialLink, realm); - } - - @Override - public UserModel getUserByServiceAccountClient(ClientModel client) { - return getDelegate().getUserByServiceAccountClient(client); - } - - @Override - public List getUsers(RealmModel realm, boolean includeServiceAccounts) { - return getDelegate().getUsers(realm, includeServiceAccounts); - } - - @Override - public int getUsersCount(RealmModel realm) { - return getDelegate().getUsersCount(realm); - } - - @Override - public List getUsers(RealmModel realm, int firstResult, int maxResults, boolean includeServiceAccounts) { - return getDelegate().getUsers(realm, firstResult, maxResults, includeServiceAccounts); - } - - @Override - public List searchForUser(String search, RealmModel realm) { - return getDelegate().searchForUser(search, realm); - } - - @Override - public List searchForUser(String search, RealmModel realm, int firstResult, int maxResults) { - return getDelegate().searchForUser(search, realm, firstResult, maxResults); - } - - @Override - public List searchForUserByAttributes(Map attributes, RealmModel realm) { - return getDelegate().searchForUserByAttributes(attributes, realm); - } - - @Override - public List searchForUserByAttributes(Map attributes, RealmModel realm, int firstResult, int maxResults) { - return getDelegate().searchForUserByAttributes(attributes, realm, firstResult, maxResults); - } - - @Override - public List searchForUserByUserAttributes(Map attributes, RealmModel realm) { - return getDelegate().searchForUserByUserAttributes(attributes, realm); - } - - @Override - public Set getFederatedIdentities(UserModel user, RealmModel realm) { - return getDelegate().getFederatedIdentities(user, realm); - } - - @Override - public FederatedIdentityModel getFederatedIdentity(UserModel user, String socialProvider, RealmModel realm) { - return getDelegate().getFederatedIdentity(user, socialProvider, realm); - } - - @Override - public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) { - return getDelegate().addUser(realm, id, username, addDefaultRoles, addDefaultRequiredActions); - } - - @Override - public UserModel addUser(RealmModel realm, String username) { - return getDelegate().addUser(realm, username); - } - - @Override - public boolean removeUser(RealmModel realm, UserModel user) { - return getDelegate().removeUser(realm, user); - } - - @Override - public void addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink) { - getDelegate().addFederatedIdentity(realm, user, socialLink); - } - - @Override - public void updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel) { - getDelegate().updateFederatedIdentity(realm, federatedUser, federatedIdentityModel); - } - - @Override - public boolean removeFederatedIdentity(RealmModel realm, UserModel user, String socialProvider) { - return getDelegate().removeFederatedIdentity(realm, user, socialProvider); - } - - @Override - public boolean validCredentials(RealmModel realm, UserModel user, List input) { - return getDelegate().validCredentials(realm, user, input); - } - - @Override - public boolean validCredentials(RealmModel realm, UserModel user, UserCredentialModel... input) { - return getDelegate().validCredentials(realm, user, input); - } - - @Override - public CredentialValidationOutput validCredentials(RealmModel realm, UserCredentialModel... input) { - return getDelegate().validCredentials(realm, input); - } - - @Override - public void preRemove(RealmModel realm) { - getDelegate().preRemove(realm); - } - - @Override - public void preRemove(RealmModel realm, UserFederationProviderModel link) { - getDelegate().preRemove(realm, link); - } - - @Override - public void preRemove(RealmModel realm, RoleModel role) { - getDelegate().preRemove(realm, role); - } - - @Override - public void preRemove(RealmModel realm, ClientModel client) { - getDelegate().preRemove(realm, client); - } - - @Override - public void preRemove(ClientModel client, ProtocolMapperModel protocolMapper) { - getDelegate().preRemove(client, protocolMapper); - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProviderFactory.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProviderFactory.java deleted file mode 100755 index a89847bf5b..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/NoCacheUserProviderFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.keycloak.models.cache; - -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class NoCacheUserProviderFactory implements CacheUserProviderFactory { - @Override - public CacheUserProvider create(KeycloakSession session) { - return new NoCacheUserProvider(session); - } - - @Override - public void close() { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void init(Config.Scope config) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - - } - - @Override - public String getId() { - return "none"; - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheRealmProviderFactory b/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheRealmProviderFactory deleted file mode 100755 index 4d92613bb4..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheRealmProviderFactory +++ /dev/null @@ -1,2 +0,0 @@ -org.keycloak.models.cache.MemoryCacheRealmProviderFactory -org.keycloak.models.cache.NoCacheRealmProviderFactory \ No newline at end of file diff --git a/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheUserProviderFactory b/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheUserProviderFactory deleted file mode 100755 index a2f107f088..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/resources/META-INF/services/org.keycloak.models.cache.CacheUserProviderFactory +++ /dev/null @@ -1,2 +0,0 @@ -org.keycloak.models.cache.MemoryCacheUserProviderFactory -org.keycloak.models.cache.NoCacheUserProviderFactory diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java index 2b05cb96e8..5bc3556269 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java @@ -6,6 +6,7 @@ import org.junit.Assert; import org.junit.ClassRule; import org.junit.Test; import org.keycloak.models.*; +import org.keycloak.models.cache.infinispan.RealmAdapter; import org.keycloak.testsuite.rule.KeycloakRule; import static org.junit.Assert.assertNotNull; @@ -45,7 +46,7 @@ public class CacheTest { } } - Assert.assertTrue(realm instanceof org.keycloak.models.cache.RealmAdapter); + Assert.assertTrue(realm instanceof RealmAdapter); realm.setAccessCodeLifespanLogin(200); ClientModel testApp = realm.getClientByClientId("test-app"); assertNotNull(testApp); diff --git a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json index c760152991..ef4b9d4023 100755 --- a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json +++ b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json @@ -26,17 +26,6 @@ "provider" : "${keycloak.userSessions.provider:infinispan}" }, - "realmCache": { - "provider": "${keycloak.realm.cache.provider:infinispan}" - }, - - "userCache": { - "provider": "${keycloak.user.cache.provider:infinispan}", - "mem": { - "maxSize": 20000 - } - }, - "timer": { "provider": "basic" }, @@ -51,18 +40,6 @@ } }, - "login": { - "provider": "freemarker" - }, - - "account": { - "provider": "freemarker" - }, - - "email": { - "provider": "freemarker" - }, - "scheduled": { "interval": 900 },