[fix][ldap] fix ldap password null pointer exception. (#10284)

This commit is contained in:
luozenglin
2022-06-23 15:01:18 +08:00
committed by GitHub
parent 6a54fc2fe5
commit a5fea86d0a
2 changed files with 6 additions and 2 deletions

View File

@ -100,13 +100,13 @@ public class LdapClient {
}
public boolean checkUpdate(String ldapPassword) {
return !this.ldapPassword.equals(ldapPassword);
return this.ldapPassword == null || !this.ldapPassword.equals(ldapPassword);
}
}
private static void init() {
LdapInfo ldapInfo = Catalog.getCurrentCatalog().getAuth().getLdapInfo();
if (ldapInfo == null) {
if (ldapInfo == null || !ldapInfo.isValid()) {
LOG.error("info is null, maybe no ldap admin password is set.");
ErrorReport.report(ErrorCode.ERROR_LDAP_CONFIGURATION_ERR);
throw new RuntimeException("ldapTemplate is not initialized");

View File

@ -46,6 +46,10 @@ public class LdapInfo implements Writable {
ldapPasswdEncrypted = SymmetricEncryption.encrypt(ldapPasswd, secretKey, iv);
}
public boolean isValid() {
return ldapPasswdEncrypted != null && secretKey != null && iv != null;
}
public String getLdapPasswdEncrypted() {
return ldapPasswdEncrypted;
}