From f9595fc6c5bcadbeec0d2ed057b9164166542d49 Mon Sep 17 00:00:00 2001 From: mposolda Date: Tue, 22 Mar 2016 18:03:58 +0100 Subject: [PATCH] KEYCLOAK-2632 Remove flag from UserCacheSession.invalidateUsers --- .../cache/infinispan/UserCacheSession.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserCacheSession.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserCacheSession.java index 5a9b218831..1a489ad698 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserCacheSession.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/UserCacheSession.java @@ -437,7 +437,7 @@ public class UserCacheSession implements CacheUserProvider { public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) { UserModel user = getDelegate().addUser(realm, id, username, addDefaultRoles, addDefaultRoles); // just in case the transaction is rolled back you need to invalidate the user and all cache queries for that user - invalidateUser(realm, user, false); + invalidateUser(realm, user); managedUsers.put(user.getId(), user); return user; } @@ -446,26 +446,24 @@ public class UserCacheSession implements CacheUserProvider { public UserModel addUser(RealmModel realm, String username) { UserModel user = getDelegate().addUser(realm, username); // just in case the transaction is rolled back you need to invalidate the user and all cache queries for that user - invalidateUser(realm, user, false); + invalidateUser(realm, user); managedUsers.put(user.getId(), user); return user; } - protected void invalidateUser(RealmModel realm, UserModel user, boolean invalidateUserLookupsByFederatedIdentity) { + protected void invalidateUser(RealmModel realm, UserModel user) { // just in case the transaction is rolled back you need to invalidate the user and all cache queries for that user if (realm.isIdentityFederationEnabled()) { + // Invalidate all keys for lookup this user by any identityProvider link + Set federatedIdentities = getFederatedIdentities(user, realm); + for (FederatedIdentityModel socialLink : federatedIdentities) { + String fedIdentityCacheKey = getUserByFederatedIdentityCacheKey(realm.getId(), socialLink); + invalidations.add(fedIdentityCacheKey); + } + // Invalidate federationLinks of user invalidations.add(getFederatedIdentityLinksCacheKey(user.getId())); - - // Invalidate all keys for lookup this user by any identityProvider link - if (invalidateUserLookupsByFederatedIdentity) { - Set federatedIdentities = getFederatedIdentities(user, realm); - for (FederatedIdentityModel socialLink : federatedIdentities) { - String fedIdentityCacheKey = getUserByFederatedIdentityCacheKey(realm.getId(), socialLink); - invalidations.add(fedIdentityCacheKey); - } - } } invalidations.add(user.getId()); @@ -475,7 +473,7 @@ public class UserCacheSession implements CacheUserProvider { @Override public boolean removeUser(RealmModel realm, UserModel user) { - invalidateUser(realm, user, true); + invalidateUser(realm, user); return getDelegate().removeUser(realm, user); }