From commits-return-4184-archive-asf-public=cust-asf.ponee.io@ranger.apache.org Tue Jan 30 11:02:46 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 3C5AE18061A for ; Tue, 30 Jan 2018 11:02:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2C095160C53; Tue, 30 Jan 2018 10:02:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 74D0D160C42 for ; Tue, 30 Jan 2018 11:02:45 +0100 (CET) Received: (qmail 26832 invoked by uid 500); 30 Jan 2018 10:02:44 -0000 Mailing-List: contact commits-help@ranger.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ranger.apache.org Delivered-To: mailing list commits@ranger.apache.org Received: (qmail 26821 invoked by uid 99); 30 Jan 2018 10:02:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jan 2018 10:02:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4BEF9DFC27; Tue, 30 Jan 2018 10:02:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@ranger.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ranger git commit: RANGER-1965 - Prevent NPE on decrypting a null password Date: Tue, 30 Jan 2018 10:02:42 +0000 (UTC) Repository: ranger Updated Branches: refs/heads/master e23977ce6 -> af6b8c4f3 RANGER-1965 - Prevent NPE on decrypting a null password Signed-off-by: Colm O hEigeartaigh Project: http://git-wip-us.apache.org/repos/asf/ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/af6b8c4f Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/af6b8c4f Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/af6b8c4f Branch: refs/heads/master Commit: af6b8c4f3d27b2a5adf37b509c036ab3ba63cb75 Parents: e23977c Author: Colm O hEigeartaigh Authored: Mon Jan 29 16:17:35 2018 +0000 Committer: Colm O hEigeartaigh Committed: Tue Jan 30 09:52:50 2018 +0000 ---------------------------------------------------------------------- .../apache/ranger/plugin/client/BaseClient.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ranger/blob/af6b8c4f/agents-common/src/main/java/org/apache/ranger/plugin/client/BaseClient.java ---------------------------------------------------------------------- diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/client/BaseClient.java b/agents-common/src/main/java/org/apache/ranger/plugin/client/BaseClient.java index cb170c2..e654f2b 100644 --- a/agents-common/src/main/java/org/apache/ranger/plugin/client/BaseClient.java +++ b/agents-common/src/main/java/org/apache/ranger/plugin/client/BaseClient.java @@ -104,15 +104,19 @@ public abstract class BaseClient { else { String encryptedPwd = configHolder.getPassword(); String password = null; - try { - password = PasswordUtils.decryptPassword(encryptedPwd); - } catch(Exception ex) { - LOG.info("Password decryption failed; trying connection with received password string"); - password = null; - } finally { - if (password == null) { - password = encryptedPwd; + if (encryptedPwd != null) { + try { + password = PasswordUtils.decryptPassword(encryptedPwd); + } catch(Exception ex) { + LOG.info("Password decryption failed; trying connection with received password string"); + password = null; + } finally { + if (password == null) { + password = encryptedPwd; + } } + } else { + LOG.info("Password decryption failed: no password was configured"); } if ( configHolder.isKerberosAuthentication() ) { LOG.info("Init Login: using username/password");