Separated the non-java project into client and server projects

in order to better support distributions that target desktops.
This commit completes the client project setup.
This commit is contained in:
Juan Carlos Luciani
2006-11-13 06:32:58 +00:00
parent 6ff1180a82
commit 55304c2836
93 changed files with 28 additions and 98 deletions

View File

@@ -0,0 +1,57 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 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("AuthToken Wrapper")]
[assembly: AssemblyDescription("C# Wrapper for Authentication Tokens")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Novell, Inc")]
[assembly: AssemblyProduct("CASA")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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.7.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("../../AuthToken.snk")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,176 @@
/***********************************************************************
*
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Jim Norman
*
***********************************************************************/
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Novell.Casa.Client.Auth
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Authtoken
{
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
private const int BUFFER_OVERFLOW = 6;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct LUID
{
public int luidLow;
public int luidHigh;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class SSCS_EXT_T
{
public int extID = 0; // defined to identify the extension
public int version = 0; // defined as the version of the specified extension
public IntPtr ext; // points to the actual extension
} ;
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
private static extern int ObtainAuthToken
(
[In] byte[] baService,
[In] byte[] baHost,
[In, Out] byte[] baToken,
[In, Out] ref int iTokenLength
);
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
private static extern int ObtainAuthTokenEx
(
[In] byte[] baService,
[In] byte[] baHost,
[In, Out] byte[] baToken,
[In, Out] ref int iTokenLength,
[In] SSCS_EXT_T ext
);
public Authtoken()
{
}
public static byte[] ObtainAuthToken(string sService, string sHost)
{
return ObtainAuthToken(sService, sHost, null);
}
public static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
{
int rcode = 0;
byte[] baService = null;
byte[] baHost = null;
int bufferSize = 0;
bool bLuidPassedIn = false;
byte[] baToken = new byte[bufferSize];
// convert service to ascii byte array
if (sService != null)
{
baService = Encoding.ASCII.GetBytes(sService);
}
else
{
throw new Exception("Invalid parameter");
}
// convert host to ascii byte array
if (sHost != null)
{
baHost = Encoding.ASCII.GetBytes(sHost);
}
else
{
throw new Exception("Invalid parameter");
}
SSCS_EXT_T ext = new SSCS_EXT_T();
if ((luid.GetHighPart() != 0) || (luid.GetLowPart() != 0))
{
// allocate a structure to marshal
LUID sluid = new LUID();
sluid.luidHigh = luid.GetHighPart();
sluid.luidLow = luid.GetLowPart();
ext.extID = 1;
ext.version = 1;
ext.ext = Marshal.AllocHGlobal(Marshal.SizeOf(sluid));
Marshal.StructureToPtr(sluid, ext.ext, false);
bLuidPassedIn = true;
}
// call with buffersize of 0. This way we determine the exact size.
try
{
if (bLuidPassedIn)
{
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
}
else
{
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)
{
LogMessage(e.ToString());
return null;
}
if (ext.ext != IntPtr.Zero)
Marshal.FreeHGlobal(ext.ext);
if (rcode != 0)
{
throw new Exception(rcode.ToString());
}
else
{
return baToken;
}
}
private static void LogMessage(string sMessage)
{
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
}
}
}

View File

@@ -0,0 +1,105 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{1BA1FC97-5AF1-4506-A7FD-EBFD46D361A0}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "Novell.Casa.Client.Auth"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "Novell.Casa.Client.Auth"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Authtoken.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "WinLuid.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,29 @@
using System;
namespace Novell.Casa.Client.Auth
{
/// <summary>
/// Summary description for WinLuid.
/// </summary>
public class WinLuid
{
private int m_low = 0;
private int m_high = 0;
public WinLuid(int lowPart, int highPart )
{
m_low = lowPart;
m_high = highPart;
}
public int GetLowPart()
{
return m_low;
}
public int GetHighPart()
{
return m_high;
}
}
}

View File

@@ -0,0 +1,68 @@
/***********************************************************************
*
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
*
***********************************************************************/
/***********************************************************************
*
* README for Novell.Casa.Client.Auth CSHARP Library
*
***********************************************************************/
INTRODUCTION
Novell.Casa.Client.Auth CSHARP Library provides a class for CSHARP client
applications to obtain authentication tokens from the CASA Authentication
Token Infrastructure.
CLIENT APPLICATION PROGRAMMING NOTES
The Novell.Casa.Client.Auth.Authtoken class provides static method ObtainAuthToken()
to allow client applications to obtain CASA Authentication Tokens. The caller must
supply the name of the service to which it wants to authenticate along with the name
of the host where it resides to the static method. The returned authentication token
is a Base64 encoded string.
Applications utilizing CASA Authentication Tokens as passwords in protocols that require the
transfer of user name and password credentials should verify or remove any password length limits
as the length of CASA Authentication Tokens may be over 1K bytes. The size of the CASA Authentication
Tokens is directly dependent on the amount of identity information configured as required by the
consuming service. These applications should also set the user name to "CasaPrincipal".
For examples of code which uses the Novell.Casa.Client.Auth.Authtoken class look at the test
application under the test folder.
SECURITY CONSIDERATIONS
CASA Authentication Tokens when compromised can be used to either impersonate
a user or to obtain identity information about the user. Because of this it is
important that the tokens be secured by applications making use of them. It is
recommended that the tokens be transmitted using SSL.

View File

@@ -0,0 +1,15 @@
/***********************************************************************
*
* TODO for Novell.Casa.Client.Auth CSHARP Library
*
***********************************************************************/
INTRODUCTION
This file contains a list of the items still outstanding for the
Novell.Casa.Client.Auth CSHARP library.
OUTSTANDING ITEMS
- Include it in the Linux Client build/rpm.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 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("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,74 @@
/***********************************************************************
*
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Jim Norman
*
***********************************************************************/
using System;
using Novell.Casa.Client.Auth;
namespace TestClientAuth
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Usage: TestClientAuth [server]");
Console.WriteLine("Press enter to continue");
Console.ReadLine();
return;
}
try
{
WinLuid luid = new WinLuid(1234, 5678);
Authtoken.ObtainAuthToken("testService", args[0], luid);
byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]);
Console.WriteLine("Token returned: ("+ baToken.Length + ")");
for (int i=0; i<baToken.Length; i++)
{
Console.Write(baToken[i].ToString());
}
Console.WriteLine("");
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("");
Console.WriteLine("Press enter to continue");
Console.ReadLine();
}
}
}
}

View File

@@ -0,0 +1,109 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{0EA635EA-97F2-4950-B36B-8151ED858DA4}"
>
<Build>
<Settings
ApplicationIcon = "App.ico"
AssemblyKeyContainerName = ""
AssemblyName = "TestClientAuth"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Exe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "TestClientAuth"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.XML"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "Novell.Casa.Client"
Project = "{1BA1FC97-5AF1-4506-A7FD-EBFD46D361A0}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "App.ico"
BuildAction = "Content"
/>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Class1.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>