mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1457996 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4cbfbbb10c
commit
1d9b347157
|
@ -16,10 +16,13 @@
|
|||
*/
|
||||
package org.apache.activemq.bugs;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.Socket;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.transport.stomp.Stomp;
|
||||
|
@ -29,76 +32,72 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public class AMQ4133Test {
|
||||
|
||||
protected String java_security_auth_login_config = "java.security.auth.login.config";
|
||||
|
||||
protected String java_security_auth_login_config = "java.security.auth.login.config";
|
||||
protected String xbean = "xbean:";
|
||||
protected String confBase = "src/test/resources/org/apache/activemq/bugs/amq4126";
|
||||
protected String certBase = "src/test/resources/org/apache/activemq/security";
|
||||
protected String sep = File.separator;
|
||||
protected String activemqXml = "InconsistentConnectorPropertiesBehaviour.xml";
|
||||
protected BrokerService broker;
|
||||
|
||||
protected String oldLoginConf = null;
|
||||
protected BrokerService broker;
|
||||
|
||||
protected String oldLoginConf = null;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
if (System.getProperty(java_security_auth_login_config) != null) {
|
||||
if (System.getProperty(java_security_auth_login_config) != null) {
|
||||
oldLoginConf = System.getProperty(java_security_auth_login_config);
|
||||
}
|
||||
System.setProperty(java_security_auth_login_config, confBase + sep + "login.config");
|
||||
broker = BrokerFactory.createBroker(xbean + confBase + sep + activemqXml);
|
||||
|
||||
System.setProperty(java_security_auth_login_config, confBase + "/" + "login.config");
|
||||
broker = BrokerFactory.createBroker(xbean + confBase + "/" + activemqXml);
|
||||
|
||||
broker.start();
|
||||
broker.waitUntilStarted();
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
if (broker != null) {
|
||||
if (broker != null) {
|
||||
broker.stop();
|
||||
broker.waitUntilStopped();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void stompSSLTransportNeedClientAuthTrue() throws Exception {
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl").getConnectUri().getPort());
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl").getConnectUri().getPort());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void stompSSLNeedClientAuthTrue() throws Exception {
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl+special").getConnectUri().getPort());
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl+special").getConnectUri().getPort());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void stompNIOSSLTransportNeedClientAuthTrue() throws Exception {
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl").getConnectUri().getPort());
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl").getConnectUri().getPort());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void stompNIOSSLNeedClientAuthTrue() throws Exception {
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl+special").getConnectUri().getPort());
|
||||
stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl+special").getConnectUri().getPort());
|
||||
}
|
||||
|
||||
|
||||
public Socket createSocket(String host, int port) throws Exception {
|
||||
System.setProperty("javax.net.ssl.trustStore", certBase + sep + "broker1.ks");
|
||||
System.setProperty("javax.net.ssl.trustStore", certBase + "/" + "broker1.ks");
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", "password");
|
||||
System.setProperty("javax.net.ssl.trustStoreType", "jks");
|
||||
System.setProperty("javax.net.ssl.keyStore", certBase + sep + "client.ks");
|
||||
System.setProperty("javax.net.ssl.keyStore", certBase + "/" + "client.ks");
|
||||
System.setProperty("javax.net.ssl.keyStorePassword", "password");
|
||||
System.setProperty("javax.net.ssl.keyStoreType", "jks");
|
||||
|
||||
SocketFactory factory = SSLSocketFactory.getDefault();
|
||||
return factory.createSocket(host, port);
|
||||
}
|
||||
|
||||
|
||||
public void stompConnectTo(String host, int port) throws Exception {
|
||||
StompConnection stompConnection = new StompConnection();
|
||||
stompConnection.open(createSocket(host, port));
|
||||
StompConnection stompConnection = new StompConnection();
|
||||
stompConnection.open(createSocket(host, port));
|
||||
stompConnection.sendFrame("CONNECT\n" + "\n" + Stomp.NULL);
|
||||
StompFrame f = stompConnection.receive();
|
||||
TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());
|
||||
|
|
Loading…
Reference in New Issue