diff options
| author | Robert Greig <rgreig@apache.org> | 2007-01-29 10:46:27 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2007-01-29 10:46:27 +0000 |
| commit | 3b1d20656f0e881f6db4d4faaa9edf30b4e91f8b (patch) | |
| tree | 42a06502e9dbd465503d54950ea5ad9f0e798082 /qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs | |
| parent | ed51b35db62e3715e34d010728d9aa2c862b1a22 (diff) | |
| download | qpid-python-3b1d20656f0e881f6db4d4faaa9edf30b4e91f8b.tar.gz | |
(Patch supplied by Tomas Restrepo) QPID-291-2.diff applied. Adds SASL capability to the .Net client.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@501001 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs')
| -rw-r--r-- | qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs index 7c0fbd8f40..fe123e6745 100644 --- a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs @@ -21,6 +21,7 @@ using Qpid.Client.Protocol; using Qpid.Client.State; using Qpid.Framing; +using Qpid.Sasl; namespace Qpid.Client.Handler { @@ -28,9 +29,31 @@ namespace Qpid.Client.Handler { public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) { - AMQFrame response = ConnectionSecureOkBody.CreateAMQFrame(evt.ChannelId, null); - evt.ProtocolSession.WriteFrame(response); + ISaslClient saslClient = evt.ProtocolSession.SaslClient; + if ( saslClient == null ) + { + throw new AMQException("No SASL client set up - cannot proceed with authentication"); + } + + + ConnectionSecureBody body = (ConnectionSecureBody)evt.Method; + + try + { + // Evaluate server challenge + byte[] response = saslClient.EvaluateChallenge(body.Challenge); + // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) + // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. + // Be aware of possible changes to parameter order as versions change. + AMQFrame responseFrame = ConnectionSecureOkBody.CreateAMQFrame( + evt.ChannelId, response); + evt.ProtocolSession.WriteFrame(responseFrame); + } catch ( SaslException e ) + { + throw new AMQException("Error processing SASL challenge: " + e, e); + } } } } + |
