activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5938 - remove unnecessary topic cast - breaks auth scenario. Fix and test
Date Mon, 21 Sep 2015 13:49:09 GMT
Repository: activemq
Updated Branches:
  refs/heads/master e9aedc801 -> cc9b9b084


https://issues.apache.org/jira/browse/AMQ-5938 - remove unnecessary topic cast - breaks auth
scenario. Fix and test


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

Branch: refs/heads/master
Commit: cc9b9b0843d7e404bdeca1a1dd09d9a9e958f967
Parents: e9aedc8
Author: gtully <gary.tully@gmail.com>
Authored: Mon Sep 21 14:48:44 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Mon Sep 21 14:48:44 2015 +0100

----------------------------------------------------------------------
 .../broker/jmx/ManagedRegionBroker.java         |  4 +--
 ...ableSubscriptionOfflineBrowseRemoveTest.java | 33 ++++++++++++++++++++
 .../DurableSubscriptionOfflineTestBase.java     |  5 +++
 3 files changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/cc9b9b08/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
index 854f5e0..601fd15 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
@@ -565,7 +565,7 @@ public class ManagedRegionBroker extends RegionBroker {
     public void remove(SubscriptionView view, String messageId)  throws Exception {
         ActiveMQDestination destination = getTopicDestination(view);
         if (destination != null) {
-            final Topic topic = (Topic) getTopicRegion().getDestinationMap().get(destination);
+            final Destination topic = getTopicRegion().getDestinationMap().get(destination);
             final MessageAck messageAck = new MessageAck();
             messageAck.setMessageID(new MessageId(messageId));
             messageAck.setDestination(destination);
@@ -588,7 +588,7 @@ public class ManagedRegionBroker extends RegionBroker {
     protected Message[] getSubscriberMessages(SubscriptionView view) {
         ActiveMQDestination destination = getTopicDestination(view);
         if (destination != null) {
-            Topic topic = (Topic) getTopicRegion().getDestinationMap().get(destination);
+            Destination topic = getTopicRegion().getDestinationMap().get(destination);
             return topic.browse();
 
         } else {

http://git-wip-us.apache.org/repos/asf/activemq/blob/cc9b9b08/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineBrowseRemoveTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineBrowseRemoveTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineBrowseRemoveTest.java
index 0532ede..7c747b6 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineBrowseRemoveTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineBrowseRemoveTest.java
@@ -29,8 +29,15 @@ import javax.management.ObjectName;
 import javax.management.openmbean.CompositeData;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.TestSupport;
+import org.apache.activemq.broker.BrokerPlugin;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
+import org.apache.activemq.filter.DestinationMapEntry;
+import org.apache.activemq.security.AuthenticationUser;
+import org.apache.activemq.security.AuthorizationEntry;
+import org.apache.activemq.security.AuthorizationPlugin;
+import org.apache.activemq.security.DefaultAuthorizationMap;
+import org.apache.activemq.security.SimpleAuthenticationPlugin;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
 import org.junit.Test;
@@ -48,6 +55,7 @@ public class DurableSubscriptionOfflineBrowseRemoveTest extends DurableSubscript
 
     private static final Logger LOG = LoggerFactory.getLogger(DurableSubscriptionOfflineBrowseRemoveTest.class);
 
+    public static final String IDENTITY = "milly";
     public boolean keepDurableSubsActive;
 
     @Parameterized.Parameters(name = "PA-{0}.KeepSubsActive-{1}")
@@ -70,6 +78,29 @@ public class DurableSubscriptionOfflineBrowseRemoveTest extends DurableSubscript
     }
 
     @Override
+    public void configurePlugins(BrokerService brokerService) throws Exception {
+        List<DestinationMapEntry> authorizationEntries = new ArrayList<>();
+
+        AuthorizationEntry entry = new AuthorizationEntry();
+        entry.setTopic(">");
+        entry.setRead(IDENTITY);
+        entry.setWrite(IDENTITY);
+        entry.setAdmin(IDENTITY);
+        authorizationEntries.add(entry);
+
+        DefaultAuthorizationMap authorizationMap = new DefaultAuthorizationMap(authorizationEntries);
+        AuthorizationPlugin authorizationPlugin = new AuthorizationPlugin(authorizationMap);
+
+        List<AuthenticationUser> users = new ArrayList<>();
+        users.add(new AuthenticationUser(IDENTITY, IDENTITY, IDENTITY));
+
+        SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
+
+
+        broker.setPlugins(new BrokerPlugin[]{authenticationPlugin, authorizationPlugin});
+
+    }
+    @Override
     public PersistenceAdapter setDefaultPersistenceAdapter(BrokerService broker) throws IOException
{
         broker.setKeepDurableSubsActive(keepDurableSubsActive);
         return super.setPersistenceAdapter(broker, defaultPersistenceAdapter);
@@ -78,6 +109,8 @@ public class DurableSubscriptionOfflineBrowseRemoveTest extends DurableSubscript
     @Override
     protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://"
+ getName(true));
+        connectionFactory.setUserName(IDENTITY);
+        connectionFactory.setPassword(IDENTITY);
         connectionFactory.setWatchTopicAdvisories(false);
         return connectionFactory;
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/cc9b9b08/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java
index 3bffb4e..74abf8a 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTestBase.java
@@ -130,10 +130,15 @@ public abstract class DurableSubscriptionOfflineTestBase {
             // have lots of journal files
             ((KahaDBPersistenceAdapter)broker.getPersistenceAdapter()).setJournalMaxFileLength(journalMaxFileLength);
         }
+
+        configurePlugins(broker);
         broker.start();
         broker.waitUntilStarted();
     }
 
+    public void configurePlugins(BrokerService broker) throws Exception {
+    }
+
     protected void destroyBroker() throws Exception {
         if (broker != null)
             broker.stop();


Mime
View raw message