You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/11/01 21:15:27 UTC

[activemq-artemis] branch main updated: ARTEMIS-3543 Fix encrypted passwords in composite urls

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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 7988739  ARTEMIS-3543 Fix encrypted passwords in composite urls
7988739 is described below

commit 7988739f41f1c10aae911c64cfd7cb08c1e2bbb0
Author: Domenico Francesco Bruscino <br...@apache.org>
AuthorDate: Wed Oct 27 22:44:24 2021 +0200

    ARTEMIS-3543 Fix encrypted passwords in composite urls
---
 .../apache/activemq/artemis/utils/uri/URIFactory.java |  2 +-
 .../artemis/uri/ConnectionFactoryURITest.java         | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
index 1680a0f..9e40acf 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
@@ -108,7 +108,7 @@ public class URIFactory<T, P> {
    * */
    private URI normalise(String uri) throws URISyntaxException {
       if (uri.startsWith("(")) {
-         String[] split = uri.split("\\)");
+         String[] split = uri.split("\\)", 2);
          String[] connectorURIS = split[0].substring(split[0].indexOf('(') + 1).split(",");
          String factoryQuery = split.length > 1 ? split[1] : "";
          StringBuilder builder = new StringBuilder(connectorURIS[0]);
diff --git a/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java
index 1cfccbd..44bace8 100644
--- a/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java
+++ b/artemis-jms-client/src/test/java/org/apache/activemq/artemis/uri/ConnectionFactoryURITest.java
@@ -224,6 +224,25 @@ public class ConnectionFactoryURITest {
       checkTC(props3, staticConnectors[2], 2);
    }
 
+   @Test
+   public void testTCPEncryptedNettyConnectorPropertiesMultiple() throws Exception {
+      final String trustStorePath = "truststore.jks";
+      final String trustStorePassword = "ENC(3a34fd21b82bf2a822fa49a8d8fa115d)";
+
+      ActiveMQConnectionFactory factory = parser.newObject(parser.expandURI(
+         "(tcp://localhost0:61616?,tcp://localhost1:61617?,tcp://localhost2:61618?)" +
+            "?ha=true&clientID=myID&trustStorePath=" + trustStorePath +
+            "&trustStorePassword=" + trustStorePassword), null);
+
+      TransportConfiguration[] staticConnectors = factory.getStaticConnectors();
+      Assert.assertEquals(3, staticConnectors.length);
+
+      for (int i = 0; i < 3; i++) {
+         Assert.assertEquals(trustStorePath, staticConnectors[i].getParams().get("trustStorePath"));
+         Assert.assertEquals(trustStorePassword, staticConnectors[0].getParams().get("trustStorePassword"));
+      }
+   }
+
    private void checkTC(Map<String, Object> props, TransportConfiguration staticConnector, int offfSet) {
       TransportConfiguration connector = staticConnector;
       Assert.assertEquals(connector.getParams().get("host"), "localhost" + offfSet);