mirror of
https://github.com/keycloak/keycloak.git
synced 2026-02-18 18:37:54 -05:00
Reduce UserListQuery memory usage
Closes #46140 Signed-off-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com> Co-authored-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
This commit is contained in:
parent
de0ae92ebe
commit
49240b6eac
49 changed files with 184 additions and 220 deletions
|
|
@ -75,7 +75,7 @@ public abstract class CacheManager {
|
|||
return counter.current();
|
||||
}
|
||||
|
||||
public Long getCurrentRevision(String id) {
|
||||
public long getCurrentRevision(String id) {
|
||||
Long revision = revisions.get(id);
|
||||
if (revision == null) {
|
||||
revision = counter.current();
|
||||
|
|
@ -93,7 +93,7 @@ public abstract class CacheManager {
|
|||
}
|
||||
|
||||
public <T extends Revisioned> T get(String id, Class<T> type) {
|
||||
Revisioned o = (Revisioned)cache.get(id);
|
||||
Revisioned o = cache.get(id);
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -110,20 +110,20 @@ public abstract class CacheManager {
|
|||
cache.remove(id);
|
||||
return null;
|
||||
}
|
||||
long oRev = o.getRevision() == null ? -1L : o.getRevision().longValue();
|
||||
long oRev = o.getRevision();
|
||||
if (rev > oRev) {
|
||||
if (getLogger().isTraceEnabled()) {
|
||||
getLogger().tracev("get() rev: {0} o.rev: {1}", rev.longValue(), oRev);
|
||||
getLogger().tracev("get() rev: {0} o.rev: {1}", rev, oRev);
|
||||
}
|
||||
// the object in this.cache is outdated => remove it
|
||||
cache.remove(id);
|
||||
return null;
|
||||
}
|
||||
return o != null && type.isInstance(o) ? type.cast(o) : null;
|
||||
return type.isInstance(o) ? type.cast(o) : null;
|
||||
}
|
||||
|
||||
public Object invalidateObject(String id) {
|
||||
Revisioned removed = (Revisioned)cache.remove(id);
|
||||
Revisioned removed = cache.remove(id);
|
||||
|
||||
if (getLogger().isTraceEnabled()) {
|
||||
getLogger().tracef("Removed key='%s', value='%s' from cache", id, removed);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class CachedCount extends AbstractRevisioned implements InRealm {
|
|||
private final String realm;
|
||||
private final long count;
|
||||
|
||||
public CachedCount(Long revision, RealmModel realm, String cacheKey, long count) {
|
||||
public CachedCount(long revision, RealmModel realm, String cacheKey, long count) {
|
||||
super(revision, cacheKey);
|
||||
this.realm = realm.getId();
|
||||
this.count = count;
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
private void invalidateClient(String id) {
|
||||
invalidations.add(id);
|
||||
ClientModel adapter = managedApplications.get(id);
|
||||
if (adapter != null && adapter instanceof ClientAdapter) ((ClientAdapter)adapter).invalidate();
|
||||
if (adapter instanceof ClientAdapter clientAdapter) clientAdapter.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -286,8 +286,8 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
// need to make sure that scope and group mapping clients and groups are invalidated
|
||||
for (String id : newInvalidations) {
|
||||
ClientModel adapter = managedApplications.get(id);
|
||||
if (adapter != null && adapter instanceof ClientAdapter){
|
||||
((ClientAdapter)adapter).invalidate();
|
||||
if (adapter instanceof ClientAdapter clientAdapter){
|
||||
clientAdapter.invalidate();
|
||||
continue;
|
||||
}
|
||||
GroupAdapter group = managedGroups.get(id);
|
||||
|
|
@ -303,7 +303,6 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
RoleAdapter role = managedRoles.get(id);
|
||||
if (role != null) {
|
||||
role.invalidate();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -486,7 +485,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
CachedRealm cached = cache.get(id, CachedRealm.class);
|
||||
RealmAdapter adapter;
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
RealmModel model = getRealmDelegate().getRealm(id);
|
||||
if (model == null) {
|
||||
return null;
|
||||
|
|
@ -532,7 +531,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
private RealmModel prepareCachedRealmByName(String name, String cacheKey) {
|
||||
RealmListQuery query = cache.get(cacheKey, RealmListQuery.class);
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
RealmModel model = getRealmDelegate().getRealmByName(name);
|
||||
if (model == null) {
|
||||
return null;
|
||||
|
|
@ -682,9 +681,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
invalidationEvents.add(ClientRemovedEvent.create(client));
|
||||
cache.clientRemoval(realm.getId(), id, client.getClientId(), invalidations);
|
||||
|
||||
client.getRolesStream().forEach(role -> {
|
||||
roleRemovalInvalidations(role.getId(), role.getName(), client.getId());
|
||||
});
|
||||
client.getRolesStream().forEach(role -> roleRemovalInvalidations(role.getId(), role.getName(), client.getId()));
|
||||
|
||||
if (client.isServiceAccountsEnabled()) {
|
||||
UserModel serviceAccount = session.users().getServiceAccount(client);
|
||||
|
|
@ -732,9 +729,9 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Set<RoleModel> model = getRoleDelegate().getRealmRolesStream(realm).collect(Collectors.toSet());
|
||||
if (model == null) return null;
|
||||
if (model.isEmpty()) return Stream.of();
|
||||
Set<String> ids = model.stream().map(RoleModel::getId).collect(Collectors.toSet());
|
||||
query = new RoleListQuery(loaded, cacheKey, realm, ids);
|
||||
logger.tracev("adding realm roles cache miss: realm {0} key {1}", realm.getName(), cacheKey);
|
||||
|
|
@ -767,9 +764,9 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Set<RoleModel> model = getRoleDelegate().getClientRolesStream(client).collect(Collectors.toSet());
|
||||
if (model == null) return null;
|
||||
if (model.isEmpty()) return Stream.of();
|
||||
Set<String> ids = model.stream().map(RoleModel::getId).collect(Collectors.toSet());
|
||||
query = new RoleListQuery(loaded, cacheKey, client.getRealm(), ids, client.getClientId());
|
||||
logger.tracev("adding client roles cache miss: client {0} key {1}", client.getClientId(), cacheKey);
|
||||
|
|
@ -849,7 +846,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
RoleModel model = getRoleDelegate().getRealmRole(realm, name);
|
||||
if (model == null) {
|
||||
// caching empty results will speed up the policy evaluation which tries to look up the role by name and ID
|
||||
|
|
@ -887,7 +884,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
RoleModel model = getRoleDelegate().getClientRole(client, name);
|
||||
if (model == null) {
|
||||
// caching empty results will speed up the policy evaluation which tries to look up the role by name and ID
|
||||
|
|
@ -940,7 +937,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
RoleModel model = getRoleDelegate().getRoleById(realm, id);
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(id)) return model;
|
||||
|
|
@ -969,7 +966,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
GroupModel model = getGroupDelegate().getGroupById(realm, id);
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(id)) return model;
|
||||
|
|
@ -994,7 +991,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
logger.tracev("Group by name cache hit: {0}", name);
|
||||
}
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
GroupModel model = getGroupDelegate().getGroupByName(realm, parent, name);
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(model.getId())) return model;
|
||||
|
|
@ -1037,8 +1034,8 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
List<GroupModel> model = getGroupDelegate().getGroupsStream(realm).collect(Collectors.toList());
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
List<GroupModel> model = getGroupDelegate().getGroupsStream(realm).toList();
|
||||
if (model.isEmpty()) return Stream.empty();
|
||||
Set<String> ids = new HashSet<>();
|
||||
for (GroupModel client : model) ids.add(client.getId());
|
||||
|
|
@ -1186,7 +1183,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
} else {
|
||||
adapter = cache.computeSerialized(session, id, (key, keycloakSession) -> prepareCachedClientById(realm, id));
|
||||
if (adapter == null) {
|
||||
return adapter;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
managedApplications.put(id, adapter);
|
||||
|
|
@ -1200,7 +1197,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
cached = null;
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
ClientModel model = getClientDelegate().getClientById(realm, id);
|
||||
if (model == null) {
|
||||
return null;
|
||||
|
|
@ -1213,11 +1210,11 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
return adapter;
|
||||
}
|
||||
|
||||
protected ClientModel cacheClient(RealmModel realm, ClientModel delegate, Long revision) {
|
||||
protected ClientModel cacheClient(RealmModel realm, ClientModel delegate, long revision) {
|
||||
if (invalidations.contains(delegate.getId())) return delegate;
|
||||
StorageId storageId = new StorageId(delegate.getId());
|
||||
CachedClient cached = null;
|
||||
ClientModel adapter = null;
|
||||
CachedClient cached;
|
||||
ClientModel adapter;
|
||||
|
||||
if (!storageId.isLocal()) {
|
||||
ComponentModel component = realm.getComponent(storageId.getProviderId());
|
||||
|
|
@ -1226,7 +1223,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
return delegate;
|
||||
}
|
||||
ClientStorageProviderModel.CachePolicy policy = model.getCachePolicy();
|
||||
if (policy != null && policy == ClientStorageProviderModel.CachePolicy.NO_CACHE) {
|
||||
if (policy == ClientStorageProviderModel.CachePolicy.NO_CACHE) {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
|
|
@ -1315,7 +1312,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
ClientListQuery query = cache.get(cacheKey, ClientListQuery.class);
|
||||
String id;
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
ClientModel model = getClientDelegate().getClientByClientId(realm, clientId);
|
||||
if (model == null) {
|
||||
return null;
|
||||
|
|
@ -1345,7 +1342,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
ClientScopeModel model = getClientScopeDelegate().getClientScopeById(realm, id);
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(id)) return model;
|
||||
|
|
@ -1375,9 +1372,9 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Set<ClientScopeModel> model = getClientScopeDelegate().getClientScopesStream(realm).collect(Collectors.toSet());
|
||||
if (model == null) return null;
|
||||
if (model.isEmpty()) return Stream.of();
|
||||
Set<String> ids = model.stream().map(ClientScopeModel::getId).collect(Collectors.toSet());
|
||||
query = new ClientScopeListQuery(loaded, cacheKey, realm, ids);
|
||||
logger.tracev("adding client scopes cache miss: realm {0} key {1}", realm.getName(), cacheKey);
|
||||
|
|
@ -1473,7 +1470,7 @@ public class RealmCacheSession implements CacheRealmProvider {
|
|||
ClientScopeListQuery query = cache.get(cacheKey, ClientScopeListQuery.class);
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Map<String, ClientScopeModel> model = getClientDelegate().getClientScopes(realm, client, defaultScopes);
|
||||
if (model == null) return null;
|
||||
Set<String> ids = model.values().stream().map(ClientScopeModel::getId).collect(Collectors.toSet());
|
||||
|
|
|
|||
|
|
@ -221,10 +221,10 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
cached = null;
|
||||
}
|
||||
|
||||
UserModel adapter = null;
|
||||
UserModel adapter;
|
||||
if (cached == null) {
|
||||
logger.trace("not cached");
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
UserModel delegate = getDelegate().getUserById(realm, id);
|
||||
if (delegate == null) {
|
||||
logger.trace("delegate returning null");
|
||||
|
|
@ -278,7 +278,7 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
|
||||
if (query == null) {
|
||||
logger.tracev("query null");
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
UserModel model = getDelegate().getUserByUsername(realm, username);
|
||||
if (model == null) {
|
||||
logger.tracev("model from delegate null");
|
||||
|
|
@ -388,7 +388,7 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
return userAdapter;
|
||||
}
|
||||
|
||||
protected UserModel cacheUser(RealmModel realm, UserModel delegate, Long revision) {
|
||||
protected UserModel cacheUser(RealmModel realm, UserModel delegate, long revision) {
|
||||
int notBefore = getDelegate().getNotBeforeOfUser(realm, delegate);
|
||||
|
||||
if (isReadOnlyOrganizationMember(session, delegate)) {
|
||||
|
|
@ -443,7 +443,7 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
UserListQuery query = cache.get(cacheKey, UserListQuery.class);
|
||||
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
UserModel model = getDelegate().getUserByEmail(realm, email);
|
||||
if (model == null) return null;
|
||||
String userId = model.getId();
|
||||
|
|
@ -494,9 +494,9 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
}
|
||||
UserListQuery query = cache.get(cacheKey, UserListQuery.class);
|
||||
|
||||
String userId = null;
|
||||
String userId;
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
UserModel model = getDelegate().getUserByFederatedIdentity(realm, socialLink);
|
||||
if (model == null) return null;
|
||||
userId = model.getId();
|
||||
|
|
@ -574,10 +574,10 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
}
|
||||
UserListQuery query = cache.get(cacheKey, UserListQuery.class);
|
||||
|
||||
String userId = null;
|
||||
String userId;
|
||||
if (query == null) {
|
||||
logger.tracev("query null");
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
UserModel model = getDelegate().getServiceAccount(client);
|
||||
if (model == null) {
|
||||
logger.tracev("model from delegate null");
|
||||
|
|
@ -699,7 +699,7 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
CachedFederatedIdentityLinks cachedLinks = cache.get(cacheKey, CachedFederatedIdentityLinks.class);
|
||||
|
||||
if (cachedLinks == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Set<FederatedIdentityModel> federatedIdentities = getDelegate().getFederatedIdentitiesStream(realm, user)
|
||||
.collect(Collectors.toSet());
|
||||
cachedLinks = new CachedFederatedIdentityLinks(loaded, cacheKey, realm, federatedIdentities);
|
||||
|
|
@ -773,7 +773,7 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
consents = Collections.singletonList(new CachedUserConsent(consent));
|
||||
}
|
||||
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
cached = new CachedUserConsents(loaded, cacheKey, realm, consents, false);
|
||||
cache.addRevisioned(cached, startupRevision); // this is from Keycloak's internal store, cache indefinitely
|
||||
}
|
||||
|
|
@ -813,8 +813,8 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
List<UserConsentModel> consents = getDelegate().getConsentsStream(realm, userId).collect(Collectors.toList());
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
List<UserConsentModel> consents = getDelegate().getConsentsStream(realm, userId).toList();
|
||||
cached = new CachedUserConsents(loaded, cacheKey, realm, consents.stream().map(CachedUserConsent::new).collect(Collectors.toList()));
|
||||
cache.addRevisioned(cached, startupRevision); // this is from Keycloak's internal store, cache indefinitely
|
||||
return consents.stream();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.keycloak.models.cache.infinispan.authorization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -459,7 +458,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (! modelMightExist(id)) return null;
|
||||
ResourceServer model = getResourceServerStoreDelegate().findById(id);
|
||||
if (model == null) {
|
||||
|
|
@ -518,7 +517,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
logger.tracev("by id cache hit: {0}", cached.getId());
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (! modelMightExist(id)) return null;
|
||||
Scope model = getScopeStoreDelegate().findById(resourceServer, id);
|
||||
if (model == null) {
|
||||
|
|
@ -548,7 +547,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
logger.tracev("scope by name cache hit: {0}", name);
|
||||
}
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
Scope model = getScopeStoreDelegate().findByName(resourceServer, name);
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(model.getId())) return model;
|
||||
|
|
@ -611,7 +610,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
logger.tracev("by id cache hit: {0}", cached.getId());
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (! modelMightExist(id)) return null;
|
||||
Resource model = getResourceStoreDelegate().findById(resourceServer, id);
|
||||
if (model == null) {
|
||||
|
|
@ -643,7 +642,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.asList(resource);
|
||||
return List.of(resource);
|
||||
},
|
||||
(revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer);
|
||||
|
||||
|
|
@ -668,14 +667,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getResourceByOwnerCacheKey(ownerId, resourceServerId);
|
||||
cacheQuery(cacheKey, ResourceListQuery.class, () -> {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
getResourceStoreDelegate().findByOwner(resourceServer, ownerId, new Consumer<Resource>() {
|
||||
@Override
|
||||
public void accept(Resource resource) {
|
||||
getResourceStoreDelegate().findByOwner(resourceServer, ownerId, resource ->
|
||||
consumer.andThen(resources::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cacheResource)
|
||||
.accept(resource);
|
||||
}
|
||||
});
|
||||
.accept(resource));
|
||||
return resources;
|
||||
},
|
||||
(revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -714,15 +709,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getResourceByScopeCacheKey(scope.getId(), resourceServerId);
|
||||
cacheQuery(cacheKey, ResourceScopeListQuery.class, () -> {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
getResourceStoreDelegate().findByScopes(resourceServer, Collections.singleton(scope), new Consumer<Resource>() {
|
||||
@Override
|
||||
public void accept(Resource resource) {
|
||||
consumer.andThen(resources::add)
|
||||
getResourceStoreDelegate().findByScopes(resourceServer, Collections.singleton(scope),
|
||||
resource -> consumer.andThen(resources::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cacheResource)
|
||||
.accept(resource);
|
||||
|
||||
}
|
||||
});
|
||||
.accept(resource));
|
||||
return resources;
|
||||
}, (revision, resources) -> new ResourceScopeListQuery(revision, cacheKey, scope.getId(), resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
}
|
||||
|
|
@ -744,14 +734,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getResourceByTypeCacheKey(type, resourceServerId);
|
||||
cacheQuery(cacheKey, ResourceListQuery.class, () -> {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
getResourceStoreDelegate().findByType(resourceServer, type, new Consumer<Resource>() {
|
||||
@Override
|
||||
public void accept(Resource resource) {
|
||||
getResourceStoreDelegate().findByType(resourceServer, type, resource ->
|
||||
consumer.andThen(resources::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cacheResource)
|
||||
.accept(resource);
|
||||
}
|
||||
});
|
||||
.accept(resource));
|
||||
return resources;
|
||||
},
|
||||
(revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -764,14 +750,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getResourceByTypeCacheKey(type, owner, resourceServerId);
|
||||
cacheQuery(cacheKey, ResourceListQuery.class, () -> {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
getResourceStoreDelegate().findByType(resourceServer, type, owner, new Consumer<Resource>() {
|
||||
@Override
|
||||
public void accept(Resource resource) {
|
||||
consumer.andThen(resources::add)
|
||||
getResourceStoreDelegate().findByType(resourceServer, type, owner,
|
||||
resource -> consumer.andThen(resources::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cacheResource)
|
||||
.accept(resource);
|
||||
}
|
||||
});
|
||||
.accept(resource));
|
||||
return resources;
|
||||
},
|
||||
(revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -784,14 +766,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getResourceByTypeInstanceCacheKey(type, resourceServerId);
|
||||
cacheQuery(cacheKey, ResourceListQuery.class, () -> {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
getResourceStoreDelegate().findByTypeInstance(resourceServer, type, new Consumer<Resource>() {
|
||||
@Override
|
||||
public void accept(Resource resource) {
|
||||
consumer.andThen(resources::add)
|
||||
getResourceStoreDelegate().findByTypeInstance(resourceServer, type,
|
||||
resource -> consumer.andThen(resources::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cacheResource)
|
||||
.accept(resource);
|
||||
}
|
||||
});
|
||||
.accept(resource));
|
||||
return resources;
|
||||
},
|
||||
(revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(Resource::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -812,7 +790,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
}
|
||||
List<R> model = Collections.emptyList();
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
model = resultSupplier.get();
|
||||
if (model == null) return null;
|
||||
if (!invalidations.contains(cacheKey)) {
|
||||
|
|
@ -884,7 +862,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
if (cached == null) {
|
||||
if (! modelMightExist(id)) return null;
|
||||
Policy model = getPolicyStoreDelegate().findById(resourceServer, id);
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (model == null) {
|
||||
setModelDoesNotExists(id, loaded);
|
||||
return null;
|
||||
|
|
@ -914,7 +892,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.asList(policy);
|
||||
return List.of(policy);
|
||||
}, (revision, policies) -> new PolicyListQuery(revision, cacheKey, policies.stream().map(Policy::getId).collect(Collectors.toSet()), resourceServerId), resourceServer);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
|
|
@ -948,14 +926,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getPolicyByResource(resource.getId(), resourceServerId);
|
||||
cacheQuery(cacheKey, PolicyResourceListQuery.class, () -> {
|
||||
List<Policy> policies = new ArrayList<>();
|
||||
getPolicyStoreDelegate().findByResource(resourceServer, resource, new Consumer<Policy>() {
|
||||
@Override
|
||||
public void accept(Policy policy) {
|
||||
consumer.andThen(policies::add)
|
||||
getPolicyStoreDelegate().findByResource(resourceServer, resource,
|
||||
policy -> consumer.andThen(policies::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cachePolicy)
|
||||
.accept(policy);
|
||||
}
|
||||
});
|
||||
.accept(policy));
|
||||
return policies;
|
||||
},
|
||||
(revision, policies) -> new PolicyResourceListQuery(revision, cacheKey, resource.getId(), policies.stream().map(Policy::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -975,14 +949,10 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
String cacheKey = getPolicyByResourceType(resourceType, resourceServerId);
|
||||
cacheQuery(cacheKey, PolicyResourceListQuery.class, () -> {
|
||||
List<Policy> policies = new ArrayList<>();
|
||||
getPolicyStoreDelegate().findByResourceType(resourceServer, resourceType, new Consumer<Policy>() {
|
||||
@Override
|
||||
public void accept(Policy policy) {
|
||||
consumer.andThen(policies::add)
|
||||
getPolicyStoreDelegate().findByResourceType(resourceServer, resourceType,
|
||||
policy -> consumer.andThen(policies::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cachePolicy)
|
||||
.accept(policy);
|
||||
}
|
||||
});
|
||||
.accept(policy));
|
||||
return policies;
|
||||
},
|
||||
(revision, policies) -> new PolicyResourceListQuery(revision, cacheKey, resourceType, policies.stream().map(Policy::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
|
|
@ -996,7 +966,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
|
||||
for (Scope scope : scopes) {
|
||||
String cacheKey = getPolicyByScope(scope.getId(), resourceServerId);
|
||||
result.addAll(cacheQuery(cacheKey, PolicyScopeListQuery.class, () -> getPolicyStoreDelegate().findByScopes(resourceServer, Collections.singletonList(scope)), (revision, resources) -> new PolicyScopeListQuery(revision, cacheKey, scope.getId(), resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServer));
|
||||
result.addAll(cacheQuery(cacheKey, PolicyScopeListQuery.class, () -> getPolicyStoreDelegate().findByScopes(resourceServer, Collections.singletonList(scope)), (revision, resources) -> new PolicyScopeListQuery(revision, cacheKey, scope.getId(), resources.stream().map(Policy::getId).collect(Collectors.toSet()), resourceServerId), resourceServer));
|
||||
}
|
||||
|
||||
return new ArrayList<>(result);
|
||||
|
|
@ -1025,11 +995,9 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
cacheQuery(cacheKey, PolicyScopeListQuery.class, () -> {
|
||||
List<Policy> policies = new ArrayList<>();
|
||||
getPolicyStoreDelegate().findByScopes(resourceServer, resource, Collections.singletonList(scope),
|
||||
policy -> {
|
||||
consumer.andThen(policies::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cachePolicy)
|
||||
.accept(policy);
|
||||
});
|
||||
policy -> consumer.andThen(policies::add)
|
||||
.andThen(StoreFactoryCacheSession.this::cachePolicy)
|
||||
.accept(policy));
|
||||
return policies;
|
||||
}, (revision, resources) -> new PolicyScopeListQuery(revision, cacheKey, scope.getId(), resources.stream().map(Policy::getId).collect(Collectors.toSet()), resourceServerId), resourceServer, consumer);
|
||||
}
|
||||
|
|
@ -1070,7 +1038,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
}
|
||||
List<R> model = Collections.emptyList();
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
model = resultSupplier.get();
|
||||
if (model == null) return null;
|
||||
if (!invalidations.contains(cacheKey)) {
|
||||
|
|
@ -1141,7 +1109,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
logger.tracev("by id cache hit: {0}", cached.getId());
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (! modelMightExist(id)) return null;
|
||||
PermissionTicket model = getPermissionTicketStoreDelegate().findById(resourceServer, id);
|
||||
if (model == null) {
|
||||
|
|
@ -1214,7 +1182,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
logger.tracev("cache hit for key: {0}", cacheKey);
|
||||
}
|
||||
if (query == null) {
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
List<R> model = resultSupplier.get();
|
||||
if (model == null) return null;
|
||||
if (invalidations.contains(cacheKey)) return model;
|
||||
|
|
@ -1242,7 +1210,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
}
|
||||
|
||||
CachedPolicy createCachedPolicy(Policy model, String id) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
return new CachedPolicy(loaded, model);
|
||||
}
|
||||
|
||||
|
|
@ -1251,7 +1219,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
if (cache.getCache().containsKey(id)) {
|
||||
return;
|
||||
}
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (!modelMightExist(id)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1264,7 +1232,7 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider {
|
|||
if (cache.getCache().containsKey(id)) {
|
||||
return;
|
||||
}
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
long loaded = cache.getCurrentRevision(id);
|
||||
if (!modelMightExist(id)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class CachedPermissionTicket extends AbstractRevisioned implements InReso
|
|||
private Long grantedTimestamp;
|
||||
private String policy;
|
||||
|
||||
public CachedPermissionTicket(Long revision, PermissionTicket permissionTicket) {
|
||||
public CachedPermissionTicket(long revision, PermissionTicket permissionTicket) {
|
||||
super(revision, permissionTicket.getId());
|
||||
this.owner = permissionTicket.getOwner();
|
||||
requester = permissionTicket.getRequester();
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class CachedPolicy extends AbstractRevisioned implements InResourceServer
|
|||
private final LazyLoader<Policy, Map<String, String>> config;
|
||||
private final String owner;
|
||||
|
||||
public CachedPolicy(Long revision, Policy policy) {
|
||||
public CachedPolicy(long revision, Policy policy) {
|
||||
super(revision, policy.getId());
|
||||
this.type = policy.getType();
|
||||
this.decisionStrategy = policy.getDecisionStrategy();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class CachedResource extends AbstractRevisioned implements InResourceServ
|
|||
private LazyLoader<Resource, Set<String>> uris;
|
||||
private LazyLoader<Resource, MultivaluedHashMap<String, String>> attributes;
|
||||
|
||||
public CachedResource(Long revision, Resource resource) {
|
||||
public CachedResource(long revision, Resource resource) {
|
||||
super(revision, resource.getId());
|
||||
this.name = resource.getName();
|
||||
this.displayName = resource.getDisplayName();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class CachedResourceServer extends AbstractRevisioned {
|
|||
private final PolicyEnforcementMode policyEnforcementMode;
|
||||
private final DecisionStrategy decisionStrategy;
|
||||
|
||||
public CachedResourceServer(Long revision, ResourceServer resourceServer) {
|
||||
public CachedResourceServer(long revision, ResourceServer resourceServer) {
|
||||
super(revision, resourceServer.getId());
|
||||
this.allowRemoteResourceManagement = resourceServer.isAllowRemoteResourceManagement();
|
||||
this.policyEnforcementMode = resourceServer.getPolicyEnforcementMode();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class CachedScope extends AbstractRevisioned implements InResourceServer
|
|||
private String displayName;
|
||||
private String iconUri;
|
||||
|
||||
public CachedScope(Long revision, Scope scope) {
|
||||
public CachedScope(long revision, Scope scope) {
|
||||
super(revision, scope.getId());
|
||||
this.name = scope.getName();
|
||||
this.displayName = scope.getDisplayName();
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ public class PermissionTicketListQuery extends AbstractRevisioned implements Per
|
|||
private final Set<String> permissions;
|
||||
private final String serverId;
|
||||
|
||||
public PermissionTicketListQuery(Long revision, String id, String permissionId, String serverId) {
|
||||
public PermissionTicketListQuery(long revision, String id, String permissionId, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
permissions = new HashSet<>();
|
||||
permissions.add(permissionId);
|
||||
}
|
||||
public PermissionTicketListQuery(Long revision, String id, Set<String> permissions, String serverId) {
|
||||
public PermissionTicketListQuery(long revision, String id, Set<String> permissions, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
this.permissions = permissions;
|
||||
|
|
@ -39,4 +39,4 @@ public class PermissionTicketListQuery extends AbstractRevisioned implements Per
|
|||
public boolean isInvalid(Set<String> invalidations) {
|
||||
return invalidations.contains(getId()) || invalidations.contains(getResourceServerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PermissionTicketResourceListQuery extends PermissionTicketListQuery
|
|||
|
||||
private final String resourceId;
|
||||
|
||||
public PermissionTicketResourceListQuery(Long revision, String id, String resourceId, Set<String> permissions, String serverId) {
|
||||
public PermissionTicketResourceListQuery(long revision, String id, String resourceId, Set<String> permissions, String serverId) {
|
||||
super(revision, id, permissions, serverId);
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
|
@ -39,4 +39,4 @@ public class PermissionTicketResourceListQuery extends PermissionTicketListQuery
|
|||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PermissionTicketScopeListQuery extends PermissionTicketListQuery im
|
|||
|
||||
private final String scopeId;
|
||||
|
||||
public PermissionTicketScopeListQuery(Long revision, String id, String scopeId, Set<String> permissions, String serverId) {
|
||||
public PermissionTicketScopeListQuery(long revision, String id, String scopeId, Set<String> permissions, String serverId) {
|
||||
super(revision, id, permissions, serverId);
|
||||
this.scopeId = scopeId;
|
||||
}
|
||||
|
|
@ -39,4 +39,4 @@ public class PermissionTicketScopeListQuery extends PermissionTicketListQuery im
|
|||
public String getScopeId() {
|
||||
return scopeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ public class PolicyListQuery extends AbstractRevisioned implements PolicyQuery {
|
|||
private final Set<String> policies;
|
||||
private final String serverId;
|
||||
|
||||
public PolicyListQuery(Long revision, String id, String policyId, String serverId) {
|
||||
public PolicyListQuery(long revision, String id, String policyId, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
policies = new HashSet<>();
|
||||
policies.add(policyId);
|
||||
}
|
||||
public PolicyListQuery(Long revision, String id, Set<String> policies, String serverId) {
|
||||
public PolicyListQuery(long revision, String id, Set<String> policies, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
this.policies = policies;
|
||||
|
|
@ -38,4 +38,4 @@ public class PolicyListQuery extends AbstractRevisioned implements PolicyQuery {
|
|||
public boolean isInvalid(Set<String> invalidations) {
|
||||
return invalidations.contains(getId()) || invalidations.contains(getResourceServerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PolicyResourceListQuery extends PolicyListQuery implements InResour
|
|||
|
||||
private final String resourceId;
|
||||
|
||||
public PolicyResourceListQuery(Long revision, String id, String resourceId, Set<String> policies, String serverId) {
|
||||
public PolicyResourceListQuery(long revision, String id, String resourceId, Set<String> policies, String serverId) {
|
||||
super(revision, id, policies, serverId);
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
|
@ -39,4 +39,4 @@ public class PolicyResourceListQuery extends PolicyListQuery implements InResour
|
|||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PolicyScopeListQuery extends PolicyListQuery implements InScope {
|
|||
|
||||
private final String scopeId;
|
||||
|
||||
public PolicyScopeListQuery(Long revision, String id, String scopeId, Set<String> resources, String serverId) {
|
||||
public PolicyScopeListQuery(long revision, String id, String scopeId, Set<String> resources, String serverId) {
|
||||
super(revision, id, resources, serverId);
|
||||
this.scopeId = scopeId;
|
||||
}
|
||||
|
|
@ -39,4 +39,4 @@ public class PolicyScopeListQuery extends PolicyListQuery implements InScope {
|
|||
public boolean isInvalid(Set<String> invalidations) {
|
||||
return super.isInvalid(invalidations) || invalidations.contains(getScopeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ public class ResourceListQuery extends AbstractRevisioned implements ResourceQue
|
|||
private final Set<String> resources;
|
||||
private final String serverId;
|
||||
|
||||
public ResourceListQuery(Long revision, String id, String resourceId, String serverId) {
|
||||
public ResourceListQuery(long revision, String id, String resourceId, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
resources = new HashSet<>();
|
||||
resources.add(resourceId);
|
||||
}
|
||||
public ResourceListQuery(Long revision, String id, Set<String> resources, String serverId) {
|
||||
public ResourceListQuery(long revision, String id, Set<String> resources, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
this.resources = resources;
|
||||
|
|
@ -38,4 +38,4 @@ public class ResourceListQuery extends AbstractRevisioned implements ResourceQue
|
|||
public boolean isInvalid(Set<String> invalidations) {
|
||||
return invalidations.contains(getId()) || invalidations.contains(getResourceServerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class ResourceScopeListQuery extends ResourceListQuery implements InScope
|
|||
|
||||
private final String scopeId;
|
||||
|
||||
public ResourceScopeListQuery(Long revision, String id, String scopeId, Set<String> resources, String serverId) {
|
||||
public ResourceScopeListQuery(long revision, String id, String scopeId, Set<String> resources, String serverId) {
|
||||
super(revision, id, resources, serverId);
|
||||
this.scopeId = scopeId;
|
||||
}
|
||||
|
|
@ -23,4 +23,4 @@ public class ResourceScopeListQuery extends ResourceListQuery implements InScope
|
|||
public boolean isInvalid(Set<String> invalidations) {
|
||||
return super.isInvalid(invalidations) || invalidations.contains(getScopeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ public class ScopeListQuery extends AbstractRevisioned implements InResourceServ
|
|||
private final Set<String> scopes;
|
||||
private final String serverId;
|
||||
|
||||
public ScopeListQuery(Long revision, String id, String scopeId, String serverId) {
|
||||
public ScopeListQuery(long revision, String id, String scopeId, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
scopes = new HashSet<>();
|
||||
scopes.add(scopeId);
|
||||
}
|
||||
public ScopeListQuery(Long revision, String id, Set<String> scopes, String serverId) {
|
||||
public ScopeListQuery(long revision, String id, Set<String> scopes, String serverId) {
|
||||
super(revision, id);
|
||||
this.serverId = serverId;
|
||||
this.scopes = scopes;
|
||||
|
|
@ -33,4 +33,4 @@ public class ScopeListQuery extends AbstractRevisioned implements InResourceServ
|
|||
public Set<String> getScopes() {
|
||||
return scopes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ abstract class AbstractCachedClientScope<D extends ClientScopeModel> extends Abs
|
|||
private final LazyLoader<D, Map<String, String>> mappersByName;
|
||||
private final LazyLoader<D, Map<String, List<String>>> mappersByType;
|
||||
|
||||
public AbstractCachedClientScope(Long revision, ClientScopeModel model) {
|
||||
public AbstractCachedClientScope(long revision, ClientScopeModel model) {
|
||||
super(revision, model.getId());
|
||||
mappersById = new DefaultLazyLoader<>(scope -> scope.getProtocolMappersStream()
|
||||
.collect(Collectors.toMap(ProtocolMapperModel::getId, ProtocolMapperModel::new)),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public abstract class AbstractExtendableRevisioned extends AbstractRevisioned {
|
||||
protected ConcurrentHashMap cachedWith = new ConcurrentHashMap();
|
||||
|
||||
public AbstractExtendableRevisioned(Long revision, String id) {
|
||||
public AbstractExtendableRevisioned(long revision, String id) {
|
||||
super(revision, id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import org.keycloak.models.cache.CachedObject;
|
|||
*/
|
||||
public class AbstractRevisioned implements Revisioned, CachedObject {
|
||||
private final String id;
|
||||
private Long revision;
|
||||
private long revision;
|
||||
private final long cacheTimestamp = Time.currentTimeMillis();
|
||||
|
||||
public AbstractRevisioned(Long revision, String id) {
|
||||
public AbstractRevisioned(long revision, String id) {
|
||||
this.revision = revision;
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -24,12 +24,12 @@ public class AbstractRevisioned implements Revisioned, CachedObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Long getRevision() {
|
||||
public long getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRevision(Long revision) {
|
||||
public void setRevision(long revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class CachedClient extends AbstractCachedClientScope<ClientModel> {
|
|||
protected int nodeReRegistrationTimeout;
|
||||
protected Map<String, Integer> registeredNodes;
|
||||
|
||||
public CachedClient(Long revision, RealmModel realm, ClientModel model) {
|
||||
public CachedClient(long revision, RealmModel realm, ClientModel model) {
|
||||
super(revision, model);
|
||||
clientAuthenticatorType = model.getClientAuthenticatorType();
|
||||
secret = model.getSecret();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class CachedClientRole extends CachedRole implements InClient {
|
|||
|
||||
private final String clientId;
|
||||
|
||||
public CachedClientRole(Long revision, String clientId, RoleModel model, RealmModel realm) {
|
||||
public CachedClientRole(long revision, String clientId, RoleModel model, RealmModel realm) {
|
||||
super(revision, model, realm);
|
||||
this.clientId = clientId;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class CachedClientScope extends AbstractCachedClientScope<ClientScopeMode
|
|||
private Set<String> scope = new HashSet<>();
|
||||
private Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
public CachedClientScope(Long revision, RealmModel realm, ClientScopeModel model) {
|
||||
public CachedClientScope(long revision, RealmModel realm, ClientScopeModel model) {
|
||||
super(revision, model);
|
||||
name = model.getName();
|
||||
description = model.getDescription();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class CachedFederatedIdentityLinks extends AbstractRevisioned implements
|
|||
private final String realmId;
|
||||
private final Set<FederatedIdentityModel> federatedIdentities = new HashSet<>();
|
||||
|
||||
public CachedFederatedIdentityLinks(Long revision, String id, RealmModel realm, Set<FederatedIdentityModel> federatedIdentities) {
|
||||
public CachedFederatedIdentityLinks(long revision, String id, RealmModel realm, Set<FederatedIdentityModel> federatedIdentities) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
this.federatedIdentities.addAll(federatedIdentities);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class CachedGroup extends AbstractRevisioned implements InRealm {
|
|||
private final Type type;
|
||||
private final String organizationId;
|
||||
|
||||
public CachedGroup(Long revision, RealmModel realm, GroupModel group) {
|
||||
public CachedGroup(long revision, RealmModel realm, GroupModel group) {
|
||||
super(revision, group.getId());
|
||||
this.realm = realm.getId();
|
||||
this.name = group.getName();
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class CachedRealm extends AbstractExtendableRevisioned {
|
|||
|
||||
protected Map<String, Map<String,String>> realmLocalizationTexts;
|
||||
|
||||
public CachedRealm(Long revision, RealmModel model) {
|
||||
public CachedRealm(long revision, RealmModel model) {
|
||||
super(revision, model.getId());
|
||||
name = model.getName();
|
||||
displayName = model.getDisplayName();
|
||||
|
|
@ -243,7 +243,7 @@ public class CachedRealm extends AbstractExtendableRevisioned {
|
|||
emailTheme = model.getEmailTheme();
|
||||
|
||||
requiredCredentials = model.getRequiredCredentialsStream().collect(Collectors.toList());
|
||||
userActionTokenLifespans = Collections.unmodifiableMap(new HashMap<>(model.getUserActionTokenLifespans()));
|
||||
userActionTokenLifespans = Map.copyOf(model.getUserActionTokenLifespans());
|
||||
|
||||
smtpConfig = model.getSmtpConfig();
|
||||
browserSecurityHeaders = model.getBrowserSecurityHeaders();
|
||||
|
|
@ -288,11 +288,11 @@ public class CachedRealm extends AbstractExtendableRevisioned {
|
|||
|
||||
authenticatorConfigs = model.getAuthenticatorConfigsStream()
|
||||
.collect(Collectors.toMap(AuthenticatorConfigModel::getId, Function.identity()));
|
||||
List<RequiredActionConfigModel> requiredActionConfigsList = model.getRequiredActionConfigsStream().collect(Collectors.toList());
|
||||
for (RequiredActionConfigModel requiredActionConfig : requiredActionConfigsList) {
|
||||
requiredActionProviderConfigs.put(requiredActionConfig.getId(), requiredActionConfig);
|
||||
requiredActionProviderConfigsByAlias.put(requiredActionConfig.getAlias(), requiredActionConfig);
|
||||
}
|
||||
model.getRequiredActionConfigsStream()
|
||||
.forEach(requiredActionConfig -> {
|
||||
requiredActionProviderConfigs.put(requiredActionConfig.getId(), requiredActionConfig);
|
||||
requiredActionProviderConfigsByAlias.put(requiredActionConfig.getAlias(), requiredActionConfig);
|
||||
});
|
||||
|
||||
requiredActionProviderList = model.getRequiredActionProvidersStream().collect(Collectors.toList());
|
||||
for (RequiredActionProviderModel action : requiredActionProviderList) {
|
||||
|
|
@ -316,7 +316,7 @@ public class CachedRealm extends AbstractExtendableRevisioned {
|
|||
model.getComponentsStream().forEach(component ->
|
||||
componentsByParent.add(component.getParentId(), component)
|
||||
);
|
||||
components = model.getComponentsStream().collect(Collectors.toMap(component -> component.getId(), Function.identity()));
|
||||
components = model.getComponentsStream().collect(Collectors.toMap(ComponentModel::getId, Function.identity()));
|
||||
|
||||
try {
|
||||
attributes = model.getAttributes();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.keycloak.models.RoleModel;
|
|||
public class CachedRealmRole extends CachedRole {
|
||||
|
||||
|
||||
public CachedRealmRole(Long revision, RoleModel model, RealmModel realm) {
|
||||
public CachedRealmRole(long revision, RoleModel model, RealmModel realm) {
|
||||
super(revision, model, realm);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class CachedRole extends AbstractRevisioned implements InRealm {
|
|||
private Set<String> cachedComposites = new HashSet<>();
|
||||
private final LazyLoader<RoleModel, MultivaluedHashMap<String, String>> attributes;
|
||||
|
||||
public CachedRole(Long revision, RoleModel model, RealmModel realm) {
|
||||
public CachedRole(long revision, RoleModel model, RealmModel realm) {
|
||||
super(revision, model.getId());
|
||||
composite = model.isComposite();
|
||||
description = model.getDescription();
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class CachedUser extends AbstractExtendableRevisioned implements InRealm
|
|||
private final LazyLoader<UserModel, Set<String>> groups;
|
||||
private final LazyLoader<UserModel, List<CredentialModel>> storedCredentials;
|
||||
|
||||
public CachedUser(Long revision, RealmModel realm, UserModel user, int notBefore) {
|
||||
public CachedUser(long revision, RealmModel realm, UserModel user, int notBefore) {
|
||||
super(revision, user.getId());
|
||||
this.realm = realm.getId();
|
||||
this.createdTimestamp = user.getCreatedTimestamp();
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ public class CachedUserConsents extends AbstractRevisioned implements InRealm {
|
|||
private final String realmId;
|
||||
private boolean allConsents;
|
||||
|
||||
public CachedUserConsents(Long revision, String id, RealmModel realm,
|
||||
public CachedUserConsents(long revision, String id, RealmModel realm,
|
||||
List<CachedUserConsent> consents) {
|
||||
this(revision, id, realm, consents, true);
|
||||
}
|
||||
|
||||
public CachedUserConsents(Long revision, String id, RealmModel realm,
|
||||
public CachedUserConsents(long revision, String id, RealmModel realm,
|
||||
List<CachedUserConsent> consents, boolean allConsents) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ public class ClientListQuery extends AbstractRevisioned implements ClientQuery {
|
|||
private final Set<String> clients;
|
||||
private final String realm;
|
||||
|
||||
public ClientListQuery(Long revisioned, String id, RealmModel realm, Set<String> clients) {
|
||||
public ClientListQuery(long revisioned, String id, RealmModel realm, Set<String> clients) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.clients = clients;
|
||||
}
|
||||
|
||||
public ClientListQuery(Long revisioned, String id, RealmModel realm, String client) {
|
||||
public ClientListQuery(long revisioned, String id, RealmModel realm, String client) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.clients = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@ public class ClientScopeListQuery extends AbstractRevisioned implements ClientSc
|
|||
private final String realm;
|
||||
private String clientUuid;
|
||||
|
||||
public ClientScopeListQuery(Long revisioned, String id, RealmModel realm, Set<String> clientScopes) {
|
||||
public ClientScopeListQuery(long revisioned, String id, RealmModel realm, Set<String> clientScopes) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.clientScopes = clientScopes;
|
||||
}
|
||||
|
||||
public ClientScopeListQuery(Long revisioned, String id, RealmModel realm, String clientUuid, Set<String> clientScopes) {
|
||||
public ClientScopeListQuery(long revisioned, String id, RealmModel realm, String clientUuid, Set<String> clientScopes) {
|
||||
this(revisioned, id, realm, clientScopes);
|
||||
this.clientUuid = clientUuid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
|
|||
private final String realm;
|
||||
private final Map<String, Set<String>> searchKeys;
|
||||
|
||||
public GroupListQuery(Long revisioned, String id, RealmModel realm, String searchKey, Set<String> result) {
|
||||
public GroupListQuery(long revisioned, String id, RealmModel realm, String searchKey, Set<String> result) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.searchKeys = new HashMap<>();
|
||||
this.searchKeys.put(searchKey, result);
|
||||
}
|
||||
|
||||
public GroupListQuery(Long revisioned, String id, RealmModel realm, String searchKey, Set<String> result, GroupListQuery previous) {
|
||||
public GroupListQuery(long revisioned, String id, RealmModel realm, String searchKey, Set<String> result, GroupListQuery previous) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.searchKeys = new HashMap<>();
|
||||
|
|
@ -31,7 +31,7 @@ public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
|
|||
this.searchKeys.put(searchKey, result);
|
||||
}
|
||||
|
||||
public GroupListQuery(Long revisioned, String id, RealmModel realm, Set<String> ids) {
|
||||
public GroupListQuery(long revisioned, String id, RealmModel realm, Set<String> ids) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.searchKeys = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class GroupNameQuery extends AbstractRevisioned implements InRealm {
|
|||
private final String realm;
|
||||
private final String groupId;
|
||||
|
||||
public GroupNameQuery(Long revisioned, String id, String groupId, RealmModel realm) {
|
||||
public GroupNameQuery(long revisioned, String id, String groupId, RealmModel realm) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.groupId = groupId;
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ public class NonExistentItem implements Revisioned {
|
|||
|
||||
private final String id;
|
||||
|
||||
private Long revision;
|
||||
private long revision;
|
||||
|
||||
public NonExistentItem(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public NonExistentItem(String id, Long revision) {
|
||||
public NonExistentItem(String id, long revision) {
|
||||
this.id = id;
|
||||
this.revision = revision;
|
||||
}
|
||||
|
|
@ -41,12 +41,12 @@ public class NonExistentItem implements Revisioned {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Long getRevision() {
|
||||
public long getRevision() {
|
||||
return this.revision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRevision(Long revision) {
|
||||
public void setRevision(long revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import java.util.Set;
|
|||
public class RealmListQuery extends AbstractRevisioned implements RealmQuery {
|
||||
private final Set<String> realms;
|
||||
|
||||
public RealmListQuery(Long revision, String id, String realm) {
|
||||
public RealmListQuery(long revision, String id, String realm) {
|
||||
super(revision, id);
|
||||
realms = new HashSet<>();
|
||||
realms.add(realm);
|
||||
}
|
||||
public RealmListQuery(Long revision, String id, Set<String> realms) {
|
||||
public RealmListQuery(long revision, String id, Set<String> realms) {
|
||||
super(revision, id);
|
||||
this.realms = realms;
|
||||
}
|
||||
|
|
@ -24,4 +24,4 @@ public class RealmListQuery extends AbstractRevisioned implements RealmQuery {
|
|||
public Set<String> getRealms() {
|
||||
return realms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ package org.keycloak.models.cache.infinispan.entities;
|
|||
*/
|
||||
public interface Revisioned {
|
||||
String getId();
|
||||
Long getRevision();
|
||||
void setRevision(Long revision);
|
||||
long getRevision();
|
||||
void setRevision(long revision);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ public class RoleByNameQuery extends AbstractRevisioned implements RoleQuery, In
|
|||
private final String realm;
|
||||
private String client;
|
||||
|
||||
public RoleByNameQuery(Long revisioned, String id, RealmModel realm, String role) {
|
||||
public RoleByNameQuery(long revisioned, String id, RealmModel realm, String role) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public RoleByNameQuery(Long revision, String id, RealmModel realm, String role, String client) {
|
||||
public RoleByNameQuery(long revision, String id, RealmModel realm, String role, String client) {
|
||||
this(revision, id, realm, role);
|
||||
this.client = client;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,25 +14,25 @@ public class RoleListQuery extends AbstractRevisioned implements RoleQuery, InCl
|
|||
private final String realm;
|
||||
private String client;
|
||||
|
||||
public RoleListQuery(Long revisioned, String id, RealmModel realm, Set<String> roles) {
|
||||
public RoleListQuery(long revisioned, String id, RealmModel realm, Set<String> roles) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public RoleListQuery(Long revisioned, String id, RealmModel realm, String role) {
|
||||
public RoleListQuery(long revisioned, String id, RealmModel realm, String role) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.roles = new HashSet<>();
|
||||
this.roles.add(role);
|
||||
}
|
||||
|
||||
public RoleListQuery(Long revision, String id, RealmModel realm, Set<String> roles, String client) {
|
||||
public RoleListQuery(long revision, String id, RealmModel realm, Set<String> roles, String client) {
|
||||
this(revision, id, realm, roles);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public RoleListQuery(Long revision, String id, RealmModel realm, String role, String client) {
|
||||
public RoleListQuery(long revision, String id, RealmModel realm, String role, String client) {
|
||||
this(revision, id, realm, role);
|
||||
this.client = client;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package org.keycloak.models.cache.infinispan.entities;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.RealmModel;
|
||||
|
|
@ -10,25 +9,25 @@ import org.keycloak.models.RealmModel;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class UserListQuery extends AbstractRevisioned implements UserQuery {
|
||||
private final Set<String> users;
|
||||
private final String userId;
|
||||
private final String realm;
|
||||
|
||||
public UserListQuery(Long revisioned, String id, RealmModel realm, Set<String> users) {
|
||||
@Deprecated(forRemoval = true, since = "26.5")
|
||||
public UserListQuery(long revisioned, String id, RealmModel realm, Set<String> users) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.users = users;
|
||||
this.userId = users.stream().findAny().orElse(null);
|
||||
}
|
||||
|
||||
public UserListQuery(Long revisioned, String id, RealmModel realm, String user) {
|
||||
public UserListQuery(long revisioned, String id, RealmModel realm, String userId) {
|
||||
super(revisioned, id);
|
||||
this.realm = realm.getId();
|
||||
this.users = new HashSet<>();
|
||||
this.users.add(user);
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUsers() {
|
||||
return users;
|
||||
return Set.of(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CachedIdentityProvider extends AbstractRevisioned implements InReal
|
|||
private final String realm;
|
||||
private final IdentityProviderModel idp;
|
||||
|
||||
public CachedIdentityProvider(Long revision, RealmModel realm, String cacheKey, IdentityProviderModel idp) {
|
||||
public CachedIdentityProvider(long revision, RealmModel realm, String cacheKey, IdentityProviderModel idp) {
|
||||
super(revision, cacheKey);
|
||||
this.realm = realm.getId();
|
||||
this.idp = idp;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CachedIdentityProviderMapper extends AbstractRevisioned implements
|
|||
private final String realm;
|
||||
private final IdentityProviderMapperModel mapper;
|
||||
|
||||
public CachedIdentityProviderMapper(Long revision, RealmModel realm, String cacheKey, IdentityProviderMapperModel mapper) {
|
||||
public CachedIdentityProviderMapper(long revision, RealmModel realm, String cacheKey, IdentityProviderMapperModel mapper) {
|
||||
super(revision, cacheKey);
|
||||
this.realm = realm.getId();
|
||||
this.mapper = mapper;
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ public class IdentityProviderListQuery extends AbstractRevisioned implements InR
|
|||
private final String realmId;
|
||||
private final Map<String, Set<String>> searchKeys;
|
||||
|
||||
public IdentityProviderListQuery(Long revision, String id, RealmModel realm, String searchKey, Set<String> result) {
|
||||
public IdentityProviderListQuery(long revision, String id, RealmModel realm, String searchKey, Set<String> result) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
this.searchKeys = new HashMap<>();
|
||||
this.searchKeys.put(searchKey, result);
|
||||
}
|
||||
|
||||
public IdentityProviderListQuery(Long revision, String id, RealmModel realm, String searchKey, Set<String> result, IdentityProviderListQuery previous) {
|
||||
public IdentityProviderListQuery(long revision, String id, RealmModel realm, String searchKey, Set<String> result, IdentityProviderListQuery previous) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
this.searchKeys = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(internalId);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(internalId);
|
||||
IdentityProviderModel model = idpDelegate.getById(internalId);
|
||||
if (model == null) return null;
|
||||
if (isInvalid(internalId)) return createOrganizationAwareIdentityProviderModel(model);
|
||||
|
|
@ -160,7 +160,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
CachedIdentityProvider cached = realmCache.getCache().get(cacheKey, CachedIdentityProvider.class);
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
IdentityProviderModel model = idpDelegate.getByAlias(alias);
|
||||
if (model == null) {
|
||||
return null;
|
||||
|
|
@ -183,7 +183,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
CachedCount cached = realmCache.getCache().get(cacheKey, CachedCount.class);
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long count = idpDelegate.getAllStream(IdentityProviderQuery.capability(IdentityProviderCapability.USER_LINKING), 0, 1).count();
|
||||
cached = new CachedCount(loaded, getRealm(), cacheKey, count);
|
||||
realmCache.getCache().addRevisioned(cached, realmCache.getStartupRevision());
|
||||
|
|
@ -209,7 +209,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
|
||||
if (query == null) {
|
||||
// not cached yet
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
cached = idpDelegate.getByOrganization(orgId, first, max).map(IdentityProviderModel::getInternalId).collect(Collectors.toSet());
|
||||
query = new IdentityProviderListQuery(loaded, cacheKey, realm, searchKey, cached);
|
||||
cache.addRevisioned(query, startupRevision);
|
||||
|
|
@ -218,7 +218,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
if (cached == null) {
|
||||
// there is a cache entry, but the current search is not yet cached
|
||||
cache.invalidateObject(cacheKey);
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
cached = idpDelegate.getByOrganization(orgId, first, max).map(IdentityProviderModel::getInternalId)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
query = new IdentityProviderListQuery(loaded, cacheKey, realm, searchKey, cached, query);
|
||||
|
|
@ -254,7 +254,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
|
||||
if (query == null) {
|
||||
// not cached yet
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
cached = idpDelegate.getForLogin(mode, organizationId).map(IdentityProviderModel::getInternalId)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
query = new IdentityProviderListQuery(loaded, cacheKey, getRealm(), searchKey, cached);
|
||||
|
|
@ -264,7 +264,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
if (cached == null) {
|
||||
// there is a cache entry, but the current search is not yet cached
|
||||
cache.invalidateObject(cacheKey);
|
||||
Long loaded = cache.getCurrentRevision(cacheKey);
|
||||
long loaded = cache.getCurrentRevision(cacheKey);
|
||||
cached = idpDelegate.getForLogin(mode, organizationId).map(IdentityProviderModel::getInternalId).collect(Collectors.toSet());
|
||||
query = new IdentityProviderListQuery(loaded, cacheKey, getRealm(), searchKey, cached, query);
|
||||
cache.addRevisioned(query, cache.getCurrentCounter());
|
||||
|
|
@ -304,7 +304,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
return cached.getCount();
|
||||
}
|
||||
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long count = idpDelegate.count();
|
||||
cached = new CachedCount(loaded, getRealm(), cacheKey, count);
|
||||
realmCache.getCache().addRevisioned(cached, realmCache.getStartupRevision());
|
||||
|
|
@ -349,7 +349,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(id);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(id);
|
||||
IdentityProviderMapperModel model = idpDelegate.getMapperById(id);
|
||||
if (model == null) return null;
|
||||
if (isInvalid(id)) return model;
|
||||
|
|
@ -372,7 +372,7 @@ public class InfinispanIdentityProviderStorageProvider implements IdentityProvid
|
|||
CachedIdentityProviderMapper cached = realmCache.getCache().get(cacheKey, CachedIdentityProviderMapper.class);
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
long loaded = realmCache.getCache().getCurrentRevision(cacheKey);
|
||||
IdentityProviderMapperModel model = idpDelegate.getMapperByName(identityProviderAlias, name);
|
||||
if (model == null) return null;
|
||||
cached = new CachedIdentityProviderMapper(loaded, getRealm(), cacheKey, model);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class CachedMembership extends AbstractRevisioned implements InRealm {
|
|||
private final boolean managed;
|
||||
private final boolean isMember;
|
||||
|
||||
public CachedMembership(Long revision, String key, RealmModel realm, boolean managed, boolean isMember) {
|
||||
public CachedMembership(long revision, String key, RealmModel realm, boolean managed, boolean isMember) {
|
||||
super(revision, key);
|
||||
this.realm = realm.getId();
|
||||
this.managed = managed;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class CachedOrganization extends AbstractRevisioned implements InRealm {
|
|||
private final Set<OrganizationDomainModel> domains;
|
||||
private final Set<IdentityProviderModel> idps;
|
||||
|
||||
public CachedOrganization(Long revision, RealmModel realm, OrganizationModel organization) {
|
||||
public CachedOrganization(long revision, RealmModel realm, OrganizationModel organization) {
|
||||
super(revision, organization.getId());
|
||||
this.realm = realm.getId();
|
||||
this.name = organization.getName();
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ public class CachedOrganizationIds extends AbstractRevisioned implements InRealm
|
|||
private final String realmId;
|
||||
private final List<String> orgIds;
|
||||
|
||||
public CachedOrganizationIds(Long revision, String id, RealmModel realm, OrganizationModel model) {
|
||||
public CachedOrganizationIds(long revision, String id, RealmModel realm, OrganizationModel model) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
orgIds = List.of(model.getId());
|
||||
}
|
||||
|
||||
public CachedOrganizationIds(Long revision, String id, RealmModel realm, Stream<OrganizationModel> models) {
|
||||
public CachedOrganizationIds(long revision, String id, RealmModel realm, Stream<OrganizationModel> models) {
|
||||
super(revision, id);
|
||||
this.realmId = realm.getId();
|
||||
var ids = models.map(OrganizationModel::getId).collect(Collectors.toSet());
|
||||
|
|
|
|||
Loading…
Reference in a new issue