From 9dfd114d53794c8875889bee547711ad38e4aceb Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 7 Oct 2008 14:10:39 +0000 Subject: This is a fix for QPID-1319. If SSL is specified as an option in the ConnectionURL then it will be copied to the broker level options. If SSL is also specified in the broker URL then it will override the value given at the top level. I also added a simple test case for this use case. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702488 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQBrokerDetails.java | 42 ++++++++++++++++++---- .../java/org/apache/qpid/jms/BrokerDetails.java | 2 ++ 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'qpid/java/client/src/main') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java index f051450260..fefb78d681 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.url.URLHelper; import org.apache.qpid.url.URLSyntaxException; @@ -35,18 +36,28 @@ public class AMQBrokerDetails implements BrokerDetails private int _port; private String _transport; - private Map _options; + private Map _options = new HashMap(); private SSLConfiguration _sslConfiguration; - public AMQBrokerDetails() - { - _options = new HashMap(); + public AMQBrokerDetails(){} + + public AMQBrokerDetails(String url)throws URLSyntaxException + { + this(url,null); } - public AMQBrokerDetails(String url) throws URLSyntaxException - { - this(); + public AMQBrokerDetails(String url,Map options) throws URLSyntaxException + { + /* According to the wiki the AMQBroker options should default to connection level options. + unless overridden by broker specific options. + Currently there seems to be only one such option (SSL). + */ + if (options != null) + { + _options.put(ConnectionURL.OPTIONS_SSL,options.get(ConnectionURL.OPTIONS_SSL)); + } + // URL should be of format tcp://host:port?option='value',option='value' try { @@ -252,6 +263,23 @@ public class AMQBrokerDetails implements BrokerDetails return BrokerDetails.DEFAULT_CONNECT_TIMEOUT; } + + public boolean useSSL() + { + if (_options.containsKey(ConnectionURL.OPTIONS_SSL)) + { + try + { + return Boolean.parseBoolean(_options.get(ConnectionURL.OPTIONS_SSL)); + } + catch (NumberFormatException nfe) + { + //Do nothing as we will use the default below. + } + } + + return false; + } public void setTimeout(long timeout) { diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java index 0316255b2c..07e1be95dc 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java @@ -94,6 +94,8 @@ public interface BrokerDetails SSLConfiguration getSSLConfiguration(); void setSSLConfiguration(SSLConfiguration sslConfiguration); + + boolean useSSL(); String toString(); -- cgit v1.2.1