summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2013-03-06 21:04:39 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2013-03-06 21:04:39 +0000
commita0a4fd7f3dafadcfd635c725de914367529fd7b3 (patch)
tree869a748ea165c160f188813098b5c7b97ff24005
parent3399b1e05ab462c6bb1c22dd51f1ec67094f214f (diff)
downloadqpid-python-a0a4fd7f3dafadcfd635c725de914367529fd7b3.tar.gz
QPID-3396 Modified the URLParser to not throw an exception if the
username and password is empty. Instead once a SASL mechanism is selected we check if that mechanism needs user/pass and then throw an exception at that point. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1453558 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java7
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java8
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java6
3 files changed, 16 insertions, 5 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
index 6b2448e385..ce6d9bdc50 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
@@ -27,6 +27,7 @@ import org.apache.qpid.util.FileUtils;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@@ -80,6 +81,8 @@ public class CallbackHandlerRegistry
/** Ordered collection of mechanisms for which callback handlers exist. */
private Collection<String> _mechanisms;
+ private static final Collection<String> MECHS_THAT_NEED_USERPASS = Arrays.asList(new String [] {"PLAIN", "AMQPLAIN", "CRAM-MD5","CRAM-MD5-HASHED"});
+
static
{
// Register any configured SASL client factories.
@@ -311,4 +314,8 @@ public class CallbackHandlerRegistry
return Collections.unmodifiableSet(mechanismSet);
}
+ public boolean isUserPassRequired(String selectedMech)
+ {
+ return MECHS_THAT_NEED_USERPASS.contains(selectedMech);
+ }
}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
index 4789dd0ed7..2775354acf 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
@@ -98,6 +98,14 @@ public class ClientConnectionDelegate extends ClientDelegate
" Client restricted itself to : " + (restrictionList != null ? restrictionList : "no restriction"));
}
+ if (CallbackHandlerRegistry.getInstance().isUserPassRequired(selectedMech))
+ {
+ throw new ConnectionException("Username and Password is required for the selected mechanism : " + selectedMech +
+ " Broker allows : " + brokerMechanisms +
+ " Client has : " + CallbackHandlerRegistry.getInstance().getMechanisms() +
+ " Client restricted itself to : " + (restrictionList != null ? restrictionList : "no restriction"));
+ }
+
Map<String,Object> saslProps = new HashMap<String,Object>();
if (getConnectionSettings().isUseSASLEncryption())
{
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
index 516ee8cf37..754b5ff6a7 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
@@ -106,11 +106,7 @@ public class URLParser
}
- if (userInfo == null)
- {
- throw URLHelper.parseError(AMQConnectionURL.AMQ_PROTOCOL.length() + 3, "User information not found on url", fullURL);
- }
- else
+ if (userInfo != null)
{
parseUserInfo(userInfo);
}