You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2013/04/15 12:00:09 UTC

svn commit: r1467922 - in /qpid/trunk/qpid/java: broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/ broker/src/main/java/org/apache/qpid/server/configuration/startup/ broker/src/test/java/org/apache/qpid/server/configuration/startu...

Author: robbie
Date: Mon Apr 15 10:00:08 2013
New Revision: 1467922

URL: http://svn.apache.org/r1467922
Log:
QPID-4739: add ACL tests for new TrustStore + KeyStore objects

Also some small fixups from secondary review: correct exception messages, remove unused imports, tweak a unit test, add a couple of missing licence headers

Modified:
    qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
    qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProviderTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java?rev=1467922&r1=1467921&r2=1467922&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java Mon Apr 15 10:00:08 2013
@@ -22,7 +22,6 @@ package org.apache.qpid.server.jmx;
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
 import org.apache.qpid.server.model.Broker;
@@ -43,9 +42,6 @@ import javax.management.remote.MBeanServ
 import javax.management.remote.rmi.RMIConnectorServer;
 import javax.net.ssl.SSLContext;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
-import javax.rmi.ssl.SslRMIServerSocketFactory;
-import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
@@ -140,11 +136,11 @@ public class JMXManagedObjectRegistry im
             }
             catch (GeneralSecurityException e)
             {
-                throw new RuntimeException("Unable to create SSLContext for key or trust store", e);
+                throw new RuntimeException("Unable to create SSLContext for key store", e);
             }
             catch (IOException e)
             {
-                throw new RuntimeException("Unable to create SSLContext - unable to load key/trust store", e);
+                throw new RuntimeException("Unable to create SSLContext for key store", e);
             }
 
             CurrentActor.get().message(ManagementConsoleMessages.SSL_KEYSTORE(keyStorePath));

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java?rev=1467922&r1=1467921&r2=1467922&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java Mon Apr 15 10:00:08 2013
@@ -1,3 +1,23 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
 package org.apache.qpid.server.jmx;
 
 import java.io.IOException;

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1467922&r1=1467921&r2=1467922&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java Mon Apr 15 10:00:08 2013
@@ -1,3 +1,23 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
 package org.apache.qpid.server.configuration.startup;
 
 import java.util.ArrayList;

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProviderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProviderTest.java?rev=1467922&r1=1467921&r2=1467922&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProviderTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProviderTest.java Mon Apr 15 10:00:08 2013
@@ -29,8 +29,10 @@ import org.apache.qpid.server.logging.Ro
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.Plugin;
 import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.stats.StatisticsGatherer;
@@ -42,7 +44,8 @@ public class DefaultRecovererProviderTes
     {
         String[] supportedTypes = {Broker.class.getSimpleName(),
                 VirtualHost.class.getSimpleName(), AuthenticationProvider.class.getSimpleName(),
-                GroupProvider.class.getSimpleName(), Plugin.class.getSimpleName(), Port.class.getSimpleName()};
+                GroupProvider.class.getSimpleName(), Plugin.class.getSimpleName(), Port.class.getSimpleName(),
+                KeyStore.class.getSimpleName(), TrustStore.class.getSimpleName()};
 
         // mocking the required object
         StatisticsGatherer statisticsGatherer = mock(StatisticsGatherer.class);

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java?rev=1467922&r1=1467921&r2=1467922&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java Mon Apr 15 10:00:08 2013
@@ -30,8 +30,10 @@ import java.util.Map;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.security.acl.AbstractACLTestCase;
 import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory;
@@ -39,6 +41,9 @@ import org.apache.qpid.server.security.a
 import org.apache.qpid.systest.rest.QpidRestTestCase;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
 import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.test.utils.TestSSLConstants;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
 
 public class BrokerACLTest extends QpidRestTestCase
 {
@@ -61,6 +66,8 @@ public class BrokerACLTest extends QpidR
                 "httpBasicAuthenticationEnabled", true);
     }
 
+    /* === AuthenticationProvider === */
+
     public void testCreateAuthenticationProviderAllowed() throws Exception
     {
         getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
@@ -168,6 +175,8 @@ public class BrokerACLTest extends QpidR
                 provider.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH));
     }
 
+    /* === VirtualHost === */
+
     public void testCreateVirtualHostAllowed() throws Exception
     {
         getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
@@ -218,6 +227,8 @@ public class BrokerACLTest extends QpidR
         assertVirtualHostExists(TEST2_VIRTUALHOST);
     }
 
+    /* === Port === */
+
     public void testCreatePortAllowed() throws Exception
     {
         getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
@@ -327,6 +338,264 @@ public class BrokerACLTest extends QpidR
                 TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER, port.get(Port.AUTHENTICATION_PROVIDER));
     }
 
