mirror of https://github.com/apache/activemq.git
fix and test for: https://issues.apache.org/jira/browse/AMQ-4373
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1456485 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fbe632e968
commit
f87f56294d
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.activemq.util;
|
package org.apache.activemq.util;
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
|
import javax.jms.JMSSecurityException;
|
||||||
import javax.jms.MessageEOFException;
|
import javax.jms.MessageEOFException;
|
||||||
import javax.jms.MessageFormatException;
|
import javax.jms.MessageFormatException;
|
||||||
|
|
||||||
|
@ -46,7 +47,12 @@ public final class JMSExceptionSupport {
|
||||||
if (msg == null || msg.length() == 0) {
|
if (msg == null || msg.length() == 0) {
|
||||||
msg = cause.toString();
|
msg = cause.toString();
|
||||||
}
|
}
|
||||||
JMSException exception = new JMSException(msg);
|
JMSException exception;
|
||||||
|
if (cause instanceof SecurityException) {
|
||||||
|
exception = new JMSSecurityException(msg);
|
||||||
|
} else {
|
||||||
|
exception = new JMSException(msg);
|
||||||
|
}
|
||||||
exception.initCause(cause);
|
exception.initCause(cause);
|
||||||
return exception;
|
return exception;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +65,12 @@ public final class JMSExceptionSupport {
|
||||||
if (msg == null || msg.length() == 0) {
|
if (msg == null || msg.length() == 0) {
|
||||||
msg = cause.toString();
|
msg = cause.toString();
|
||||||
}
|
}
|
||||||
JMSException exception = new JMSException(msg);
|
JMSException exception;
|
||||||
|
if (cause instanceof SecurityException) {
|
||||||
|
exception = new JMSSecurityException(msg);
|
||||||
|
} else {
|
||||||
|
exception = new JMSException(msg);
|
||||||
|
}
|
||||||
exception.setLinkedException(cause);
|
exception.setLinkedException(cause);
|
||||||
exception.initCause(cause);
|
exception.initCause(cause);
|
||||||
return exception;
|
return exception;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.net.URI;
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
|
import javax.jms.JMSSecurityException;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.jms.MessageProducer;
|
import javax.jms.MessageProducer;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
|
@ -104,6 +105,19 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport {
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testConnectionStartThrowsJMSSecurityException() throws Exception {
|
||||||
|
|
||||||
|
Connection connection = factory.createConnection("badUser", "password");
|
||||||
|
try {
|
||||||
|
connection.start();
|
||||||
|
fail("Should throw JMSSecurityException");
|
||||||
|
} catch (JMSSecurityException jmsEx) {
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.info("Expected JMSSecurityException but was: {}", e.getClass());
|
||||||
|
fail("Should throw JMSSecurityException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testSecurityContextClearedOnPurge() throws Exception {
|
public void testSecurityContextClearedOnPurge() throws Exception {
|
||||||
|
|
||||||
connection.close();
|
connection.close();
|
||||||
|
|
Loading…
Reference in New Issue