You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/03/30 18:57:05 UTC

[atlas] branch master updated: ATLAS-3667: Option to store Ldap/AD bind password in jceks keystore file - #2 (fix for NPE)

This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new fc0ae77  ATLAS-3667: Option to store Ldap/AD bind password in jceks keystore file - #2 (fix for NPE)
fc0ae77 is described below

commit fc0ae7713acfe0b24e0c56325a0e9b92283ea3a5
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Mon Mar 30 09:49:51 2020 -0700

    ATLAS-3667: Option to store Ldap/AD bind password in jceks keystore file - #2 (fix for NPE)
---
 .../org/apache/atlas/ApplicationProperties.java    | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/ApplicationProperties.java b/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
index d1a84c2..e40ca88 100644
--- a/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
+++ b/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
@@ -277,24 +277,28 @@ public final class ApplicationProperties extends PropertiesConfiguration {
     }
 
     private static void setLdapPasswordFromKeystore(Configuration configuration) {
-        try {
-            if (configuration.getString(LDAP_TYPE).equalsIgnoreCase("ldap")) {
-                String maskPasssword = configuration.getString(LDAP_BIND_PASSWORD);
-                if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
-                    String password = SecurityUtil.getPassword(configuration, LDAP_BIND_PASSWORD);
-                    configuration.clearProperty(LDAP_BIND_PASSWORD);
-                    configuration.addProperty(LDAP_BIND_PASSWORD, password);
-                }
-            } else if (configuration.getString(LDAP_TYPE).equalsIgnoreCase("ad")) {
-                String maskPasssword = configuration.getString(LDAP_AD_BIND_PASSWORD);
-                if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
-                    String password = SecurityUtil.getPassword(configuration, LDAP_AD_BIND_PASSWORD);
-                    configuration.clearProperty(LDAP_AD_BIND_PASSWORD);
-                    configuration.addProperty(LDAP_AD_BIND_PASSWORD, password);
+        String ldapType = configuration.getString(LDAP_TYPE);
+
+        if (StringUtils.isNotEmpty(ldapType)) {
+            try {
+                if (ldapType.equalsIgnoreCase("ldap")) {
+                    String maskPasssword = configuration.getString(LDAP_BIND_PASSWORD);
+                    if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
+                        String password = SecurityUtil.getPassword(configuration, LDAP_BIND_PASSWORD);
+                        configuration.clearProperty(LDAP_BIND_PASSWORD);
+                        configuration.addProperty(LDAP_BIND_PASSWORD, password);
+                    }
+                } else if (ldapType.equalsIgnoreCase("ad")) {
+                    String maskPasssword = configuration.getString(LDAP_AD_BIND_PASSWORD);
+                    if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
+                        String password = SecurityUtil.getPassword(configuration, LDAP_AD_BIND_PASSWORD);
+                        configuration.clearProperty(LDAP_AD_BIND_PASSWORD);
+                        configuration.addProperty(LDAP_AD_BIND_PASSWORD, password);
+                    }
                 }
+            } catch (Exception e) {
+                LOG.error("Error in getting secure password ", e);
             }
-        } catch (Exception e) {
-            LOG.error("Error in getting secure password ", e);
         }
     }