diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2013-03-06 21:04:39 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2013-03-06 21:04:39 +0000 |
| commit | 1335e9b25d34601e9ee6cc462c02b3bef885263e (patch) | |
| tree | 19d017d5c932fad073f2c596f25d4524466cbbd1 /java | |
| parent | 80a5577c4cd0b607d7ab787bcf8660c659e5b176 (diff) | |
| download | qpid-python-1335e9b25d34601e9ee6cc462c02b3bef885263e.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/qpid@1453558 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
3 files changed, 16 insertions, 5 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java b/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java index 6b2448e385..ce6d9bdc50 100644 --- a/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java +++ b/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/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java b/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java index 4789dd0ed7..2775354acf 100644 --- a/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java +++ b/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/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java b/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java index 516ee8cf37..754b5ff6a7 100644 --- a/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java +++ b/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); } |
