git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1355183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-06-28 22:20:09 +00:00
parent 87b2920927
commit b7a1883b4b
6 changed files with 154 additions and 7 deletions

View File

@ -87,5 +87,14 @@ public class StompNIOTransportFactory extends NIOTransportFactory implements Bro
this.brokerContext = brokerService.getBrokerContext(); this.brokerContext = brokerService.getBrokerContext();
} }
@Override
protected Transport createInactivityMonitor(Transport transport, WireFormat format) {
StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format);
StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class);
filter.setInactivityMonitor(monitor);
return monitor;
}
} }

View File

@ -65,4 +65,13 @@ public class StompSslTransportFactory extends SslTransportFactory implements Bro
this.brokerContext = brokerService.getBrokerContext(); this.brokerContext = brokerService.getBrokerContext();
} }
@Override
protected Transport createInactivityMonitor(Transport transport, WireFormat format) {
StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format);
StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class);
filter.setInactivityMonitor(monitor);
return monitor;
}
} }

View File

@ -0,0 +1,44 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.transport.stomp;
import java.io.IOException;
import java.net.Socket;
import java.net.URI;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
public class Stomp11NIOSSLTest extends Stomp11Test {
protected void setUp() throws Exception {
bindAddress = "stomp+nio+ssl://localhost:61613";
confUri = "xbean:org/apache/activemq/transport/stomp/sslstomp-auth-broker.xml";
System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
super.setUp();
}
protected Socket createSocket(URI connectUri) throws IOException {
SocketFactory factory = SSLSocketFactory.getDefault();
return factory.createSocket("127.0.0.1", connectUri.getPort());
}
}

View File

@ -0,0 +1,27 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.transport.stomp;
public class Stomp11NIOTest extends Stomp11Test {
@Override
protected void setUp() throws Exception {
bindAddress = "stomp+nio://localhost:61612";
confUri = "xbean:org/apache/activemq/transport/stomp/niostomp-auth-broker.xml";
super.setUp();
}
}

View File

@ -0,0 +1,56 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.transport.stomp;
import java.io.IOException;
import java.net.Socket;
import java.net.URI;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
/**
*
*/
public class Stomp11SslAuthTest extends Stomp11Test {
protected void setUp() throws Exception {
// Test mutual authentication on both stomp and standard ssl transports
bindAddress = "stomp+ssl://localhost:61612";
confUri = "xbean:org/apache/activemq/transport/stomp/sslstomp-mutual-auth-broker.xml";
jmsUri="ssl://localhost:61617";
System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
//System.setProperty("javax.net.debug","ssl,handshake");
super.setUp();
}
protected Socket createSocket(URI connectUri) throws IOException {
SocketFactory factory = SSLSocketFactory.getDefault();
return factory.createSocket("127.0.0.1", connectUri.getPort());
}
}

View File

@ -197,12 +197,12 @@ public class Stomp11Test extends CombinationTestSupport {
stompConnection.sendFrame(connectFrame); stompConnection.sendFrame(connectFrame);
String f = stompConnection.receiveFrame(); String f = stompConnection.receiveFrame();
assertTrue(f.startsWith("CONNECTED")); assertTrue("Failed to receive a connected frame.", f.startsWith("CONNECTED"));
assertTrue(f.indexOf("version:1.1") >= 0); assertTrue("Frame should have a versoion 1.1 header.", f.indexOf("version:1.1") >= 0);
assertTrue(f.indexOf("heart-beat:") >= 0); assertTrue("Frame should have a heart beat header.", f.indexOf("heart-beat:") >= 0);
assertTrue(f.indexOf("session:") >= 0); assertTrue("Frame should have a session header.", f.indexOf("session:") >= 0);
LOG.debug("Broker sent: " + f); LOG.info("Broker sent: " + f);
stompConnection.getStompSocket().getOutputStream().write('\n'); stompConnection.getStompSocket().getOutputStream().write('\n');
@ -278,11 +278,13 @@ public class Stomp11Test extends CombinationTestSupport {
Thread.sleep(TimeUnit.SECONDS.toMillis(10)); Thread.sleep(TimeUnit.SECONDS.toMillis(10));
try { try {
String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL; String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" +
"receipt:1\n\n" + "Hello World" + Stomp.NULL;
stompConnection.sendFrame(message); stompConnection.sendFrame(message);
stompConnection.receiveFrame();
fail("SEND frame has been accepted after missing heart beat"); fail("SEND frame has been accepted after missing heart beat");
} catch (Exception ex) { } catch (Exception ex) {
System.out.println(ex.getMessage()); LOG.info(ex.getMessage());
} }
} }