Author: ritchiem
Date: Fri Jun  6 09:03:42 2008
New Revision: 663999

URL: http://svn.apache.org/viewvc?rev=663999&view=rev
Log:
QPID-1058 : Added new CramMD5HexSaslClient.cs and registered it in the Sasl 
Factory and the client CallbackHandler

Added:
    
incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj
   (with props)
    
incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
Modified:
    incubator/qpid/branches/M2.x/dotnet/   (props changed)
    
incubator/qpid/branches/M2.x/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
    incubator/qpid/branches/M2.x/dotnet/Qpid.NET.sln
    incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Callbacks.cs
    incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/DefaultClientFactory.cs
    incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Qpid.Sasl.csproj

Propchange: incubator/qpid/branches/M2.x/dotnet/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jun  6 09:03:42 2008
@@ -5,3 +5,4 @@
 Qpid.NET.resharper
 Qpid.NET.resharper.user
 Qpid.NET.suo
+bin

Modified: 
incubator/qpid/branches/M2.x/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs?rev=663999&r1=663998&r2=663999&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.x/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
 (original)
+++ 
incubator/qpid/branches/M2.x/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
 Fri Jun  6 09:03:42 2008
@@ -96,6 +96,8 @@
             _mechanism2HandlerMap.Add(ExternalSaslClient.Mechanism, 
typeof(UsernamePasswordCallbackHandler));
          if ( !_mechanism2HandlerMap.Contains(CramMD5SaslClient.Mechanism) )
             _mechanism2HandlerMap.Add(CramMD5SaslClient.Mechanism, 
typeof(UsernamePasswordCallbackHandler));
+         if ( !_mechanism2HandlerMap.Contains(CramMD5HexSaslClient.Mechanism) )
+            _mechanism2HandlerMap.Add(CramMD5HexSaslClient.Mechanism, 
typeof(UsernamePasswordCallbackHandler));
          if ( !_mechanism2HandlerMap.Contains(PlainSaslClient.Mechanism) )
             _mechanism2HandlerMap.Add(PlainSaslClient.Mechanism, 
typeof(UsernamePasswordCallbackHandler));
 

Added: 
incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj?rev=663999&view=auto
==============================================================================
--- 
incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj
 (added)
+++ 
incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj
 Fri Jun  6 09:03:42 2008
@@ -0,0 +1,65 @@
+<Project DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
+  <PropertyGroup>
+    <ProjectGuid>{DE21CEBC-F38C-43EA-B576-38CA9738A00A}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Qpid.Integration.Tests</RootNamespace>
+    <AssemblyName>Qpid.Integration.Tests</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <OutputPath>bin\Debug\</OutputPath>
+    <DebugSymbols>True</DebugSymbols>
+    <DebugType>Full</DebugType>
+    <Optimize>False</Optimize>
+    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <OutputPath>bin\Release\</OutputPath>
+    <DebugSymbols>False</DebugSymbols>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="framework\Circuit.cs" />
+    <Compile Include="framework\FrameworkBaseCase.cs" />
+    <Compile Include="framework\Publisher.cs" />
+    <Compile Include="framework\Receiver.cs" />
+    <Compile Include="framework\TestClientDetails.cs" />
+    <Compile Include="framework\TestModel.cs" />
+    <Compile Include="interactive\SendReceiveTest.cs" />
+    <Compile Include="interop\InteropClientTestCase.cs" />
+    <Compile Include="interop\TestCases\TestCase1DummyRun.cs" />
+    <Compile Include="interop\TestCases\TestCase3BasicPubSub.cs" />
+    <Compile Include="testcases\BaseMessagingTestFixture.cs" />
+    <Compile Include="testcases\ChannelQueueTest.cs" />
+    <Compile Include="testcases\CommitRollbackTest.cs" />
+    <Compile Include="testcases\ConnectionTest.cs" />
+    <Compile Include="testcases\DurableSubscriptionTest.cs" />
+    <Compile Include="testcases\HeadersExchangeTest.cs" />
+    <Compile Include="testcases\MandatoryMessageTest.cs" />
+    <Compile Include="testcases\ProducerMultiConsumerTest.cs" />
+    <Compile Include="testcases\SslConnectionTest.cs" />
+    <Compile Include="testcases\SustainedTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="framework\Assertion.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="interactive\FailoverTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="interop\TestClient.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="interop\TestCases\TestCase2BasicP2P.cs" />
+  </ItemGroup>
+</Project>
\ No newline at end of file

