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/01 08:27:32 UTC

[1/2] qpid-broker-j git commit: QPID-7869: [Java Broker] [Truststore] The on-delete integrity check should consider OAuth Authentication Providers too

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master a94d6ffe8 -> 94c9e5ba2


QPID-7869: [Java Broker] [Truststore] The on-delete integrity check should consider OAuth Authentication Providers too


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/f56e9cb4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/f56e9cb4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/f56e9cb4

Branch: refs/heads/master
Commit: f56e9cb429e54aacbf3c0d3592f0c963e3579dec
Parents: a94d6ff
Author: Keith Wall <kw...@apache.org>
Authored: Mon Jul 31 15:56:21 2017 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Aug 1 09:26:56 2017 +0100

----------------------------------------------------------------------
 .../server/security/AbstractTrustStore.java     | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f56e9cb4/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
index db42d3b..acfdbc1 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/AbstractTrustStore.java
@@ -49,6 +49,7 @@ import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManager;
+import org.apache.qpid.server.security.auth.manager.oauth2.OAuth2AuthenticationProvider;
 
 public abstract class AbstractTrustStore<X extends AbstractTrustStore<X>>
         extends AbstractConfiguredObject<X> implements TrustStore<X>
@@ -160,16 +161,22 @@ public abstract class AbstractTrustStore<X extends AbstractTrustStore<X>>
         Collection<AuthenticationProvider> authenticationProviders = new ArrayList<>(_broker.getAuthenticationProviders());
         for (AuthenticationProvider authProvider : authenticationProviders)
         {
+            TrustStore otherTrustStore = null;
             if (authProvider instanceof SimpleLDAPAuthenticationManager)
             {
-                SimpleLDAPAuthenticationManager simpleLdap = (SimpleLDAPAuthenticationManager) authProvider;
-                if (simpleLdap.getTrustStore() == this)
-                {
-                    throw new IntegrityViolationException("Trust store '"
-                                                          + storeName
-                                                          + "' can't be deleted as it is in use by an authentication manager: "
-                                                          + authProvider.getName());
-                }
+                otherTrustStore = ((SimpleLDAPAuthenticationManager) authProvider).getTrustStore();
+            }
+            else if (authProvider instanceof OAuth2AuthenticationProvider)
+            {
+                otherTrustStore = ((OAuth2AuthenticationProvider) authProvider).getTrustStore();
+            }
+
+            if (otherTrustStore == this)
+            {
+                throw new IntegrityViolationException(String.format(
+                        "Trust store '%s' can't be deleted as it is in use by an authentication manager: '%s'",
+                        getName(),
+                        authProvider.getName()));
             }
         }
         deleted();


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


[2/2] qpid-broker-j git commit: QPID-7869: [Java Broker] Reformat QpidMultipleTrustManager/QpidPeersOnlyTrustManager - no functional change

Posted by kw...@apache.org.
QPID-7869: [Java Broker] Reformat QpidMultipleTrustManager/QpidPeersOnlyTrustManager - no functional change


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/94c9e5ba
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/94c9e5ba
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/94c9e5ba

Branch: refs/heads/master
Commit: 94c9e5ba22de89c7a6f7311fdc8544c4e71c716a
Parents: f56e9cb
Author: Keith Wall <kw...@apache.org>
Authored: Tue Aug 1 08:39:12 2017 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Aug 1 09:27:17 2017 +0100

----------------------------------------------------------------------
 .../security/ssl/QpidMultipleTrustManager.java  | 39 +++++++++++--------
 .../security/ssl/QpidPeersOnlyTrustManager.java | 41 ++++++++++++--------
 2 files changed, 46 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/94c9e5ba/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidMultipleTrustManager.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidMultipleTrustManager.java b/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidMultipleTrustManager.java
index 7715517..b56d2f6 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidMultipleTrustManager.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidMultipleTrustManager.java
@@ -33,28 +33,31 @@ import javax.net.ssl.X509TrustManager;
  * Supports multiple X509TrustManager(s). Check succeeds if any of the
  * underlying managers succeeds.
  */