+    /* === KeyStore === */
+
+    public void testCreateKeyStoreAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String keyStoreName = getTestName();
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, "app1");
+        assertEquals("keyStore creation should be allowed", 201, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+    }
+
+    public void testCreateKeyStoreDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        String keyStoreName = getTestName();
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, "app1");
+        assertEquals("keyStore creation should be allowed", 403, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, false);
+    }
+
+    public void testDeleteKeyStoreDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String keyStoreName = getTestName();
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, "app1");
+        assertEquals("keyStore creation should be allowed", 201, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        responseCode = getRestTestHelper().submitRequest("/rest/keystore/" + keyStoreName, "DELETE", null);
+        assertEquals("keystore deletion should be denied", 403, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+    }
+
+    public void testDeleteKeyStoreAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String keyStoreName = getTestName();
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, "app1");
+        assertEquals("keyStore creation should be allowed", 201, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        responseCode = getRestTestHelper().submitRequest("/rest/keystore/" + keyStoreName, "DELETE", null);
+        assertEquals("keystore deletion should be allowed", 200, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, false);
+    }
+
+    public void testSetKeyStoreAttributesAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String keyStoreName = getTestName();
+        String initialCertAlias = "app1";
+        String updatedCertAlias = "app2";
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, initialCertAlias);
+        assertEquals("keyStore creation should be allowed", 201, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+        Map<String, Object> keyStore = getRestTestHelper().getJsonAsSingletonList("/rest/keystore/" + keyStoreName);
+        assertEquals("Unexpected certificateAlias attribute value", initialCertAlias, keyStore.get(KeyStore.CERTIFICATE_ALIAS));
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(KeyStore.NAME, keyStoreName);
+        attributes.put(KeyStore.CERTIFICATE_ALIAS, updatedCertAlias);
+        responseCode = getRestTestHelper().submitRequest("/rest/keystore/" + keyStoreName, "PUT", attributes);
+        assertEquals("Setting of keystore attributes should be allowed", 200, responseCode);
+
+        keyStore = getRestTestHelper().getJsonAsSingletonList("/rest/keystore/" + keyStoreName);
+        assertEquals("Unexpected certificateAlias attribute value", updatedCertAlias, keyStore.get(KeyStore.CERTIFICATE_ALIAS));
+    }
+
+    public void testSetKeyStoreAttributesDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String keyStoreName = getTestName();
+        String initialCertAlias = "app1";
+        String updatedCertAlias = "app2";
+
+        assertKeyStoreExistence(keyStoreName, false);
+
+        int responseCode = createKeyStore(keyStoreName, initialCertAlias);
+        assertEquals("keyStore creation should be allowed", 201, responseCode);
+
+        assertKeyStoreExistence(keyStoreName, true);
+        Map<String, Object> keyStore = getRestTestHelper().getJsonAsSingletonList("/rest/keystore/" + keyStoreName);
+        assertEquals("Unexpected certificateAlias attribute value", initialCertAlias, keyStore.get(KeyStore.CERTIFICATE_ALIAS));
+
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(KeyStore.NAME, keyStoreName);
+        attributes.put(KeyStore.CERTIFICATE_ALIAS, updatedCertAlias);
+        responseCode = getRestTestHelper().submitRequest("/rest/keystore/" + keyStoreName, "PUT", attributes);
+        assertEquals("Setting of keystore attributes should be denied", 403, responseCode);
+
+        keyStore = getRestTestHelper().getJsonAsSingletonList("/rest/keystore/" + keyStoreName);
+        assertEquals("Unexpected certificateAlias attribute value", initialCertAlias, keyStore.get(KeyStore.CERTIFICATE_ALIAS));
+    }
+
+    /* === TrustStore === */
+
+    public void testCreateTrustStoreAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String trustStoreName = getTestName();
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, false);
+        assertEquals("trustStore creation should be allowed", 201, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+    }
+
+    public void testCreateTrustStoreDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        String trustStoreName = getTestName();
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, false);
+        assertEquals("trustStore creation should be allowed", 403, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, false);
+    }
+
+    public void testDeleteTrustStoreDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String trustStoreName = getTestName();
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, false);
+        assertEquals("trustStore creation should be allowed", 201, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        responseCode = getRestTestHelper().submitRequest("/rest/truststore/" + trustStoreName, "DELETE", null);
+        assertEquals("truststore deletion should be denied", 403, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+    }
+
+    public void testDeleteTrustStoreAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String trustStoreName = getTestName();
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, false);
+        assertEquals("trustStore creation should be allowed", 201, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        responseCode = getRestTestHelper().submitRequest("/rest/truststore/" + trustStoreName, "DELETE", null);
+        assertEquals("truststore deletion should be allowed", 200, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, false);
+    }
+
+    public void testSetTrustStoreAttributesAllowed() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String trustStoreName = getTestName();
+        boolean initialPeersOnly = false;
+        boolean updatedPeersOnly = true;
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, initialPeersOnly);
+        assertEquals("trustStore creation should be allowed", 201, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+        Map<String, Object> trustStore = getRestTestHelper().getJsonAsSingletonList("/rest/truststore/" + trustStoreName);
+        assertEquals("Unexpected peersOnly attribute value", initialPeersOnly, trustStore.get(TrustStore.PEERS_ONLY));
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(TrustStore.NAME, trustStoreName);
+        attributes.put(TrustStore.PEERS_ONLY, updatedPeersOnly);
+        responseCode = getRestTestHelper().submitRequest("/rest/truststore/" + trustStoreName, "PUT", attributes);
+        assertEquals("Setting of truststore attributes should be allowed", 200, responseCode);
+
+        trustStore = getRestTestHelper().getJsonAsSingletonList("/rest/truststore/" + trustStoreName);
+        assertEquals("Unexpected peersOnly attribute value", updatedPeersOnly, trustStore.get(TrustStore.PEERS_ONLY));
+    }
+
+    public void testSetTrustStoreAttributesDenied() throws Exception
+    {
+        getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
+
+        String trustStoreName = getTestName();
+        boolean initialPeersOnly = false;
+        boolean updatedPeersOnly = true;
+
+        assertTrustStoreExistence(trustStoreName, false);
+
+        int responseCode = createTrustStore(trustStoreName, initialPeersOnly);
+        assertEquals("trustStore creation should be allowed", 201, responseCode);
+
+        assertTrustStoreExistence(trustStoreName, true);
+        Map<String, Object> trustStore = getRestTestHelper().getJsonAsSingletonList("/rest/truststore/" + trustStoreName);
+        assertEquals("Unexpected peersOnly attribute value", initialPeersOnly, trustStore.get(TrustStore.PEERS_ONLY));
+
+        getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(TrustStore.NAME, trustStoreName);
+        attributes.put(TrustStore.PEERS_ONLY, updatedPeersOnly);
+        responseCode = getRestTestHelper().submitRequest("/rest/truststore/" + trustStoreName, "PUT", attributes);
+        assertEquals("Setting of truststore attributes should be denied", 403, responseCode);
+
+        trustStore = getRestTestHelper().getJsonAsSingletonList("/rest/truststore/" + trustStoreName);
+        assertEquals("Unexpected peersOnly attribute value", initialPeersOnly, trustStore.get(TrustStore.PEERS_ONLY));
+    }
+
+    /* === Broker === */
+
     public void testSetBrokerAttributesAllowed() throws Exception
     {
         getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
@@ -395,6 +664,18 @@ public class BrokerACLTest extends QpidR
         assertEquals("Unexpected result", exists, !hosts.isEmpty());
     }
 