Propchange: 
incubator/qpid/branches/M2.x/dotnet/Qpid.Integration.Tests/Qpid.Integration.Tests.csproj
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Modified: incubator/qpid/branches/M2.x/dotnet/Qpid.NET.sln
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.NET.sln?rev=663999&r1=663998&r2=663999&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/dotnet/Qpid.NET.sln (original)
+++ incubator/qpid/branches/M2.x/dotnet/Qpid.NET.sln Fri Jun  6 09:03:42 2008
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
+Microsoft Visual Studio Solution File, Format Version 9.00
 # Visual Studio 2005
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qpid.Messaging", 
"Qpid.Messaging\Qpid.Messaging.csproj", "{6688F826-C58E-4C1B-AA1F-22AFAB4B7D07}"
 EndProject
@@ -26,6 +26,8 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", 
"TestClient\TestClient.csproj", "{9A112DF2-146F-4CF4-919B-9D3BE7D088E9}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qpid.Integration.Tests", 
"Qpid.Integration.Tests\Qpid.Integration.Tests.csproj", 
"{DE21CEBC-F38C-43EA-B576-38CA9738A00A}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -80,6 +82,14 @@
                {9A112DF2-146F-4CF4-919B-9D3BE7D088E9}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
                {9A112DF2-146F-4CF4-919B-9D3BE7D088E9}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
                {9A112DF2-146F-4CF4-919B-9D3BE7D088E9}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {666C2D04-C9DC-4D43-B4DF-0989225EABC3}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {666C2D04-C9DC-4D43-B4DF-0989225EABC3}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {666C2D04-C9DC-4D43-B4DF-0989225EABC3}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {666C2D04-C9DC-4D43-B4DF-0989225EABC3}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {DE21CEBC-F38C-43EA-B576-38CA9738A00A}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {DE21CEBC-F38C-43EA-B576-38CA9738A00A}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {DE21CEBC-F38C-43EA-B576-38CA9738A00A}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {DE21CEBC-F38C-43EA-B576-38CA9738A00A}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE

Modified: incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Callbacks.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Callbacks.cs?rev=663999&r1=663998&r2=663999&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Callbacks.cs (original)
+++ incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Callbacks.cs Fri Jun  6 
09:03:42 2008
@@ -21,6 +21,8 @@
 
 using System;
 using System.Text;
+using System.Globalization;
+using System.Security.Cryptography;
 
 namespace Apache.Qpid.Sasl
 {
@@ -87,6 +89,37 @@
          : base("password:", "", "")
       {
       }
+
+      public byte[] HashedText
+      {
+          get
+          {
+            string _text = this.Text;
+            System.Security.Cryptography.MD5CryptoServiceProvider x = new 
System.Security.Cryptography.MD5CryptoServiceProvider();
+            byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
+            return bs;
+          }
+
+      }
+   } // class PasswordCallback
+
+   public class HashedPasswordCallback : TextSaslCallback
+   {
+       public HashedPasswordCallback()
+           : base("password:", "", "")
+       {
+       }
+
+       public byte[] HashedText
+       {
+        get {
+               string _text = this.Text;
+               System.Security.Cryptography.MD5CryptoServiceProvider x = new 
System.Security.Cryptography.MD5CryptoServiceProvider();
+               _text = _text.PadRight(16, '\0');
+               byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
+               return bs;
+        }
+       }
    } // class PasswordCallback
 
    public class RealmCallback : TextSaslCallback

