diff --git a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanRealmCache.java b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanRealmCache.java index b5204e8b41..ec93a7a3bb 100755 --- a/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanRealmCache.java +++ b/model/invalidation-cache/infinispan/src/main/java/org/keycloak/models/cache/infinispan/InfinispanRealmCache.java @@ -3,7 +3,7 @@ package org.keycloak.models.cache.infinispan; import org.infinispan.Cache; import org.jboss.logging.Logger; import org.keycloak.models.cache.RealmCache; -import org.keycloak.models.cache.entities.CachedApplication; +import org.keycloak.models.cache.entities.CachedClient; import org.keycloak.models.cache.entities.CachedRealm; import org.keycloak.models.cache.entities.CachedRole; @@ -77,19 +77,19 @@ public class InfinispanRealmCache implements RealmCache { } @Override - public CachedApplication getApplication(String id) { + public CachedClient getApplication(String id) { if (!enabled) return null; - return get(id, CachedApplication.class); + return get(id, CachedClient.class); } @Override - public void invalidateApplication(CachedApplication app) { + public void invalidateApplication(CachedClient app) { logger.tracev("Removing application {0}", app.getId()); cache.remove(app.getId()); } @Override - public void addCachedApplication(CachedApplication app) { + public void addCachedClient(CachedClient app) { if (!enabled) return; logger.tracev("Adding application {0}", app.getId()); cache.put(app.getId(), app); diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java index 5330fbc18a..436405ee8d 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/ClientAdapter.java @@ -6,7 +6,7 @@ import org.keycloak.models.ProtocolMapperModel; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleContainerModel; import org.keycloak.models.RoleModel; -import org.keycloak.models.cache.entities.CachedApplication; +import org.keycloak.models.cache.entities.CachedClient; import java.util.HashMap; import java.util.HashSet; @@ -24,9 +24,9 @@ public class ClientAdapter implements ClientModel { protected RealmCache cache; protected ClientModel updated; - protected CachedApplication cached; + protected CachedClient cached; - public ClientAdapter(RealmModel cachedRealm, CachedApplication cached, CacheRealmProvider cacheSession, RealmCache cache) { + public ClientAdapter(RealmModel cachedRealm, CachedClient cached, CacheRealmProvider cacheSession, RealmCache cache) { this.cachedRealm = cachedRealm; this.cache = cache; this.cacheSession = cacheSession; diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java index 933ac743b0..13f6924a71 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheRealmProvider.java @@ -6,8 +6,8 @@ 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.CachedApplication; -import org.keycloak.models.cache.entities.CachedApplicationRole; +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; @@ -235,7 +235,7 @@ public class DefaultCacheRealmProvider implements CacheRealmProvider { if (model == null) return null; if (roleInvalidations.contains(id)) return model; if (model.getContainer() instanceof ClientModel) { - cached = new CachedApplicationRole(((ClientModel) model.getContainer()).getId(), model, realm); + cached = new CachedClientRole(((ClientModel) model.getContainer()).getId(), model, realm); } else { cached = new CachedRealmRole(model, realm); } @@ -254,7 +254,7 @@ public class DefaultCacheRealmProvider implements CacheRealmProvider { @Override public ClientModel getClientById(String id, RealmModel realm) { if (!cache.isEnabled()) return getDelegate().getClientById(id, realm); - CachedApplication cached = cache.getApplication(id); + CachedClient cached = cache.getApplication(id); if (cached != null && !cached.getRealm().equals(realm.getId())) { cached = null; } @@ -263,8 +263,8 @@ public class DefaultCacheRealmProvider implements CacheRealmProvider { ClientModel model = getDelegate().getClientById(id, realm); if (model == null) return null; if (appInvalidations.contains(id)) return model; - cached = new CachedApplication(cache, getDelegate(), realm, model); - cache.addCachedApplication(cached); + cached = new CachedClient(cache, getDelegate(), realm, model); + cache.addCachedClient(cached); } else if (appInvalidations.contains(id)) { return getDelegate().getClientById(id, realm); } else if (managedApplications.containsKey(id)) { 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 index 25064c6764..3b04670d70 100755 --- 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 @@ -1,6 +1,6 @@ package org.keycloak.models.cache; -import org.keycloak.models.cache.entities.CachedApplication; +import org.keycloak.models.cache.entities.CachedClient; import org.keycloak.models.cache.entities.CachedRealm; import org.keycloak.models.cache.entities.CachedRole; @@ -14,7 +14,7 @@ public class MemoryRealmCache implements RealmCache { protected ConcurrentHashMap realmCache = new ConcurrentHashMap(); protected ConcurrentHashMap realmCacheByName = new ConcurrentHashMap(); - protected ConcurrentHashMap applicationCache = new ConcurrentHashMap(); + protected ConcurrentHashMap applicationCache = new ConcurrentHashMap(); protected ConcurrentHashMap roleCache = new ConcurrentHashMap(); protected volatile boolean enabled = true; @@ -72,18 +72,18 @@ public class MemoryRealmCache implements RealmCache { } @Override - public CachedApplication getApplication(String id) { + public CachedClient getApplication(String id) { if (!enabled) return null; return applicationCache.get(id); } @Override - public void invalidateApplication(CachedApplication app) { + public void invalidateApplication(CachedClient app) { applicationCache.remove(app.getId()); } @Override - public void addCachedApplication(CachedApplication app) { + public void addCachedClient(CachedClient app) { if (!enabled) return; applicationCache.put(app.getId(), app); } diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java index f2532af4b3..68a65ac2ff 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java @@ -474,7 +474,7 @@ public class RealmAdapter implements RealmModel { public Map getClientNameMap() { if (updated != null) return updated.getClientNameMap(); Map map = new HashMap(); - for (String id : cached.getApplications().values()) { + for (String id : cached.getClients().values()) { ClientModel model = cacheSession.getClientById(id, this); if (model == null) { throw new IllegalStateException("Cached application not found: " + id); @@ -488,7 +488,7 @@ public class RealmAdapter implements RealmModel { public List getClients() { if (updated != null) return updated.getClients(); List apps = new LinkedList(); - for (String id : cached.getApplications().values()) { + for (String id : cached.getClients().values()) { ClientModel model = cacheSession.getClientById(id, this); if (model == null) { throw new IllegalStateException("Cached application not found: " + id); @@ -531,7 +531,7 @@ public class RealmAdapter implements RealmModel { @Override public ClientModel getClientByClientId(String clientId) { if (updated != null) return updated.getClientByClientId(clientId); - String id = cached.getApplications().get(clientId); + String id = cached.getClients().get(clientId); if (id == null) return null; return getClientById(id); } @@ -752,7 +752,7 @@ public class RealmAdapter implements RealmModel { @Override public ClientModel getMasterAdminClient() { - return cacheSession.getRealm(Config.getAdminRealm()).getClientById(cached.getMasterAdminApp()); + return cacheSession.getRealm(Config.getAdminRealm()).getClientById(cached.getMasterAdminClient()); } @Override diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmCache.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmCache.java index 3d6646200f..b683f577c9 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmCache.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmCache.java @@ -1,6 +1,6 @@ package org.keycloak.models.cache; -import org.keycloak.models.cache.entities.CachedApplication; +import org.keycloak.models.cache.entities.CachedClient; import org.keycloak.models.cache.entities.CachedRealm; import org.keycloak.models.cache.entities.CachedRole; @@ -21,11 +21,11 @@ public interface RealmCache { void invalidateCachedRealmById(String id); - CachedApplication getApplication(String id); + CachedClient getApplication(String id); - void invalidateApplication(CachedApplication app); + void invalidateApplication(CachedClient app); - void addCachedApplication(CachedApplication app); + void addCachedClient(CachedClient app); void invalidateCachedApplicationById(String id); diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java index 0f30ecdd2a..3323338a26 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RoleAdapter.java @@ -3,7 +3,7 @@ package org.keycloak.models.cache; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleContainerModel; import org.keycloak.models.RoleModel; -import org.keycloak.models.cache.entities.CachedApplicationRole; +import org.keycloak.models.cache.entities.CachedClientRole; import org.keycloak.models.cache.entities.CachedRealmRole; import org.keycloak.models.cache.entities.CachedRole; import org.keycloak.models.utils.KeycloakModelUtils; @@ -106,8 +106,8 @@ public class RoleAdapter implements RoleModel { if (cached instanceof CachedRealmRole) { return realm; } else { - CachedApplicationRole appRole = (CachedApplicationRole)cached; - return realm.getClientById(appRole.getAppId()); + CachedClientRole appRole = (CachedClientRole)cached; + return realm.getClientById(appRole.getIdClient()); } } diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplicationRole.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplicationRole.java deleted file mode 100755 index da0451c788..0000000000 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplicationRole.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.keycloak.models.cache.entities; - -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleModel; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class CachedApplicationRole extends CachedRole { - private final String appId; - - public CachedApplicationRole(String appId, RoleModel model, RealmModel realm) { - super(model, realm); - this.appId = appId; - - } - - public String getAppId() { - return appId; - } -} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplication.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClient.java similarity index 93% rename from model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplication.java rename to model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClient.java index 896dfc96f3..c5869273d0 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedApplication.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClient.java @@ -21,7 +21,7 @@ import java.util.TreeMap; * @author Bill Burke * @version $Revision: 1 $ */ -public class CachedApplication { +public class CachedClient { private String id; private String name; private String realm; @@ -49,7 +49,7 @@ public class CachedApplication { private int nodeReRegistrationTimeout; private Map registeredNodes; - public CachedApplication(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientModel model) { + public CachedClient(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientModel model) { id = model.getId(); secret = model.getSecret(); name = model.getClientId(); @@ -79,7 +79,7 @@ public class CachedApplication { consentRequired = model.isConsentRequired(); for (RoleModel role : model.getRoles()) { roles.put(role.getName(), role.getId()); - cache.addCachedRole(new CachedApplicationRole(id, role, realm)); + cache.addCachedRole(new CachedClientRole(id, role, realm)); } nodeReRegistrationTimeout = model.getNodeReRegistrationTimeout(); diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClientRole.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClientRole.java new file mode 100755 index 0000000000..dd270a55c6 --- /dev/null +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedClientRole.java @@ -0,0 +1,22 @@ +package org.keycloak.models.cache.entities; + +import org.keycloak.models.RealmModel; +import org.keycloak.models.RoleModel; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class CachedClientRole extends CachedRole { + private final String idClient; + + public CachedClientRole(String idClient, RoleModel model, RealmModel realm) { + super(model, realm); + this.idClient = idClient; + + } + + public String getIdClient() { + return idClient; + } +} diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java index d302c48979..e4908140f1 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java @@ -66,7 +66,7 @@ public class CachedRealm { private String accountTheme; private String adminTheme; private String emailTheme; - private String masterAdminApp; + private String masterAdminClient; private List requiredCredentials = new ArrayList(); private List userFederationProviders = new ArrayList(); @@ -81,7 +81,6 @@ public class CachedRealm { private Set enabledEventTypes = new HashSet(); private List defaultRoles = new LinkedList(); private Map realmRoles = new HashMap(); - private Map applications = new HashMap(); private Map clients = new HashMap(); private boolean internationalizationEnabled; private Set supportedLocales = new HashSet(); @@ -155,7 +154,7 @@ public class CachedRealm { eventsListeners.addAll(model.getEventsListeners()); enabledEventTypes.addAll(model.getEnabledEventTypes()); defaultRoles.addAll(model.getDefaultRoles()); - masterAdminApp = model.getMasterAdminClient().getId(); + masterAdminClient = model.getMasterAdminClient().getId(); for (RoleModel role : model.getRoles()) { realmRoles.put(role.getName(), role.getId()); @@ -163,10 +162,10 @@ public class CachedRealm { cache.addCachedRole(cachedRole); } - for (ClientModel app : model.getClients()) { - applications.put(app.getClientId(), app.getId()); - CachedApplication cachedApp = new CachedApplication(cache, delegate, model, app); - cache.addCachedApplication(cachedApp); + for (ClientModel client : model.getClients()) { + clients.put(client.getClientId(), client.getId()); + CachedClient cachedClient = new CachedClient(cache, delegate, model, client); + cache.addCachedClient(cachedClient); } internationalizationEnabled = model.isInternationalizationEnabled(); @@ -180,8 +179,8 @@ public class CachedRealm { return id; } - public String getMasterAdminApp() { - return masterAdminApp; + public String getMasterAdminClient() { + return masterAdminClient; } public String getName() { @@ -196,10 +195,6 @@ public class CachedRealm { return realmRoles; } - public Map getApplications() { - return applications; - } - public Map getClients() { return clients; } diff --git a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java index c744b8af2a..e515ddef0b 100755 --- a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java +++ b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java @@ -91,7 +91,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme @Override public SslRequired getSslRequired() { - return SslRequired.valueOf(realm.getSslRequired()); + return realm.getSslRequired() != null ? SslRequired.valueOf(realm.getSslRequired()) : null; } @Override