c# wrapper updates, etc.

This commit is contained in:
Jim Norman 2006-08-18 17:41:08 +00:00
parent 169e3a389d
commit 2ec99203a2
7 changed files with 98 additions and 93 deletions

View File

@ -28,7 +28,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Novell.Casa.Client", "clien
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClientAuth", "TestClientAuth\TestClientAuth.csproj", "{0EA635EA-97F2-4950-B36B-8151ED858DA4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClientAuth", "client\csharp\test\TestClientAuth.csproj", "{0EA635EA-97F2-4950-B36B-8151ED858DA4}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject

View File

@ -40,6 +40,12 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_313DE095D13281AF91A64E3F3D472413" "MsmKey" = "8:_313DE095D13281AF91A64E3F3D472413"
"OwnerKey" = "8:_409269C4EABE4CC18045A808B7B1C104"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_313DE095D13281AF91A64E3F3D472413"
"OwnerKey" = "8:_9A2FC85FE99C48E8AD1E4813BE33A03A" "OwnerKey" = "8:_9A2FC85FE99C48E8AD1E4813BE33A03A"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
@ -57,14 +63,14 @@
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A" "MsmKey" = "8:_7A0B81639B6D4DB1839306A9290BDE2D"
"OwnerKey" = "8:_0C0B5ECE6E9C47F1A1F13B58141B5DC8" "OwnerKey" = "8:_8292EFFD84EF46C6BD2F1F3E20808684"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A" "MsmKey" = "8:_8292EFFD84EF46C6BD2F1F3E20808684"
"OwnerKey" = "8:_409269C4EABE4CC18045A808B7B1C104" "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
@ -73,12 +79,6 @@
"OwnerKey" = "8:_UNDEFINED" "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry"
{
"MsmKey" = "8:_FE85A5D48B5A23F3077871E9FD2378DE"
"OwnerKey" = "8:_0C0B5ECE6E9C47F1A1F13B58141B5DC8"
"MsmSig" = "8:_UNDEFINED"
}
} }
"Configurations" "Configurations"
{ {
@ -228,52 +228,23 @@
"IsDependency" = "11:FALSE" "IsDependency" = "11:FALSE"
"IsolateTo" = "8:" "IsolateTo" = "8:"
} }
"{A582A373-4685-4296-BEFE-614B80A702C3}:_71C343EBC4935F8914C3145115EDEC4A"
{
"SourcePath" = "8:micasa.dll"
"TargetName" = "8:micasa.dll"
"Tag" = "8:"
"Folder" = "8:_01897726E7804A3B875B67A1C2692147"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:TRUE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{A582A373-4685-4296-BEFE-614B80A702C3}:_FE85A5D48B5A23F3077871E9FD2378DE"
{
"SourcePath" = "8:WINHTTP.dll"
"TargetName" = "8:WINHTTP.dll"
"Tag" = "8:"
"Folder" = "8:_01897726E7804A3B875B67A1C2692147"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:TRUE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
} }
"FileType" "FileType"
{ {
} }
"Folder" "Folder"
{ {
"{B4CE2BB7-2D9F-4E14-A952-99DFEBF520A8}:_8E0BBDD021EA45308BD98380F28EB7F6"
{
"Name" = "8:#1927"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:GAC"
"Folders"
{
}
}
"{78BAF5CE-F2E5-45BE-83BC-DB6AF387E941}:_DB481DA18FE347988F44E459AD84EDE9" "{78BAF5CE-F2E5-45BE-83BC-DB6AF387E941}:_DB481DA18FE347988F44E459AD84EDE9"
{ {
"Name" = "8:#1912" "Name" = "8:#1912"
@ -382,6 +353,17 @@
} }
"MergeModule" "MergeModule"
{ {
"{35A69C6E-5BA4-440D-803D-762B59A45393}:_7A0B81639B6D4DB1839306A9290BDE2D"
{
"UseDynamicProperties" = "11:FALSE"
"IsDependency" = "11:TRUE"
"SourcePath" = "8:dotnetfxredist_x86.msm"
"LanguageId" = "3:1033"
"Exclude" = "11:FALSE"
"Folder" = "8:"
"Feature" = "8:"
"IsolateTo" = "8:"
}
} }
"Module" "Module"
{ {
@ -399,7 +381,7 @@
{ {
"{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_0C0B5ECE6E9C47F1A1F13B58141B5DC8" "{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_0C0B5ECE6E9C47F1A1F13B58141B5DC8"
{ {
"SourcePath" = "8:..\\windows\\debug\\authtoken.dll" "SourcePath" = "8:..\\windows\\Debug\\authtoken.dll"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_01897726E7804A3B875B67A1C2692147" "Folder" = "8:_01897726E7804A3B875B67A1C2692147"
@ -427,7 +409,7 @@
} }
"{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_409269C4EABE4CC18045A808B7B1C104" "{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_409269C4EABE4CC18045A808B7B1C104"
{ {
"SourcePath" = "8:..\\mechanisms\\pwd\\windows\\Debug\\pwmech.dll" "SourcePath" = "8:..\\mechanisms\\krb5\\windows\\Debug\\krb5mech.dll"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_F5F5F604B81645F8B6463F7A7D6A53AD" "Folder" = "8:_F5F5F604B81645F8B6463F7A7D6A53AD"
@ -453,9 +435,37 @@
{ {
} }
} }
"{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_8292EFFD84EF46C6BD2F1F3E20808684"
{
"SourcePath" = "8:..\\csharp\\Novell.Casa.Authtoken\\obj\\Debug\\Novell.Casa.Client.Auth.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_8E0BBDD021EA45308BD98380F28EB7F6"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
"ProjectOutputGroupRegister" = "3:1"
"OutputConfiguration" = "8:"
"OutputGroupCanonicalName" = "8:Built"
"OutputProjectGuid" = "8:{1BA1FC97-5AF1-4506-A7FD-EBFD46D361A0}"
"ShowKeyOutput" = "11:TRUE"
"ExcludeFilters"
{
}
}
"{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_9A2FC85FE99C48E8AD1E4813BE33A03A" "{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_9A2FC85FE99C48E8AD1E4813BE33A03A"
{ {
"SourcePath" = "8:..\\mechanisms\\krb5\\windows\\debug\\krb5mech.dll" "SourcePath" = "8:..\\mechanisms\\krb5\\windows\\Debug\\krb5mech.dll"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_F5F5F604B81645F8B6463F7A7D6A53AD" "Folder" = "8:_F5F5F604B81645F8B6463F7A7D6A53AD"

View File

@ -6,15 +6,14 @@ using System.Runtime.CompilerServices;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
// //
[assembly: AssemblyTitle("")] [assembly: AssemblyTitle("AuthToken Wrapper")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("C# Wrapper for Authentication Tokens")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Novell, Inc")]
[assembly: AssemblyProduct("")] [assembly: AssemblyProduct("CASA")]
[assembly: AssemblyCopyright("")] [assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// //
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
@ -26,7 +25,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.7.*")]
// //
// In order to sign your assembly you must specify a key to use. Refer to the // In order to sign your assembly you must specify a key to use. Refer to the
@ -54,5 +53,5 @@ using System.Runtime.CompilerServices;
// documentation for more information on this. // documentation for more information on this.
// //
[assembly: AssemblyDelaySign(false)] [assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyFile("../../AuthToken.snk")]
[assembly: AssemblyKeyName("")] [assembly: AssemblyKeyName("")]

View File

@ -10,13 +10,14 @@ namespace Novell.Casa.Client.Auth
public class Authtoken public class Authtoken
{ {
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken"; private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
private const int BUFFER_OVERFLOW = 6;
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ] [DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
public static extern int ObtainAuthToken public static extern int ObtainAuthToken
( (
[In] byte[] baService, [In] byte[] baService,
[In] byte[] baHost, [In] byte[] baHost,
IntPtr pToken, [In, Out] byte[] baToken,
[In, Out] ref int iTokenLength [In, Out] ref int iTokenLength
); );
@ -24,9 +25,6 @@ namespace Novell.Casa.Client.Auth
public Authtoken() public Authtoken()
{ {
//
// TODO: Add constructor logic here
//
} }
@ -35,9 +33,7 @@ namespace Novell.Casa.Client.Auth
int rcode = 0; int rcode = 0;
byte[] baService = null; byte[] baService = null;
byte[] baHost = null; byte[] baHost = null;
int bufferSize = 0;
int bufferSize = 4096;
IntPtr pBuffer = Marshal.AllocHGlobal(bufferSize);
byte[] baToken = new byte[bufferSize]; byte[] baToken = new byte[bufferSize];
@ -56,45 +52,45 @@ namespace Novell.Casa.Client.Auth
{ {
baHost = Encoding.ASCII.GetBytes(sHost); baHost = Encoding.ASCII.GetBytes(sHost);
} }
else
{
throw new Exception("Invalid parameter");
}
LogMessage("Calling Native API->ObtainAuthToken");
LogMessage("Buffer size is "+ bufferSize);
// call with buffersize of 0. This way we determine the exact size.
try try
{ {
rcode = ObtainAuthToken(baService, baHost, pBuffer, ref bufferSize); rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
int test = (rcode & BUFFER_OVERFLOW);
if (test == BUFFER_OVERFLOW)
{
// now allocate the proper size
baToken = new byte[bufferSize];
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
}
} }
catch (Exception e) catch (Exception e)
{ {
LogMessage(e.ToString()); LogMessage(e.ToString());
return null;
} }
LogMessage("ObtainAuthToken returned " + rcode);
if (rcode != 0) if (rcode != 0)
{ {
Marshal.FreeHGlobal(pBuffer);
throw new Exception(rcode.ToString()); throw new Exception(rcode.ToString());
} }
else else
{ {
// marshal the IntPtr into a byte array return baToken;
String sTemp = Marshal.PtrToStringAnsi(pBuffer, bufferSize);
Marshal.FreeHGlobal(pBuffer);
return (Encoding.ASCII.GetBytes(sTemp));
} }
return null;
} }
private static void LogMessage(string sMessage) private static void LogMessage(string sMessage)
{ {
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage); System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
} }
} }
} }

View File

@ -76,7 +76,7 @@
/> />
<Reference <Reference
Name = "System.XML" Name = "System.XML"
AssemblyName = "System.XML" AssemblyName = "System.Xml"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/> />
</References> </References>

View File

@ -25,7 +25,7 @@ namespace TestClientAuth
try try
{ {
byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]); byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]);
Console.WriteLine("Token returned:"); Console.WriteLine("Token returned: ("+ baToken.Length + ")");
for (int i=0; i<baToken.Length; i++) for (int i=0; i<baToken.Length; i++)
{ {
Console.Write(baToken[i].ToString()); Console.Write(baToken[i].ToString());