diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-01-12 23:14:11 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-01-12 23:14:11 +0000 |
| commit | 65489bc8e42a1c4136c6bd218d4ae673b53a1241 (patch) | |
| tree | 3e7bccbe58119a63f18cc11cb75192670aabb591 /java/common/src | |
| parent | 0c3fff4ec5b4d28c59e8579236f16c1527e5d1c4 (diff) | |
| download | qpid-python-65489bc8e42a1c4136c6bd218d4ae673b53a1241.tar.gz | |
This is a fix for QPID-2339
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@898570 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java index 2f15ba1f15..8828d30f52 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java +++ b/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java @@ -24,6 +24,8 @@ import static org.apache.qpid.transport.Connection.State.OPEN; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -62,7 +64,7 @@ public class ClientDelegate extends ConnectionDelegate private String vhost; private String username; private String password; - private String[] saslMechs; + private List<String> clientMechs; private String protocol; private String serverName; @@ -71,7 +73,7 @@ public class ClientDelegate extends ConnectionDelegate this.vhost = vhost; this.username = username; this.password = password; - this.saslMechs = saslMechs.split(" "); + this.clientMechs = Arrays.asList(saslMechs.split(" ")); // Looks kinda of silly but the Sun SASL Kerberos client uses the // protocol + servername as the service key. @@ -96,24 +98,41 @@ public class ClientDelegate extends ConnectionDelegate clientProperties.put("qpid.client_process", System.getProperty("qpid.client_process","Qpid Java Client")); - List<Object> mechanisms = start.getMechanisms(); - if (mechanisms == null || mechanisms.isEmpty()) + List<Object> brokerMechs = start.getMechanisms(); + if (brokerMechs == null || brokerMechs.isEmpty()) { conn.connectionStartOk (clientProperties, null, null, conn.getLocale()); return; } - - String[] mechs = new String[mechanisms.size()]; - mechanisms.toArray(mechs); - + + List<String> choosenMechs = new ArrayList<String>(); + for (String mech:clientMechs) + { + if (brokerMechs.contains(mech)) + { + choosenMechs.add(mech); + } + } + + if (choosenMechs.size() == 0) + { + conn.exception(new ConnectionException("The following SASL mechanisms " + + clientMechs.toString() + + " specified by the client are not supported by the broker")); + return; + } + + String[] mechs = new String[choosenMechs.size()]; + choosenMechs.toArray(mechs); + try { UsernamePasswordCallbackHandler handler = new UsernamePasswordCallbackHandler(); handler.initialise(username, password); SaslClient sc = Sasl.createSaslClient - (saslMechs, null, protocol, serverName, null, handler); + (mechs, null, protocol, serverName, null, handler); conn.setSaslClient(sc); byte[] response = sc.hasInitialResponse() ? |
