Check if LDAPObject is available from a previously cached proxied user

Closes #34412

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
Stefan Guilhen 2024-10-28 18:27:30 -03:00 committed by Pedro Igor
parent a4cbd77043
commit d66030fcad

View file

@ -45,7 +45,13 @@ public class LDAPStorageUserManager {
} }
public LDAPObject getManagedLDAPObject(String userId) { public LDAPObject getManagedLDAPObject(String userId) {
return managedLDAPObjects.get(userId); ManagedUserEntry entry = managedUsers.get(userId);
if (entry != null) {
return entry.getLdapUser();
}
else {
return managedLDAPObjects.get(userId);
}
} }
public void setManagedLDAPObject(String userId, LDAPObject ldapObject) { public void setManagedLDAPObject(String userId, LDAPObject ldapObject) {
@ -74,7 +80,7 @@ public class LDAPStorageUserManager {
} }
LDAPTransaction ldapTransaction = new LDAPTransaction(provider, ldapObject); LDAPTransaction ldapTransaction = new LDAPTransaction(provider, ldapObject);
ManagedUserEntry newEntry = new ManagedUserEntry(proxiedUser, ldapTransaction); ManagedUserEntry newEntry = new ManagedUserEntry(proxiedUser, ldapObject, ldapTransaction);
managedUsers.put(userId, newEntry); managedUsers.put(userId, newEntry);
} }
@ -87,10 +93,12 @@ public class LDAPStorageUserManager {
private static class ManagedUserEntry { private static class ManagedUserEntry {
private final UserModel managedProxiedUser; private final UserModel managedProxiedUser;
private final LDAPObject ldapUser;
private final LDAPTransaction ldapTransaction; private final LDAPTransaction ldapTransaction;
public ManagedUserEntry(UserModel managedProxiedUser, LDAPTransaction ldapTransaction) { public ManagedUserEntry(UserModel managedProxiedUser, LDAPObject ldapUser, LDAPTransaction ldapTransaction) {
this.managedProxiedUser = managedProxiedUser; this.managedProxiedUser = managedProxiedUser;
this.ldapUser = ldapUser;
this.ldapTransaction = ldapTransaction; this.ldapTransaction = ldapTransaction;
} }
@ -98,6 +106,10 @@ public class LDAPStorageUserManager {
return managedProxiedUser; return managedProxiedUser;
} }
public LDAPObject getLdapUser() {
return ldapUser;
}
public LDAPTransaction getLdapTransaction() { public LDAPTransaction getLdapTransaction() {
return ldapTransaction; return ldapTransaction;
} }