AMQ-6908 allow use of ActiveMQ console login credential (for authorization) when browsing messages through the console

(cherry picked from commit 822cf62034)
This commit is contained in:
Alvin Lin 2018-03-16 11:30:05 -07:00 committed by Jean-Baptiste Onofré
parent a59ebe7d09
commit e7b7334e42
2 changed files with 21 additions and 23 deletions

View File

@ -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();
}

View File

@ -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());
}
}