diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2008-10-23 19:32:02 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2008-10-23 19:32:02 +0000 |
commit | 9113054ad3ef3a35c18bd601bf61ea4f04ae60e0 (patch) | |
tree | c6c70a06e4500dc862a54faecb409e519801dcaf | |
parent | b86dc28068add97e152bddfb514c02d0659f1088 (diff) | |
download | qpid-python-9113054ad3ef3a35c18bd601bf61ea4f04ae60e0.tar.gz |
This is for QPID-1296
added a boolean to the connect method to indicate whether an SSL connection should be created.
currently there seems to be two issues.
1. The shutdownInput method used in IoReceiver is not supported by the SSLSocket implementation.
2. I haven't able to get client side authentication working.
For item 1 we may need to use nio classes to get around the issue.
For item 2 I am yet to figure out the correct config options to get client side auth working.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@707453 13f79535-47bb-0310-9956-ffa450edef68
15 files changed, 41 insertions, 25 deletions
diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java index aa99112f32..38073cb7f2 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java @@ -36,7 +36,7 @@ public class DeclareQueue { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java index 1e571eeede..2234eb22da 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java @@ -38,7 +38,7 @@ public class DirectProducer { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java index 370573c3eb..93bb097268 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java @@ -64,7 +64,7 @@ public class Listener implements SessionListener { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java index 079be003b1..9c3ec2fb3b 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java @@ -36,7 +36,7 @@ public class DeclareQueue { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java index 257bcdbfb1..39d34713c6 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java @@ -38,7 +38,7 @@ public class FannoutProducer { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java index dead5569eb..4c72ce75a5 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java @@ -64,7 +64,7 @@ public class Listener implements SessionListener { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java index 2ed5b2d719..5e6d3c6f69 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java @@ -78,7 +78,7 @@ public class TopicListener implements SessionListener { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java index 20264d3791..facf08eeca 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java +++ b/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java @@ -57,7 +57,7 @@ public class TopicPublisher { // Create connection Connection con = new Connection(); - con.connect("localhost", 5672, "test", "guest", "guest"); + con.connect("localhost", 5672, "test", "guest", "guest",false); // Create session Session session = con.createSession(0); diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java index 6e886f25a8..116b163b3c 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java @@ -263,7 +263,9 @@ public class AMQProtocolHandler extends IoHandlerAdapter _protocolSession = new AMQProtocolSession(this, _connection); _stateManager.setProtocolSession(_protocolSession); IoTransport.connect_0_9(getProtocolSession(), - brokerDetail.getHost(), brokerDetail.getPort()); + brokerDetail.getHost(), + brokerDetail.getPort(), + brokerDetail.useSSL()); _protocolSession.init(); } diff --git a/java/common/src/main/java/org/apache/qpid/ToyClient.java b/java/common/src/main/java/org/apache/qpid/ToyClient.java index 8163210f14..3491af8cd2 100644 --- a/java/common/src/main/java/org/apache/qpid/ToyClient.java +++ b/java/common/src/main/java/org/apache/qpid/ToyClient.java @@ -52,7 +52,7 @@ class ToyClient implements SessionListener public static final void main(String[] args) { Connection conn = new Connection(); - conn.connect("0.0.0.0", 5672, null, "guest", "guest"); + conn.connect("0.0.0.0", 5672, null, "guest", "guest", false); Session ssn = conn.createSession(); ssn.setSessionListener(new ToyClient()); diff --git a/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/java/common/src/main/java/org/apache/qpid/transport/Connection.java index f4dc4408be..7a66c2c238 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -155,7 +155,7 @@ public class Connection extends ConnectionInvoker return saslClient; } - public void connect(String host, int port, String vhost, String username, String password) + public void connect(String host, int port, String vhost, String username, String password,boolean ssl) { synchronized (lock) { @@ -163,7 +163,7 @@ public class Connection extends ConnectionInvoker delegate = new ClientDelegate(vhost, username, password); - IoTransport.connect(host, port, ConnectionBinding.get(this)); + IoTransport.connect(host, port, ConnectionBinding.get(this),ssl); send(new ProtocolHeader(1, 0, 10)); Waiter w = new Waiter(lock, timeout); diff --git a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoTransport.java b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoTransport.java index be17766740..8d52c3269a 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/network/io/IoTransport.java +++ b/java/common/src/main/java/org/apache/qpid/transport/network/io/IoTransport.java @@ -26,6 +26,8 @@ import java.net.Socket; import java.net.SocketException; import java.nio.ByteBuffer; +import javax.net.ssl.SSLSocketFactory; + import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; import org.apache.qpid.transport.Binding; import org.apache.qpid.transport.Connection; @@ -98,22 +100,24 @@ public final class IoTransport<E> } public static final <E> E connect(String host, int port, - Binding<E,ByteBuffer> binding) + Binding<E,ByteBuffer> binding, + boolean ssl) { - Socket socket = createSocket(host, port); + Socket socket = createSocket(host, port,ssl); IoTransport<E> transport = new IoTransport<E>(socket, binding); return transport.endpoint; } public static final Connection connect(String host, int port, - ConnectionDelegate delegate) + ConnectionDelegate delegate, + boolean ssl) { - return connect(host, port, ConnectionBinding.get(delegate)); + return connect(host, port, ConnectionBinding.get(delegate),ssl); } - public static void connect_0_9(AMQVersionAwareProtocolSession session, String host, int port) + public static void connect_0_9(AMQVersionAwareProtocolSession session, String host, int port, boolean ssl) { - connect(host, port, new Binding_0_9(session)); + connect(host, port, new Binding_0_9(session),ssl); } private static class Binding_0_9 @@ -140,12 +144,21 @@ public final class IoTransport<E> } - private static Socket createSocket(String host, int port) + private static Socket createSocket(String host, int port, boolean ssl) { try { InetAddress address = InetAddress.getByName(host); - Socket socket = new Socket(); + Socket socket; + if (ssl) + { + SSLSocketFactory sslSocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + socket = sslSocketfactory.createSocket(); + } + else + { + socket = new Socket(); + } socket.setReuseAddress(true); socket.setTcpNoDelay(Boolean.getBoolean("amqj.tcpNoDelay")); diff --git a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java index 19e1c2537f..b1fe08bfb9 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java +++ b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java @@ -139,7 +139,7 @@ public class ConnectionTest extends TestCase implements SessionListener } } }); - conn.connect("localhost", port, null, "guest", "guest"); + conn.connect("localhost", port, null, "guest", "guest",false); return conn; } @@ -170,7 +170,7 @@ public class ConnectionTest extends TestCase implements SessionListener public void testResume() throws Exception { Connection conn = new Connection(); - conn.connect("localhost", port, null, "guest", "guest"); + conn.connect("localhost", port, null, "guest", "guest",false); conn.setConnectionListener(new ConnectionListener() { @@ -182,7 +182,7 @@ public class ConnectionTest extends TestCase implements SessionListener public void closed(Connection conn) { queue = true; - conn.connect("localhost", port, null, "guest", "guest"); + conn.connect("localhost", port, null, "guest", "guest",false); conn.resume(); } }); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java b/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java index 551f59d6b6..1a51085ad3 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java @@ -137,7 +137,8 @@ public final class QpidDatasource _connectionData.getPort(), _connectionData.getVirtualHost(), _connectionData.getUsername(), - _connectionData.getPassword()); + _connectionData.getPassword(), + false); return connection; } diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java b/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java index 61e6349d94..35418a4101 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java @@ -82,7 +82,7 @@ public class UTF8Test extends QpidTestCase Connection conn = new Connection(); if (!_broker.equals(QpidTestCase.EXTERNAL) && !isBroker08()) { - conn.connect("localhost", 5672, "test", "guest", "guest"); + conn.connect("localhost", 5672, "test", "guest", "guest",false); } else { |