diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2009-02-09 05:14:09 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2009-02-09 05:14:09 +0000 |
| commit | e7a74d891cfb6e508535eea0caccd33c7b8a4900 (patch) | |
| tree | 079ab7edf17df6abe6f4a486483ee28c257dc5fb /java/common | |
| parent | 03d86bcbab8e6c3ec4bcc99d83febf989892f732 (diff) | |
| download | qpid-python-e7a74d891cfb6e508535eea0caccd33c7b8a4900.tar.gz | |
This is related to QPID-1645
Added support to specify the sasl_mechs as a space separated list in the connection URL.
By default it will use PLAIN.
You could provide a list of mechs to support or force to use one GASSAPI or CRAM-MD5 by specifying only that in the connection URL.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@742267 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java | 15 | ||||
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/transport/Connection.java | 9 |
2 files changed, 19 insertions, 5 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 993da168a9..359dfc8c11 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 @@ -46,12 +46,21 @@ public class ClientDelegate extends ConnectionDelegate private String vhost; private String username; private String password; - - public ClientDelegate(String vhost, String username, String password) + private String[] saslMechs; + private String protocol; + private String serverName; + + public ClientDelegate(String vhost, String username, String password,String saslMechs) { this.vhost = vhost; this.username = username; this.password = password; + this.saslMechs = saslMechs.split(" "); + + // Looks kinda of silly but the Sun SASL Kerberos client uses the + // protocol + servername as the service key. + this.protocol = System.getProperty("qpid.sasl_protocol","AMQP"); + this.serverName = System.getProperty("qpid.sasl_server_name","localhost"); } public void init(Connection conn, ProtocolHeader hdr) @@ -84,7 +93,7 @@ public class ClientDelegate extends ConnectionDelegate new UsernamePasswordCallbackHandler(); handler.initialise(username, password); SaslClient sc = Sasl.createSaslClient - (new String[] {"PLAIN"}, null, "AMQP", "localhost", null, handler); + (saslMechs, null, protocol, serverName, null, handler); conn.setSaslClient(sc); byte[] response = sc.hasInitialResponse() ? diff --git a/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 2f7e1490ab..adaf2ccd37 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -161,14 +161,19 @@ public class Connection extends ConnectionInvoker { connect(host, port, vhost, username, password, false); } - + public void connect(String host, int port, String vhost, String username, String password, boolean ssl) { + connect(host, port, vhost, username, password, false,"PLAIN"); + } + + public void connect(String host, int port, String vhost, String username, String password, boolean ssl,String saslMechs) + { synchronized (lock) { state = OPENING; - delegate = new ClientDelegate(vhost, username, password); + delegate = new ClientDelegate(vhost, username, password,saslMechs); IoTransport.connect(host, port, ConnectionBinding.get(this), ssl); send(new ProtocolHeader(1, 0, 10)); |
