You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/08/07 13:02:39 UTC
qpid-broker-j git commit: QPID-7867: [Java Broker] Extend UI to allow
"Trust Anchor Validity Enforced" to be mutated
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 555593d95 -> d55b08e89
QPID-7867: [Java Broker] Extend UI to allow "Trust Anchor Validity Enforced" to be mutated
Added documentation.
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/d55b08e8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/d55b08e8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/d55b08e8
Branch: refs/heads/master
Commit: d55b08e89e2d0755b392bfe291a5e9698a782e4f
Parents: 555593d
Author: Keith Wall <kw...@apache.org>
Authored: Mon Aug 7 13:53:19 2017 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Mon Aug 7 14:02:19 2017 +0100
----------------------------------------------------------------------
.../qpid/server/security/FileTrustStore.java | 4 +-
.../qpid/server/security/NonJavaTrustStore.java | 6 +--
.../server/security/NonJavaTrustStoreTest.java | 51 +++++++++++++++++---
.../resources/js/qpid/management/TrustStore.js | 4 +-
.../src/main/java/resources/showTrustStore.html | 4 ++
.../resources/store/filetruststore/add.html | 8 +--
.../main/java/resources/store/truststore.html | 33 ++++++++++---
...a-Broker-Management-Managing-Truststores.xml | 4 ++
test-profiles/test_resources/ssl/expired.crt | 17 +++++++
9 files changed, 108 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java
index 2efcdaa..efbe805 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStore.java
@@ -57,7 +57,9 @@ public interface FileTrustStore<X extends FileTrustStore<X>> extends TrustStore<
@ManagedAttribute( defaultValue = "${trustStoreFile.trustStoreType}")
String getTrustStoreType();
- @ManagedAttribute( defaultValue = "false" )
+ @ManagedAttribute( defaultValue = "false",
+ description = "If true, the Truststore it will authenticate only those clients that present a certificate"
+ + " exactly matching a certificate contained within the Truststore.")
boolean isPeersOnly();
@ManagedAttribute( secure = true, mandatory = true )
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaTrustStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaTrustStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaTrustStore.java
index 7b34419..c861110 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaTrustStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/NonJavaTrustStore.java
@@ -20,10 +20,6 @@
*/
package org.apache.qpid.server.security;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.server.model.DerivedAttribute;
import org.apache.qpid.server.model.ManagedAttribute;
import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.TrustStore;
@@ -31,6 +27,8 @@ import org.apache.qpid.server.model.TrustStore;
@ManagedObject( category = false, type = "NonJavaTrustStore" )
public interface NonJavaTrustStore<X extends NonJavaTrustStore<X>> extends TrustStore<X>
{
+ String CERTIFICATES_URL = "certificatesUrl";
+
@Override
@ManagedAttribute(defaultValue = "${this:certificateDetails}")
String getDescription();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaTrustStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaTrustStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaTrustStoreTest.java
index 3ebaa4c..8e999d5 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaTrustStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/security/NonJavaTrustStoreTest.java
@@ -22,10 +22,15 @@ package org.apache.qpid.server.security;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import javax.net.ssl.TrustManager;
+import java.security.KeyStore;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
@@ -35,7 +40,9 @@ import org.apache.qpid.server.model.BrokerModel;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestSSLConstants;
public class NonJavaTrustStoreTest extends QpidTestCase
@@ -61,23 +68,55 @@ public class NonJavaTrustStoreTest extends QpidTestCase
{
Map<String,Object> attributes = new HashMap<>();
attributes.put(NonJavaTrustStore.NAME, "myTestTrustStore");
- attributes.put("certificatesUrl", getClass().getResource("/java_broker.crt").toExternalForm());
+ attributes.put(NonJavaTrustStore.CERTIFICATES_URL, getClass().getResource("/java_broker.crt").toExternalForm());
attributes.put(NonJavaTrustStore.TYPE, "NonJavaTrustStore");
- NonJavaTrustStoreImpl fileTrustStore =
- (NonJavaTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker);
+ TrustStore trustStore = _factory.create(TrustStore.class, attributes, _broker);
- TrustManager[] trustManagers = fileTrustStore.getTrustManagers();
+ TrustManager[] trustManagers = trustStore.getTrustManagers();
assertNotNull(trustManagers);
assertEquals("Unexpected number of trust managers", 1, trustManagers.length);
assertNotNull("Trust manager unexpected null", trustManagers[0]);
}
+ public void testUseOfExpiredTrustAnchorDenied() throws Exception
+ {
+ Map<String,Object> attributes = new HashMap<>();
+ attributes.put(NonJavaTrustStore.NAME, "myTestTrustStore");
+ attributes.put(NonJavaTrustStore.TRUST_ANCHOR_VALIDITY_ENFORCED, true);
+ attributes.put(NonJavaTrustStore.CERTIFICATES_URL, getClass().getResource("/expired.crt").toExternalForm());
+ attributes.put(NonJavaTrustStore.TYPE, "NonJavaTrustStore");
+
+ TrustStore trustStore = _factory.create(TrustStore.class, attributes, _broker);
+
+ TrustManager[] trustManagers = trustStore.getTrustManagers();
+ assertNotNull(trustManagers);
+ assertEquals("Unexpected number of trust managers", 1, trustManagers.length);
+ assertTrue("Unexpected trust manager type",trustManagers[0] instanceof X509TrustManager);
+ X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
+
+ KeyStore clientStore = SSLUtil.getInitializedKeyStore(TestSSLConstants.EXPIRED_KEYSTORE,
+ TestSSLConstants.KEYSTORE_PASSWORD,
+ KeyStore.getDefaultType());
+ String alias = clientStore.aliases().nextElement();
+ X509Certificate certificate = (X509Certificate) clientStore.getCertificate(alias);
+
+ try
+ {
+ trustManager.checkClientTrusted(new X509Certificate[] {certificate}, "NULL");
+ fail("Exception not thrown");
+ }
+ catch (CertificateExpiredException e)
+ {
+ // PASS
+ }
+ }
+
public void testCreationOfTrustStoreFromNonCertificate() throws Exception
{
Map<String,Object> attributes = new HashMap<>();
attributes.put(NonJavaTrustStore.NAME, "myTestTrustStore");
- attributes.put("certificatesUrl", getClass().getResource("/java_broker.req").toExternalForm());
+ attributes.put(NonJavaTrustStore.CERTIFICATES_URL, getClass().getResource("/java_broker.req").toExternalForm());
attributes.put(NonJavaTrustStore.TYPE, "NonJavaTrustStore");
try
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js
index 7114351..a461d40 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js
@@ -126,7 +126,7 @@ define(["dojo/_base/lang",
}
}
- storeNodes(["name", "type", "state", "exposedAsMessageSource"]);
+ storeNodes(["name", "type", "state", "exposedAsMessageSource", "trustAnchorValidityEnforced"]);
}
@@ -137,6 +137,8 @@ define(["dojo/_base/lang",
this.state.innerHTML = entities.encode(String(this.trustStoreData["state"]));
this.exposedAsMessageSource.innerHTML =
entities.encode(String(this.trustStoreData["exposedAsMessageSource"]));
+ this.trustAnchorValidityEnforced.innerHTML =
+ entities.encode(String(this.trustStoreData["trustAnchorValidityEnforced"]));
};
KeyStoreUpdater.prototype.update = function (callback)
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-plugins/management-http/src/main/java/resources/showTrustStore.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/showTrustStore.html b/broker-plugins/management-http/src/main/java/resources/showTrustStore.html
index 6ff04ce..eb82307 100644
--- a/broker-plugins/management-http/src/main/java/resources/showTrustStore.html
+++ b/broker-plugins/management-http/src/main/java/resources/showTrustStore.html
@@ -36,6 +36,10 @@
<div class="exposedAsMessageSource"></div>
</div>
<div class="clear">
+ <div class="formLabel-labelCell">Trust Anchor Validity Enforced:</div>
+ <div class="trustAnchorValidityEnforced"></div>
+ </div>
+ <div class="clear">
<div class="typeFieldsContainer"></div>
</div>
<div class="clear">
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html b/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html
index 15b1692..7a49bc4 100644
--- a/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html
+++ b/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html
@@ -50,9 +50,11 @@
<input type="text" id="addStore.peersOnly"
data-dojo-type="dijit/form/CheckBox"
data-dojo-props="
- name: 'peersOnly',
- promptMessage: 'Peers only or not',
- title: 'Tick if peers only'" />
+ name: 'peersOnly'" />
+ <div data-dojo-type="dijit/Tooltip"
+ data-dojo-props="connectId: ['addStore.peersOnly'],
+ label: 'If true, the Truststore it will authenticate only those clients that present a certificate exactly matching a certificate contained within the Truststore'">
+ </div>
</div>
</div>
<div class="clear">
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/broker-plugins/management-http/src/main/java/resources/store/truststore.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/store/truststore.html b/broker-plugins/management-http/src/main/java/resources/store/truststore.html
index 16ea8cd..8c3047b 100644
--- a/broker-plugins/management-http/src/main/java/resources/store/truststore.html
+++ b/broker-plugins/management-http/src/main/java/resources/store/truststore.html
@@ -18,13 +18,30 @@
-->
<div class="clear">
- <div id="addStore.exposedAsMessageSourceLabel" class="formLabel-labelCell tableContainer-labelCell">Exposed As Message Source:</div>
- <div class="formLabel-controlCell tableContainer-valueCell">
- <input type="text" id="addStore.exposedAsMessageSource"
- data-dojo-type="dijit/form/CheckBox"
- data-dojo-props="
- name: 'exposedAsMessageSource',
- promptMessage: 'Expose trust store as message source',
- title: 'Tick to expose trust store as message source'" />
+ <div class="clear">
+
+ <div id="addStore.exposedAsMessageSourceLabel" class="formLabel-labelCell tableContainer-labelCell">Exposed As Message Source:</div>
+ <div class="formLabel-controlCell tableContainer-valueCell">
+ <input type="text" id="addStore.exposedAsMessageSource"
+ data-dojo-type="dijit/form/CheckBox"
+ data-dojo-props="
+ name: 'exposedAsMessageSource'" />
+ <div data-dojo-type="dijit/Tooltip"
+ data-dojo-props="connectId: ['addStore.exposedAsMessageSource'],
+ label: 'Expose trust store as message source'">
+ </div>
+ </div>
+ <div class="clear">
+ <div id="addStore.trustAnchorValidityEnforcedLabel" class="formLabel-labelCell tableContainer-labelCell">Trust Anchor Validity Enforced:</div>
+ <div class="formLabel-controlCell tableContainer-valueCell">
+ <input type="text" id="addStore.trustAnchorValidityEnforced"
+ data-dojo-type="dijit/form/CheckBox"
+ data-dojo-props="
+ name: 'trustAnchorValidityEnforced'" />
+ <div data-dojo-type="dijit/Tooltip"
+ data-dojo-props="connectId: ['addStore.trustAnchorValidityEnforced'],
+ label: 'If true, trust anchor validity dates will be enforced'">
+ </div>
+ </div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/doc/java-broker/src/docbkx/management/managing/Java-Broker-Management-Managing-Truststores.xml
----------------------------------------------------------------------
diff --git a/doc/java-broker/src/docbkx/management/managing/Java-Broker-Management-Managing-Truststores.xml b/doc/java-broker/src/docbkx/management/managing/Java-Broker-Management-Managing-Truststores.xml
index 37f02cd..3c03019 100644
--- a/doc/java-broker/src/docbkx/management/managing/Java-Broker-Management-Managing-Truststores.xml
+++ b/doc/java-broker/src/docbkx/management/managing/Java-Broker-Management-Managing-Truststores.xml
@@ -81,6 +81,10 @@
will distribute certificates contained within the trustore to clients.
Used by the end to end message encryption feature.</para>
</listitem>
+ <listitem>
+ <para><emphasis>Trust Anchor Validity Enforced</emphasis>. If enabled, authentications will
+ fail if the trust anchor's validity date has not yet been reached or already expired.</para>
+ </listitem>
</itemizedlist>
</para>
<para>The following attributes apply to <emphasis>File Trust Stores</emphasis> only.</para>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d55b08e8/test-profiles/test_resources/ssl/expired.crt
----------------------------------------------------------------------
diff --git a/test-profiles/test_resources/ssl/expired.crt b/test-profiles/test_resources/ssl/expired.crt
new file mode 100644
index 0000000..933330a
--- /dev/null
+++ b/test-profiles/test_resources/ssl/expired.crt
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICvzCCAaegAwIBAgIEAjtn8zANBgkqhkiG9w0BAQ0FADAQMQ4wDAYDVQQDEwVV
+U0VSMTAeFw0xMDAxMDEyMjQ0MjVaFw0xMDAxMDIyMjQ0MjVaMBAxDjAMBgNVBAMT
+BVVTRVIxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj2wa5um63bXJ
+j7jv3pfhDgkvwE9hfM/DLv1rmkq2Psepefb40VJng61WiTeLNWdXrAJ+ui5iHTCn
+8n+iqaucaPv4mOwH3j57CCLRvFrFSp/cUx2oZ3Zx1DfaSgfIc5F8AJQvYrtCxa6m
+eYCoUJ3BZqARiKc6fk/RtACB1YI9mCDYOgnntNhEwMkRTuPqholyaL1fmw51EDGH
+iGCQwsxj+YMLkuK2aQAs498NcA6fzui0Ey3MJ6LmLYbOSKqZ1cBzC4YfSGH921Ic
+4YDgsvQ1io1zN4AJFHj8ld5rlDCTElgUFmkm2wCLvQAQ9+5MB4fDVLFldpHHBgX2
+0097qFSAEwIDAQABoyEwHzAdBgNVHQ4EFgQUZ30jJvIgSSRkltqIKv7UgEYnlvUw
+DQYJKoZIhvcNAQENBQADggEBABYZ+ZwbRnJvfjnFq9c+GV5/7FJOTlO0SVAVZrYJ
+HzquTr3mFDkhOc6aDlaNGiFAJcs6Udj3MvV7J+Uuai9oJDmVCt94HZL3k09G+z1b
+A3BorBKWDYm2L9CKpjUgD0VY40Tc2yNVyrzCbdjVnBkrLKiAirSrb5NJK2lnJg4Y
+TB7TiAnSydfRWUyUo8/wEMgIo4o0vuB7AnBQFhCd0XRmxBNoBZ19f+R041I6CQ0L
+9jc172XWHL1o111/RS7M8qLcWxi11DN62p6IKNT32DnhVV0RFnfVTQDaQ9qsPFmg
+Dngy+2weYwc6hEKhnunGrv0LNoqp6lQbOZO4c4v0/ynBHf4=
+-----END CERTIFICATE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org