+    private void assertKeyStoreExistence(String keyStoreName, boolean exists) throws Exception
+    {
+        List<Map<String, Object>> keyStores = getRestTestHelper().getJsonAsList("/rest/keystore/" + keyStoreName);
+        assertEquals("Unexpected result", exists, !keyStores.isEmpty());
+    }
+
+    private void assertTrustStoreExistence(String trustStoreName, boolean exists) throws Exception
+    {
+        List<Map<String, Object>> trustStores = getRestTestHelper().getJsonAsList("/rest/truststore/" + trustStoreName);
+        assertEquals("Unexpected result", exists, !trustStores.isEmpty());
+    }
+
     private int createHost(String hostName) throws Exception
     {
         Map<String, Object> hostData = new HashMap<String, Object>();
@@ -452,4 +733,25 @@ public class BrokerACLTest extends QpidR
         assertEquals("Unexpected result", exists, !providers.isEmpty());
     }
 
+    private int createKeyStore(String name, String certAlias) throws IOException, JsonGenerationException, JsonMappingException
+    {
+        Map<String, Object> keyStoreAttributes = new HashMap<String, Object>();
+        keyStoreAttributes.put(KeyStore.NAME, name);
+        keyStoreAttributes.put(KeyStore.PATH, TestSSLConstants.KEYSTORE);
+        keyStoreAttributes.put(KeyStore.PASSWORD, TestSSLConstants.KEYSTORE_PASSWORD);
+        keyStoreAttributes.put(KeyStore.CERTIFICATE_ALIAS, certAlias);
+
+        return getRestTestHelper().submitRequest("/rest/keystore/" + name, "PUT", keyStoreAttributes);
+    }
+
+    private int createTrustStore(String name, boolean peersOnly) throws IOException, JsonGenerationException, JsonMappingException
+    {
+        Map<String, Object> trustStoreAttributes = new HashMap<String, Object>();
+        trustStoreAttributes.put(TrustStore.NAME, name);
+        trustStoreAttributes.put(TrustStore.PATH, TestSSLConstants.KEYSTORE);
+        trustStoreAttributes.put(TrustStore.PASSWORD, TestSSLConstants.KEYSTORE_PASSWORD);
+        trustStoreAttributes.put(TrustStore.PEERS_ONLY, peersOnly);
+
+        return getRestTestHelper().submitRequest("/rest/truststore/" + name, "PUT", trustStoreAttributes);
+    }
 }



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