Repository: qpid-jms-amqp-0-x
Updated Branches:
  refs/heads/6.3.x 2f6732941 -> a9ff1856d


QPID-8135: [Qpid JMS AMQP 0-x] Mask passwords associated with end to end 
encryption in the BrokerDetails#toString()

(cherry picked from commit 97347f0fb0e0782398bd16a7ba2d318bbb759bd1)


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/commit/a9ff1856
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/tree/a9ff1856
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/diff/a9ff1856

Branch: refs/heads/6.3.x
Commit: a9ff1856da994be8d4f83cc612e5ac1fd2bdddb6
Parents: 2f67329
Author: Keith Wall <kw...@apache.org>
Authored: Thu Apr 5 16:13:36 2018 +0100
Committer: Alex Rudyy <oru...@apache.org>
Committed: Mon Apr 16 17:01:24 2018 +0100

----------------------------------------------------------------------
 .../org/apache/qpid/client/BrokerDetails.java   | 12 ++++++++++-
 .../client/BrokerDetails/BrokerDetailsTest.java | 22 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/a9ff1856/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/qpid/client/BrokerDetails.java 
b/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
index c7865ef..5b99285 100644
--- a/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
+++ b/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
@@ -23,8 +23,12 @@ package org.apache.qpid.client;
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.transport.ConnectionSettings;
@@ -65,6 +69,12 @@ public class BrokerDetails implements Serializable
     public static final String OPTIONS_ENCRYPTION_KEY_STORE = 
"encryption_key_store";
     public static final String OPTIONS_ENCRYPTION_KEY_STORE_PASSWORD = 
"encryption_key_store_password";
 
+    private static final Set<String> PASSWORD_YIELDING_OPTIONS =
+            Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+                    OPTIONS_TRUST_STORE_PASSWORD,
+                    OPTIONS_KEY_STORE_PASSWORD,
+                    OPTIONS_ENCRYPTION_TRUST_STORE_PASSWORD,
+                    OPTIONS_ENCRYPTION_KEY_STORE_PASSWORD)));
 
     public static final int DEFAULT_PORT = 5672;
     public static final String TCP = "tcp";
@@ -427,7 +437,7 @@ public class BrokerDetails implements Serializable
 
                 optionsURL.append("='");
 
-                if (OPTIONS_TRUST_STORE_PASSWORD.equals(key) || 
OPTIONS_KEY_STORE_PASSWORD.equals(key))
+                if (PASSWORD_YIELDING_OPTIONS.contains(key))
                 {
                     optionsURL.append("********");
                 }

http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/a9ff1856/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
----------------------------------------------------------------------
diff --git 
a/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
 
b/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
index 2a33bf7..fd0e7d0 100644
--- 
a/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
+++ 
b/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
@@ -144,6 +144,28 @@ public class BrokerDetailsTest extends QpidTestCase
         assertEquals("Unexpected toString", expectedToString, actualToString);
     }
 
+    public void testToStringMasksEncryptionTrustStorePassword() throws 
Exception
+    {
+        String url = 
"tcp://localhost:5672?encryption_trust_store_password='password'";
+        BrokerDetails details = new BrokerDetails(url);
+
+        String expectedToString = 
"tcp://localhost:5672?encryption_trust_store_password='********'";
+        String actualToString = details.toString();
+
+        assertEquals("Unexpected toString", expectedToString, actualToString);
+    }
+
+    public void testToStringMasksEncryptionKeyStorePassword() throws Exception
+    {
+        String url = 
"tcp://localhost:5672?encryption_key_store_password='password'";
+        BrokerDetails details = new BrokerDetails(url);
+
+        String expectedToString = 
"tcp://localhost:5672?encryption_key_store_password='********'";
+        String actualToString = details.toString();
+
+        assertEquals("Unexpected toString", expectedToString, actualToString);
+    }
+
     public void testDefaultSsl() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to