activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1846 fix activemq.usemaskedpassword in URL
Date Thu, 03 May 2018 16:10:05 GMT
ARTEMIS-1846 fix activemq.usemaskedpassword in URL


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a6fe2559
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a6fe2559
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a6fe2559

Branch: refs/heads/master
Commit: a6fe25599cb73555642fa0ed72740279844604f7
Parents: 541dfc6
Author: Justin Bertram <jbertram@apache.org>
Authored: Thu May 3 10:28:05 2018 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu May 3 12:09:58 2018 -0400

----------------------------------------------------------------------
 .../artemis/utils/ConfigurationHelper.java      |  8 +-
 .../ssl/CoreClientOverOneWaySSLTest.java        | 80 ++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a6fe2559/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
index 4367318..3b2647c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/ConfigurationHelper.java
@@ -162,7 +162,13 @@ public class ConfigurationHelper {
       }
 
       String value = prop.toString();
-      Boolean useMask = (Boolean) props.get(defaultMaskPassword);
+      Object useMaskObject = props.get(defaultMaskPassword);
+      Boolean useMask;
+      if (useMaskObject instanceof String) {
+         useMask = Boolean.parseBoolean((String)useMaskObject);
+      } else {
+         useMask = (Boolean) useMaskObject;
+      }
       final String classImpl = (String) props.get(defaultPasswordCodec);
       try {
          return PasswordMaskingUtil.resolveMask(useMask, value, classImpl);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a6fe2559/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java
index c9bf35e..aeb7524 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/CoreClientOverOneWaySSLTest.java
@@ -44,6 +44,8 @@ import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
+import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.junit.Assert;
 import org.junit.Before;
@@ -133,6 +135,84 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase {
    }
 
    @Test
+   public void testOneWaySSLwithURL() throws Exception {
+      createCustomSslServer();
+      String text = RandomUtil.randomString();
+
+      ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider="
+ storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=" + PASSWORD));
+      ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
+      ClientSession session = addClientSession(sf.createSession(false, true, true));
+      session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE,
false);
+      ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
+
+      ClientMessage message = createTextMessage(session, text);
+      producer.send(message);
+
+      ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
+      session.start();
+
+      ClientMessage m = consumer.receive(1000);
+      Assert.assertNotNull(m);
+      Assert.assertEquals(text, m.getBodyBuffer().readString());
+   }
+
+   @Test
+   public void testOneWaySSLwithURLandMaskedPasswordProperty() throws Exception {
+      createCustomSslServer();
+      String text = RandomUtil.randomString();
+
+      DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec();
+      Map<String, String> params = new HashMap<>();
+      codec.init(params);
+
+      String masked = codec.encode(PASSWORD);
+
+      ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider="
+ storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=" + masked
+ ";activemq.usemaskedpassword=true"));
+      ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
+      ClientSession session = addClientSession(sf.createSession(false, true, true));
+      session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE,
false);
+      ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
+
+      ClientMessage message = createTextMessage(session, text);
+      producer.send(message);
+
+      ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
+      session.start();
+
+      ClientMessage m = consumer.receive(1000);
+      Assert.assertNotNull(m);
+      Assert.assertEquals(text, m.getBodyBuffer().readString());
+   }
+
+   @Test
+   public void testOneWaySSLwithURLandMaskedPasswordENCSyntax() throws Exception {
+      createCustomSslServer();
+      String text = RandomUtil.randomString();
+
+      DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec();
+      Map<String, String> params = new HashMap<>();
+      codec.init(params);
+
+      String masked = codec.encode(PASSWORD);
+
+      ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider="
+ storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=ENC(" + masked
+ ")"));
+      ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
+      ClientSession session = addClientSession(sf.createSession(false, true, true));
+      session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE,
false);
+      ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
+
+      ClientMessage message = createTextMessage(session, text);
+      producer.send(message);
+
+      ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
+      session.start();
+
+      ClientMessage m = consumer.receive(1000);
+      Assert.assertNotNull(m);
+      Assert.assertEquals(text, m.getBodyBuffer().readString());
+   }
+
+   @Test
    public void testOneWaySSLUsingDefaultSslContext() throws Exception {
       createCustomSslServer();
       String text = RandomUtil.randomString();


Mime
View raw message