You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2013/03/06 22:04:39 UTC

svn commit: r1453558 - in /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client: security/CallbackHandlerRegistry.java transport/ClientConnectionDelegate.java url/URLParser.java

Author: rajith
Date: Wed Mar  6 21:04:39 2013
New Revision: 1453558

URL: http://svn.apache.org/r1453558
Log:
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.

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java?rev=1453558&r1=1453557&r2=1453558&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java Wed Mar  6 21:04:39 2013
@@ -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);
+    }
 }

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java?rev=1453558&r1=1453557&r2=1453558&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java Wed Mar  6 21:04:39 2013
@@ -98,6 +98,14 @@ public class ClientConnectionDelegate ex
                     " 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())
         {

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java?rev=1453558&r1=1453557&r2=1453558&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java Wed Mar  6 21:04:39 2013
@@ -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);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org