Merge pull request #3720 from hmlnarik/KEYCLOAK-4091-Possible-NullPointerExceptions-with-disabled-cache
KEYCLOAK-4091 Prevent NPE with disabled cache
This commit is contained in:
commit
7eeebff874
7 files changed
+42
-9
No files matched your search
@@ -637,7 +637,10 @@ public class LDAPStorageProvider implements UserStorageProvider,
|
||||
logger.warnf("User with username [%s] aready exists and is linked to provider [%s] but is not valid. Stale LDAP_ID on local user is: %s",
|
||||
username, model.getName(), user.getFirstAttribute(LDAPConstants.LDAP_ID));
|
||||
logger.warn("Will re-create user");
|
||||
session.userCache().evict(realm, user);
|
||||
UserCache userCache = session.userCache();
|
||||
if (userCache != null) {
|
||||
userCache.evict(realm, user);
|
||||
}
|
||||
new UserManager(session).removeUser(realm, user, session.userLocalStorage());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -34,6 +34,7 @@ import org.keycloak.models.LDAPConstants;
|
||||
import org.keycloak.models.ModelException;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.cache.UserCache;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
import org.keycloak.provider.ProviderConfigProperty;
|
||||
import org.keycloak.provider.ProviderConfigurationBuilder;
|
||||
@@ -532,7 +533,10 @@ public class LDAPStorageProviderFactory implements UserStorageProviderFactory<LD
|
||||
if (username != null) {
|
||||
UserModel existing = session.userLocalStorage().getUserByUsername(username, currentRealm);
|
||||
if (existing != null) {
|
||||
session.userCache().evict(currentRealm, existing);
|
||||
UserCache userCache = session.userCache();
|
||||
if (userCache != null) {
|
||||
userCache.evict(currentRealm, existing);
|
||||
}
|
||||
session.userLocalStorage().removeUser(currentRealm, existing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user