Modified: incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/DefaultClientFactory.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/DefaultClientFactory.cs?rev=663999&r1=663998&r2=663999&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/DefaultClientFactory.cs 
(original)
+++ incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/DefaultClientFactory.cs Fri 
Jun  6 09:03:42 2008
@@ -31,6 +31,7 @@
       private static readonly string[] SUPPORTED = new string[] {
                DigestSaslClient.Mechanism,
                CramMD5SaslClient.Mechanism,
+               CramMD5HexSaslClient.Mechanism,
                PlainSaslClient.Mechanism, 
                AnonymousSaslClient.Mechanism,
                ExternalSaslClient.Mechanism,
@@ -50,6 +51,7 @@
              props.Contains(SaslProperties.PolicyPassCredentials) )
          {
             vetoed.Add(CramMD5SaslClient.Mechanism);
+            vetoed.Add(CramMD5HexSaslClient.Mechanism);
             vetoed.Add(PlainSaslClient.Mechanism);
             vetoed.Add(AnonymousSaslClient.Mechanism);
             vetoed.Add(ExternalSaslClient.Mechanism);
@@ -81,6 +83,8 @@
             return new DigestSaslClient(authorizationId, serverName, protocol, 
props, handler);
          if ( mechs.Contains(CramMD5SaslClient.Mechanism) )
             return new CramMD5SaslClient(authorizationId, props, handler);
+         if ( mechs.Contains(CramMD5HexSaslClient.Mechanism) )
+            return new CramMD5HexSaslClient(authorizationId, props, handler);
          if ( mechs.Contains(PlainSaslClient.Mechanism) )
             return new PlainSaslClient(authorizationId, props, handler);
          if ( mechs.Contains(AnonymousSaslClient.Mechanism) )

Added: 
incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs?rev=663999&view=auto
==============================================================================
--- 
incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
 (added)
+++ 
incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
 Fri Jun  6 09:03:42 2008
@@ -0,0 +1,96 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+   /// <summary>
+   /// Implements the CRAM-MD5 authentication mechanism as outlined
+   /// in RFC 2195
+   /// </summary>
+   public class CramMD5HexSaslClient : SaslClient
+   {
+      public const string Mechanism = "CRAM-MD5-HEX";
+      private const int MinPwdLen = 16;
+
+      public CramMD5HexSaslClient(
+         string authorizationId, 
+         IDictionary properties, 
+         ISaslCallbackHandler handler)
+         : base(authorizationId, null, null, properties, handler)
+      {
+      }
+
+      #region ISaslClient Implementation
+      //
+      // ISaslClient Implementation
+      //
+
+      public override string MechanismName
+      {
+         get { return Mechanism; }
+      }
+
+      public override bool HasInitialResponse
+      {
+         get { return false; }
+      }
+      
+      
+      public override byte[] EvaluateChallenge(byte[] challenge)
+      {
+        if ( challenge == null || challenge.Length == 0 )
+            throw new ArgumentNullException("challenge");
+
+
+        NameCallback nameCB = new NameCallback(AuthorizationId);
+        PasswordCallback pwdCB = new PasswordCallback();
+        ISaslCallback[] callbacks = { nameCB, pwdCB };
+        Handler.Handle(callbacks);
+
+        string username = nameCB.Text;
+        
+        //Encode the Hashed Password as Hex
+        byte[] passwd = Encoding.UTF8.GetBytes(ToHex(pwdCB.HashedText));
+
+        string s = System.Text.UTF8Encoding.UTF8.GetString(challenge);
+        
+        Console.WriteLine("Connection Username = " + username + ", Challenge = 
" + s + " Secret length - " + passwd.Length + ", Hashed secret - " + 
ToHex(pwdCB.HashedText));
+
+        using ( HMAC hmac = new HMACMD5(passwd) )
+         {
+            byte[] value = hmac.ComputeHash(challenge);
+            string encoded = ToHex(value);
+            SetComplete();
+            Console.WriteLine(username + " " + encoded);
+            return Encoding.UTF8.GetBytes(username + " " + encoded);
+         }
+      }
+
+      #endregion // ISaslClient Implementation
+
+   } // class CramMD5HashedSaslClient
+
+} // namespace Apache.Qpid.Sasl.Mechanisms

Modified: incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Qpid.Sasl.csproj
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Qpid.Sasl.csproj?rev=663999&r1=663998&r2=663999&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Qpid.Sasl.csproj (original)
+++ incubator/qpid/branches/M2.x/dotnet/Qpid.Sasl/Qpid.Sasl.csproj Fri Jun  6 
09:03:42 2008
@@ -38,6 +38,7 @@
     <Compile Include="Configuration\SaslConfiguration.cs" />
     <Compile Include="Configuration\SaslConfigurationSectionHandler.cs" />
     <Compile Include="MD5HMAC.cs" />
+    <Compile Include="Mechanisms\CramMD5HexSaslClient.cs" />
     <Compile Include="Mechanisms\ExternalSaslClient.cs" />
     <Compile Include="SaslException.cs" />
     <Compile Include="Mechanisms\AnonymousSaslClient.cs" />
@@ -61,4 +62,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file


Reply via email to