activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-522 fix AMQP ANON advert
Date Tue, 17 May 2016 16:34:28 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master bbe365eb6 -> 664636dbd


ARTEMIS-522 fix AMQP ANON advert


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/b9b41070
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/b9b41070
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/b9b41070

Branch: refs/heads/master
Commit: b9b41070206b743e5a4fea0d800803e38a218b05
Parents: bbe365e
Author: jbertram <jbertram@apache.org>
Authored: Tue May 17 08:46:36 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue May 17 12:34:10 2016 -0400

----------------------------------------------------------------------
 .../plug/ActiveMQProtonConnectionCallback.java  | 20 +++++++++++++++++++-
 .../protocol/proton/sasl/ActiveMQPlainSASL.java | 14 ++++++++------
 2 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b9b41070/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/plug/ActiveMQProtonConnectionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/plug/ActiveMQProtonConnectionCallback.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/plug/ActiveMQProtonConnectionCallback.java
index f8514db..7e0fe22 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/plug/ActiveMQProtonConnectionCallback.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/plug/ActiveMQProtonConnectionCallback.java
@@ -56,7 +56,25 @@ public class ActiveMQProtonConnectionCallback implements AMQPConnectionCallback
 
    @Override
    public ServerSASL[] getSASLMechnisms() {
-      return new ServerSASL[]{new AnonymousServerSASL(), new ActiveMQPlainSASL(manager.getServer().getSecurityStore(),
manager.getServer().getSecurityManager())};
+      boolean supportsAnonymous = false;
+      try {
+         manager.getServer().getSecurityStore().authenticate(null, null, null);
+         supportsAnonymous = true;
+      }
+      catch (Exception e) {
+         // authentication failed so no anonymous support
+      }
+
+      ServerSASL[] result;
+
+      if (supportsAnonymous) {
+         result = new ServerSASL[]{new AnonymousServerSASL(), new ActiveMQPlainSASL(manager.getServer().getSecurityStore())};
+      }
+      else {
+         result = new ServerSASL[]{new ActiveMQPlainSASL(manager.getServer().getSecurityStore())};
+      }
+
+      return result;
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b9b41070/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/sasl/ActiveMQPlainSASL.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/sasl/ActiveMQPlainSASL.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/sasl/ActiveMQPlainSASL.java
index c60e9cd..bf4f043 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/sasl/ActiveMQPlainSASL.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/sasl/ActiveMQPlainSASL.java
@@ -17,24 +17,26 @@
 package org.apache.activemq.artemis.core.protocol.proton.sasl;
 
 import org.apache.activemq.artemis.core.security.SecurityStore;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 import org.proton.plug.sasl.ServerSASLPlain;
 
 public class ActiveMQPlainSASL extends ServerSASLPlain {
 
-   private final ActiveMQSecurityManager securityManager;
-
    private final SecurityStore securityStore;
 
-   public ActiveMQPlainSASL(SecurityStore securityStore, ActiveMQSecurityManager securityManager)
{
-      this.securityManager = securityManager;
+   public ActiveMQPlainSASL(SecurityStore securityStore) {
       this.securityStore = securityStore;
    }
 
    @Override
    protected boolean authenticate(String user, String password) {
       if (securityStore.isSecurityEnabled()) {
-         return securityManager.validateUser(user, password);
+         try {
+            securityStore.authenticate(user, password, null);
+            return true;
+         }
+         catch (Exception e) {
+            return false;
+         }
       }
       else {
          return true;


Mime
View raw message