activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [activemq] branch activemq-5.15.x updated: AMQ-6908 allow use of ActiveMQ console login credential (for authorization) when browsing messages through the console
Date Mon, 18 Nov 2019 15:59:59 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.15.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
     new 822cf62  AMQ-6908 allow use of ActiveMQ console login credential (for authorization)
when browsing messages through the console
     new a393b8c  Merge pull request #280 from alvinlin123/amq-6908
822cf62 is described below

commit 822cf6203437f06a58e8e442de87b8416ad232e6
Author: Alvin Lin <alvinlin@amazon.com>
AuthorDate: Fri Mar 16 11:30:05 2018 -0700

    AMQ-6908 allow use of ActiveMQ console login credential (for authorization) when browsing
messages through the console
---
 .../java/org/apache/activemq/web/MessageQuery.java | 16 ++++++-------
 .../org/apache/activemq/web/QueueBrowseQuery.java  | 28 ++++++++++------------
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageQuery.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageQuery.java
index 79fab49..3ccad48 100644
--- a/activemq-web/src/main/java/org/apache/activemq/web/MessageQuery.java
+++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageQuery.java
@@ -16,9 +16,6 @@
  */
 package org.apache.activemq.web;
 
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
 import javax.jms.BytesMessage;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
@@ -27,19 +24,22 @@ import javax.jms.ObjectMessage;
 import javax.jms.QueueBrowser;
 import javax.jms.StreamMessage;
 import javax.jms.TextMessage;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Allow the user to browse a message on a queue by its ID
- * 
- * 
+ *
+ *
  */
 public class MessageQuery extends QueueBrowseQuery {
 
     private String id;
     private Message message;
 
-    public MessageQuery(BrokerFacade brokerFacade, SessionPool sessionPool) throws JMSException
{
-        super(brokerFacade, sessionPool);
+    public MessageQuery(BrokerFacade brokerFacade) throws JMSException {
+        super(brokerFacade);
     }
 
     public String getId() {
@@ -111,7 +111,7 @@ public class MessageQuery extends QueueBrowseQuery {
 
         return null;
     }
-    
+
     public boolean isDLQ() throws Exception {
     	return getQueueView().isDLQ();
     }
diff --git a/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java b/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java
index e2532b9..db93654 100644
--- a/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java
+++ b/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java
@@ -16,28 +16,26 @@
  */
 package org.apache.activemq.web;
 
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.QueueBrowser;
 import javax.jms.Session;
 
-import org.springframework.beans.factory.DisposableBean;
-
 /**
- * 
- * 
+ *
+ *
  */
 public class QueueBrowseQuery extends DestinationFacade implements DisposableBean {
-    private SessionPool sessionPool;
     private String selector;
-    private Session session;
     private Queue queue;
     private QueueBrowser browser;
 
-    public QueueBrowseQuery(BrokerFacade brokerFacade, SessionPool sessionPool) throws JMSException
{
+    public QueueBrowseQuery(BrokerFacade brokerFacade) throws JMSException {
         super(brokerFacade);
-        this.sessionPool = sessionPool;
-        this.session = sessionPool.borrowSession();
         setJMSDestinationType("query");
     }
 
@@ -45,8 +43,6 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
         if (browser != null) {
             browser.close();
         }
-        sessionPool.returnSession(session);
-        session = null;
     }
 
     public QueueBrowser getBrowser() throws JMSException {
@@ -62,7 +58,7 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
 
     public Queue getQueue() throws JMSException {
         if (queue == null) {
-            queue = session.createQueue(getValidDestination());
+            queue = getSession().createQueue(getValidDestination());
         }
         return queue;
     }
@@ -79,10 +75,13 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
         this.selector = selector;
     }
 
-    public Session getSession() {
-        return session;
+    public Session getSession() throws JMSException {
+        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
+
+        return WebClient.getWebClient(servletRequestAttributes.getRequest()).getSession();
     }
 
+
     public boolean isQueue() {
         return true;
     }
@@ -91,5 +90,4 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
         return getSession().createBrowser(getQueue(), getSelector());
     }
 
-    
 }


Mime
View raw message