The sample also depends on a hashing helper that signs and validates the header values.
That code is not in the MSI - but the sample code is instead shown below. You can create a project that outputs a DLL called "HashingHelper.dll". For it to be callable from Classic ASP, you will need to run "gacutil -i" to install the assembly in the GAC and
you will also need to use "regasm" to register the class in the assembly with COM.
HashHelper.cs: using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace HashingHelper
{
public class HashHelper
{
private static string hashKey =
"You need to supply a valid 128 character long hex key here";
public static byte[] ConvertStringKeyToByteArray(string stringizedKeyValue)
{
byte[] keyBuffer = new byte[64];
for (int i = 0; i < hashKey.Length; i = i + 2)
{
keyBuffer[i / 2] = Byte.Parse(hashKey.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
}
return keyBuffer;
}
public static string ConvertByteArrayToString(byte[] value)
{
StringBuilder sb = new StringBuilder(128);
foreach (byte b in value)
{
int i = (int)b;
sb.Append(i.ToString("X2"));
}
return sb.ToString();
}
public static string HashStringValue(string valueToHash)
{
using (HMACSHA1 hms = new HMACSHA1(bKey))
{
return ConvertByteArrayToString(hms.ComputeHash(Encoding.Unicode.GetBytes(valueToHash)));
}
}
public static bool ValidateHash(string value, string hash)
{
using (HMACSHA1 hms = new HMACSHA1(bKey))
{
if (HashStringValue(value) != hash)
return false;
else
return true;
}
}
using System.Reflection;
using System.Security;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HashingHelper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Me")]
[assembly: AssemblyProduct("HashingHelper")]
[assembly: AssemblyCopyright("Copyright Me")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("09f8b521-ad1b-4545-94e6-51e94d89a2ac")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AllowPartiallyTrustedCallers()]
-Stefan
----------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Member
80 Points
616 Posts
Download info for using ASP.NET 2.0 authentication with a Classic ASP site
Jun 20, 2005 04:09 PM|sschack|LINK
The sample ASP.NET/ASP site with the custom Http handler is available for download at:
http://download.microsoft.com/download/9/C/D/9CD0A246-5F89-4854-B4B6-CAE0D3F386BE/WEB343.msi
The sample also depends on a hashing helper that signs and validates the header values.
That code is not in the MSI - but the sample code is instead shown below. You can create a project that outputs a DLL called "HashingHelper.dll". For it to be callable from Classic ASP, you will need to run "gacutil -i" to install the assembly in the GAC and you will also need to use "regasm" to register the class in the assembly with COM.
HashHelper.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace HashingHelper
{
public class HashHelper
{
private static string hashKey =
"You need to supply a valid 128 character long hex key here";
private static byte[] bKey;
static HashHelper()
{
bKey = ConvertStringKeyToByteArray(hashKey);
}
public static byte[] ConvertStringKeyToByteArray(string stringizedKeyValue)
{
byte[] keyBuffer = new byte[64];
for (int i = 0; i < hashKey.Length; i = i + 2)
{
keyBuffer[i / 2] = Byte.Parse(hashKey.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
}
return keyBuffer;
}
public static string ConvertByteArrayToString(byte[] value)
{
StringBuilder sb = new StringBuilder(128);
foreach (byte b in value)
{
int i = (int)b;
sb.Append(i.ToString("X2"));
}
return sb.ToString();
}
public static string HashStringValue(string valueToHash)
{
using (HMACSHA1 hms = new HMACSHA1(bKey))
{
return ConvertByteArrayToString(hms.ComputeHash(Encoding.Unicode.GetBytes(valueToHash)));
}
}
public static bool ValidateHash(string value, string hash)
{
using (HMACSHA1 hms = new HMACSHA1(bKey))
{
if (HashStringValue(value) != hash)
return false;
else
return true;
}
}
#region COM support
public HashHelper() { }
public bool ValidateHashCOM(string value, string hash)
{
return HashHelper.ValidateHash(value, hash);
}
#endregion
}
}
AssemblyInfo.cs:
using System.Reflection;
using System.Security;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HashingHelper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Me")]
[assembly: AssemblyProduct("HashingHelper")]
[assembly: AssemblyCopyright("Copyright Me")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("09f8b521-ad1b-4545-94e6-51e94d89a2ac")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AllowPartiallyTrustedCallers()]
----------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.