KEYCLOAK-2632 Remove flag from UserCacheSession.invalidateUsers

This commit is contained in:
mposolda 2016-03-22 18:03:58 +01:00
parent 4c6dd10e48
commit f9595fc6c5

View file

@ -437,7 +437,7 @@ public class UserCacheSession implements CacheUserProvider {
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) { public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
UserModel user = getDelegate().addUser(realm, id, username, addDefaultRoles, addDefaultRoles); 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 // 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); managedUsers.put(user.getId(), user);
return user; return user;
} }
@ -446,26 +446,24 @@ public class UserCacheSession implements CacheUserProvider {
public UserModel addUser(RealmModel realm, String username) { public UserModel addUser(RealmModel realm, String username) {
UserModel user = getDelegate().addUser(realm, 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 // 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); managedUsers.put(user.getId(), user);
return 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 // just in case the transaction is rolled back you need to invalidate the user and all cache queries for that user
if (realm.isIdentityFederationEnabled()) { if (realm.isIdentityFederationEnabled()) {
// Invalidate all keys for lookup this user by any identityProvider link
Set<FederatedIdentityModel> federatedIdentities = getFederatedIdentities(user, realm);
for (FederatedIdentityModel socialLink : federatedIdentities) {
String fedIdentityCacheKey = getUserByFederatedIdentityCacheKey(realm.getId(), socialLink);
invalidations.add(fedIdentityCacheKey);
}
// Invalidate federationLinks of user // Invalidate federationLinks of user
invalidations.add(getFederatedIdentityLinksCacheKey(user.getId())); invalidations.add(getFederatedIdentityLinksCacheKey(user.getId()));
// Invalidate all keys for lookup this user by any identityProvider link
if (invalidateUserLookupsByFederatedIdentity) {
Set<FederatedIdentityModel> federatedIdentities = getFederatedIdentities(user, realm);
for (FederatedIdentityModel socialLink : federatedIdentities) {
String fedIdentityCacheKey = getUserByFederatedIdentityCacheKey(realm.getId(), socialLink);
invalidations.add(fedIdentityCacheKey);
}
}
} }
invalidations.add(user.getId()); invalidations.add(user.getId());
@ -475,7 +473,7 @@ public class UserCacheSession implements CacheUserProvider {
@Override @Override
public boolean removeUser(RealmModel realm, UserModel user) { public boolean removeUser(RealmModel realm, UserModel user) {
invalidateUser(realm, user, true); invalidateUser(realm, user);
return getDelegate().removeUser(realm, user); return getDelegate().removeUser(realm, user);
} }