-public class QpidMultipleTrustManager implements X509TrustManager {
+public class QpidMultipleTrustManager implements X509TrustManager
+{
 
-    private List<X509TrustManager> trustManagers;
+    private final List<X509TrustManager> _trustManagers;
 
-    public QpidMultipleTrustManager() {
-        this.trustManagers = new ArrayList<X509TrustManager>();
+    public QpidMultipleTrustManager()
+    {
+        _trustManagers = new ArrayList<>();
     }
 
     public boolean isEmpty()
     {
-        return trustManagers.isEmpty();
+        return _trustManagers.isEmpty();
     }
-    
+
     public void addTrustManager(final X509TrustManager trustManager)
     {
-        this.trustManagers.add(trustManager);
+        _trustManagers.add(trustManager);
     }
-    
+
     @Override
     public void checkClientTrusted(X509Certificate[] chain, String authType)
-            throws CertificateException {
-        for (X509TrustManager trustManager : this.trustManagers)
+            throws CertificateException
+    {
+        for (X509TrustManager trustManager : _trustManagers)
         {
             try
             {
@@ -62,7 +65,7 @@ public class QpidMultipleTrustManager implements X509TrustManager {
                 // this trustManager check succeeded, no need to check another one
                 return;
             }
-            catch(CertificateException ex)
+            catch (CertificateException ex)
             {
                 // do nothing, try another one in a loop
             }
@@ -73,8 +76,9 @@ public class QpidMultipleTrustManager implements X509TrustManager {
 
     @Override
     public void checkServerTrusted(X509Certificate[] chain, String authType)
-            throws CertificateException {
-        for (X509TrustManager trustManager : this.trustManagers)
+            throws CertificateException
+    {
+        for (X509TrustManager trustManager : _trustManagers)
         {
             try
             {
@@ -82,7 +86,7 @@ public class QpidMultipleTrustManager implements X509TrustManager {
                 // this trustManager check succeeded, no need to check another one
                 return;
             }
-            catch(CertificateException ex)
+            catch (CertificateException ex)
             {
                 // do nothing, try another one in a loop
             }
@@ -92,9 +96,10 @@ public class QpidMultipleTrustManager implements X509TrustManager {
     }
 
     @Override
-    public X509Certificate[] getAcceptedIssuers() {
-        final Collection<X509Certificate> accIssuersCol = new ArrayList<X509Certificate>();
-        for (X509TrustManager trustManager : this.trustManagers)
+    public X509Certificate[] getAcceptedIssuers()
+    {
+        final Collection<X509Certificate> accIssuersCol = new ArrayList<>();
+        for (X509TrustManager trustManager : _trustManagers)
         {
             accIssuersCol.addAll(Arrays.asList(trustManager.getAcceptedIssuers()));
         }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/94c9e5ba/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidPeersOnlyTrustManager.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidPeersOnlyTrustManager.java b/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidPeersOnlyTrustManager.java
index 6b13b1d..b3f9610 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidPeersOnlyTrustManager.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/transport/network/security/ssl/QpidPeersOnlyTrustManager.java
@@ -34,33 +34,38 @@ import javax.net.ssl.X509TrustManager;
 /**
  * TrustManager implementation which accepts the client certificate
  * only if the underlying check by the delegate pass through and
- * the certificate is physically saved in the truststore. 
+ * the certificate is physically saved in the truststore.
  */
-public class QpidPeersOnlyTrustManager implements X509TrustManager {
+public class QpidPeersOnlyTrustManager implements X509TrustManager
+{
 
-    final private KeyStore ts;
-    final private X509TrustManager delegate;
-    final List<Certificate> trustedCerts = new ArrayList<Certificate>();
-    
-    public QpidPeersOnlyTrustManager(KeyStore ts, X509TrustManager trustManager) throws KeyStoreException {
-        this.ts = ts;
-        this.delegate = trustManager;
-        Enumeration<String> aliases = this.ts.aliases();
+    private final KeyStore _ts;
+    private final X509TrustManager _delegate;
+    private final List<Certificate> _trustedCerts = new ArrayList<>();
+
+    public QpidPeersOnlyTrustManager(KeyStore ts, X509TrustManager trustManager) throws KeyStoreException
+    {
+        _ts = ts;
+        _delegate = trustManager;
+        Enumeration<String> aliases = this._ts.aliases();
         while (aliases.hasMoreElements())
         {
-            trustedCerts.add(ts.getCertificate(aliases.nextElement()));
+            _trustedCerts.add(ts.getCertificate(aliases.nextElement()));
         }
     }
 
     @Override
     public void checkClientTrusted(X509Certificate[] chain, String authType)
-            throws CertificateException {
-        this.delegate.checkClientTrusted(chain, authType);
-        for (Certificate serverTrustedCert : this.trustedCerts)
+            throws CertificateException
+    {
+        _delegate.checkClientTrusted(chain, authType);
+        for (Certificate serverTrustedCert : this._trustedCerts)
         {
             // first position in the chain contains the peer's own certificate
             if (chain[0].equals(serverTrustedCert))
+            {
                 return;  // peer's certificate found in the store
+            }
         }
         // peer's certificate was not found in the store, do not trust the client
         throw new CertificateException();
@@ -68,12 +73,14 @@ public class QpidPeersOnlyTrustManager implements X509TrustManager {
 
     @Override
     public void checkServerTrusted(X509Certificate[] chain, String authType)
-            throws CertificateException {
-        this.delegate.checkServerTrusted(chain, authType);
+            throws CertificateException
+    {
+        _delegate.checkServerTrusted(chain, authType);
     }
 
     @Override
-    public X509Certificate[] getAcceptedIssuers() {
+    public X509Certificate[] getAcceptedIssuers()
+    {
         // return empty array since this implementation of TrustManager doesn't
         // rely on certification authorities
         return new X509Certificate[0];


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