QPID-8441: [JMS AMQP 0-x] Add connection options to override keystore and truststore types
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 0ce3fd3..c19f023 100644
--- a/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
+++ b/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
@@ -54,8 +54,10 @@
     public static final String OPTIONS_SASL_SERVER_NAME = "sasl_server";
     public static final String OPTIONS_TRUST_STORE = "trust_store";
     public static final String OPTIONS_TRUST_STORE_PASSWORD = "trust_store_password";
+    public static final String OPTIONS_TRUST_STORE_TYPE = "trust_store_type";
     public static final String OPTIONS_KEY_STORE = "key_store";
     public static final String OPTIONS_KEY_STORE_PASSWORD = "key_store_password";
+    public static final String OPTIONS_KEY_STORE_TYPE = "key_store_type";
     public static final String OPTIONS_SSL_VERIFY_HOSTNAME = "ssl_verify_hostname";
     public static final String OPTIONS_SSL_CERT_ALIAS = "ssl_cert_alias";
     public static final String OPTIONS_CLIENT_CERT_PRIV_KEY_PATH = "client_cert_priv_key_path";
@@ -65,9 +67,11 @@
 
     public static final String OPTIONS_ENCRYPTION_TRUST_STORE = "encryption_trust_store";
     public static final String OPTIONS_ENCRYPTION_TRUST_STORE_PASSWORD = "encryption_trust_store_password";
+    public static final String OPTIONS_ENCRYPTION_TRUST_STORE_TYPE = "encryption_trust_store_type";
     public static final String OPTIONS_ENCRYPTION_REMOTE_TRUST_STORE = "encryption_remote_trust_store";
     public static final String OPTIONS_ENCRYPTION_KEY_STORE = "encryption_key_store";
     public static final String OPTIONS_ENCRYPTION_KEY_STORE_PASSWORD = "encryption_key_store_password";
+    public static final String OPTIONS_ENCRYPTION_KEY_STORE_TYPE = "encryption_key_store_type";
 
     static final Set<String> PASSWORD_YIELDING_OPTIONS =
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
@@ -488,6 +492,12 @@
                     getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD));
         }
 
+        if (getProperty(BrokerDetails.OPTIONS_TRUST_STORE_TYPE) != null)
+        {
+            conSettings.setTrustStoreType(
+                    getProperty(BrokerDetails.OPTIONS_TRUST_STORE_TYPE));
+        }
+
         if (getProperty(BrokerDetails.OPTIONS_KEY_STORE) != null)
         {
             conSettings.setKeyStorePath(
@@ -500,6 +510,12 @@
                     getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD));
         }
 
+        if (getProperty(BrokerDetails.OPTIONS_KEY_STORE_TYPE) != null)
+        {
+            conSettings.setKeyStoreType(
+                    getProperty(BrokerDetails.OPTIONS_KEY_STORE_TYPE));
+        }
+
         if (getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS) != null)
         {
             conSettings.setCertAlias(
@@ -550,6 +566,11 @@
                     getProperty(BrokerDetails.OPTIONS_ENCRYPTION_KEY_STORE_PASSWORD));
         }
 
+        if (getProperty(BrokerDetails.OPTIONS_ENCRYPTION_KEY_STORE_TYPE) != null)
+        {
+            conSettings.setEncryptionKeyStoreType(
+                    getProperty(BrokerDetails.OPTIONS_ENCRYPTION_KEY_STORE_TYPE));
+        }
 
         if (getProperty(BrokerDetails.OPTIONS_ENCRYPTION_TRUST_STORE) != null)
         {
@@ -564,6 +585,13 @@
         }
 
 
+        if (getProperty(BrokerDetails.OPTIONS_ENCRYPTION_TRUST_STORE_TYPE) != null)
+        {
+            conSettings.setEncryptionTrustStoreType(
+                    getProperty(BrokerDetails.OPTIONS_ENCRYPTION_TRUST_STORE_TYPE));
+        }
+
+
         if (getProperty(BrokerDetails.OPTIONS_ENCRYPTION_REMOTE_TRUST_STORE) != null)
         {
             conSettings.setEncryptionRemoteTrustStoreName(
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 3d7e63f..4dc94f2 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
@@ -271,4 +271,32 @@
         ConnectionSettings connectionSettings = broker.buildConnectionSettings();
         assertEquals("foo", connectionSettings.getEncryptionTrustStorePassword());
     }
+
+    public void testEncryptionKeyStoreType() throws Exception
+    {
+        BrokerDetails broker = new BrokerDetails("tcp://localhost:5672?encryption_key_store_type='foo'");
+        ConnectionSettings connectionSettings = broker.buildConnectionSettings();
+        assertEquals("foo", connectionSettings.getEncryptionKeyStoreType());
+    }
+
+    public void testEncryptionTrustStoreType() throws Exception
+    {
+        BrokerDetails broker = new BrokerDetails("tcp://localhost:5672?encryption_trust_store_type='foo'");
+        ConnectionSettings connectionSettings = broker.buildConnectionSettings();
+        assertEquals("foo", connectionSettings.getEncryptionTrustStoreType());
+    }
+
+    public void testKeyStoreType() throws Exception
+    {
+        BrokerDetails details = new BrokerDetails("tcp://localhost:5672?key_store_type='foo'");
+        ConnectionSettings connectionSettings = details.buildConnectionSettings();
+        assertEquals("foo", connectionSettings.getKeyStoreType());
+    }
+
+    public void testTrustStoreType() throws Exception
+    {
+        BrokerDetails details = new BrokerDetails("tcp://localhost:5672?trust_store_type='foo'");
+        ConnectionSettings connectionSettings = details.buildConnectionSettings();
+        assertEquals("foo", connectionSettings.getTrustStoreType());
+    }
 }