Moving micasa 1.5 trunk to Novell forge.

This commit is contained in:
Cameron (Kamran) Mashayekhi
2005-10-11 19:51:00 +00:00
parent 082db33275
commit efe0a5e13c
691 changed files with 116628 additions and 0 deletions

BIN
c_test/c_sample/CSample.ncb Normal file

Binary file not shown.

View File

@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NativeSample", "NativeSample.vcproj", "{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}.Debug.ActiveCfg = Debug|Win32
{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}.Debug.Build.0 = Debug|Win32
{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}.Release.ActiveCfg = Release|Win32
{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

BIN
c_test/c_sample/CSample.suo Normal file

Binary file not shown.

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="cSample"
ProjectGUID="{2635AF48-A4B2-42BD-97E2-A9AD9FF79E8C}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="D:\ccm\SSClient\SecretStoreClient_src\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="micasa_mdd.lib odbc32.lib odbccp32.lib"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="D:\ccm\SSClient\SecretStoreClient_src\bin\w32\mdd"
GenerateDebugInformation="TRUE"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/sshtst.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="D:\ccm\SSClient\SecretStoreClient_src\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="micasa.lib odbc32.lib odbccp32.lib"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="D:\ccm\SSClient\SecretStoreClient_src\lib\w32"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/sshtst.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\cSample.c">
</File>
<File
RelativePath="..\..\include\micasa.h">
</File>
<File
RelativePath="..\..\include\micasa_mgmd.h">
</File>
<File
RelativePath="..\..\include\micasa_types.h">
</File>
<File
RelativePath="..\..\include\sscs_utf8.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

19
c_test/c_sample/Makefile Normal file
View File

@@ -0,0 +1,19 @@
#
# configure environment
#
TARGET = cSample
include global.mak
include defaults.$(PLAT)
include rules.mak
BIN_NAME = $(TARGET).exe
#
# target object and source files
#
include objs.$(PLAT)
#
# targets
#
include target

444
c_test/c_sample/cSample.c Normal file
View File

@@ -0,0 +1,444 @@
/**************************************************************************
Copyright (c) [2005] 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 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, if not, contact Novell, Inc.
To contact Novell about this file by physical or electronic mail,
you may find current contact information at www.novell.com.
**************************************************************************/
/* Sample code for C Language miCASA APIs */
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <conio.h>
#include <windows.h>
#else
#define getch(x) getchar(x);
#endif
#include <time.h>
#include <string.h>
#include <micasa_mgmd.h>
#include <sscs_utf8.h>
///////////////////////////////////////////////////////////////////////
void Pause()
{
printf("\nPress a key ==>\n");
getch();
} /* end of Pause */
void AddSecret()
{
int rcode = 0;
char inputID[20];
char inputUsername[20];
char inputPassword[20];
SSCS_BASIC_CREDENTIAL credential = {0};
SSCS_SECRET_ID_T appSecretId = {0};
SSCS_SECRET_ID_T sharedSecretId = {0};
SSCS_EXT_T ext = {0};
printf("Enter secretID: ");
gets(inputID);
printf("Enter Username: ");
gets(inputUsername);
printf("Enter Password: ");
gets(inputPassword);
if ((sscs_Utf8Strlen(inputID) > 0) &&
(sscs_Utf8Strlen(inputUsername) > 0) &&
(sscs_Utf8Strlen(inputPassword) > 0))
{
appSecretId.len = sscs_Utf8Strlen(inputID) + 1;
sscs_Utf8Strcpy(appSecretId.id, inputID);
credential.unFlags = USERNAME_TYPE_CN_F;
sscs_Utf8Strcpy(credential.username, inputUsername);
credential.unLen = sscs_Utf8Strlen(inputUsername) + 1;
sscs_Utf8Strcpy(credential.password, inputPassword);
credential.pwordLen = sscs_Utf8Strlen(inputPassword) + 1;
// sets the credential for this app
rcode = miCASASetCredential(
0,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
if (rcode)
{
printf("Add Secret returned %d\r\n", rcode);
Pause();
}
}
}
void DisplaySecret()
{
int rcode = 0;
char inputID[20];
SSCS_BASIC_CREDENTIAL credential = {0};
SSCS_SECRET_ID_T appSecretId = {0};
SSCS_SECRET_ID_T sharedSecretId = {0};
SSCS_EXT_T ext = {0};
printf("Enter secretID to display: ");
gets(inputID);
if (sscs_Utf8Strlen(inputID) > 0)
{
appSecretId.len = sscs_Utf8Strlen(inputID) + 1;
sscs_Utf8Strcpy(appSecretId.id, inputID);
// set name type we desire
credential.unFlags = USERNAME_TYPE_CN_F;
// gets the credential
rcode = miCASAGetCredential(
0,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
if (rcode == NSSCS_SUCCESS)
{
printf("Credential for: %s\r\n", appSecretId.id);
printf("Username: %s\r\n", credential.username);
printf("Password: %s\r\n", credential.password);
}
else
{
printf("Error: %d\r\n", rcode);
Pause();
}
}
}
void RemoveSecret()
{
int rcode = 0;
char inputID[20];
SSCS_BASIC_CREDENTIAL credential = {0};
SSCS_SECRET_ID_T appSecretId = {0};
SSCS_SECRET_ID_T sharedSecretId = {0};
SSCS_EXT_T ext = {0};
printf("Enter secretID to remove: ");
gets(inputID);
if (sscs_Utf8Strlen(inputID) > 0)
{
appSecretId.len = sscs_Utf8Strlen(inputID) + 1;
sscs_Utf8Strcpy(appSecretId.id, inputID);
// set name type we desire
credential.unFlags = USERNAME_TYPE_CN_F;
// gets the credential
rcode = miCASARemoveCredential(
0,
&appSecretId,
NULL,
NULL
);
if (rcode == NSSCS_SUCCESS)
{
printf("Credential %s removed\r\n", inputID);
}
else
{
printf("Error: %d\r\n", rcode);
Pause();
}
}
}
void RunTest()
{
{
SSCS_BASIC_CREDENTIAL credential = {0};
SSCS_SECRET_ID_T appSecretId = {0};
int rcode = 0;
int iFlags = 0;
sscs_Utf8Strcpy(appSecretId.id, "NativeC.AppSecretID");
appSecretId.len = sscs_Utf8Strlen(appSecretId.id) + 1;
credential.unFlags = USERNAME_TYPE_CN_F;
sscs_Utf8Strcpy((char*)credential.username, "SampleUsername");
credential.unLen = sscs_Utf8Strlen(credential.username) + 1;
sscs_Utf8Strcpy((char*)credential.password, "SamplePassword");
credential.pwordLen = sscs_Utf8Strlen(credential.password) + 1;
printf("Setting %s\r\n", appSecretId.id);
printf(" Username: %s\r\n", credential.username);
printf(" Password: %s\r\n", credential.password);
// sets the credential for this app
rcode = miCASASetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
credential.unFlags = USERNAME_TYPE_EMAIL_F;
sscs_Utf8Strcpy((char*)credential.username, "Username@novell.com");
credential.unLen = sscs_Utf8Strlen(credential.username) + 1;
sscs_Utf8Strcpy((char*)credential.password, "SamplePassword");
credential.pwordLen = sscs_Utf8Strlen(credential.password) + 1;
// sets the credential for this app
rcode = miCASASetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
credential.unFlags = USERNAME_TYPE_LDAP_DN_F;
sscs_Utf8Strcpy((char*)credential.username, "cn=user,o=novell");
credential.unLen = sscs_Utf8Strlen(credential.username) + 1;
sscs_Utf8Strcpy((char*)credential.password, "SamplePassword");
credential.pwordLen = sscs_Utf8Strlen(credential.password) + 1;
// sets the credential for this app
rcode = miCASASetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
credential.unFlags = USERNAME_TYPE_NDS_DN_F;
sscs_Utf8Strcpy((char*)credential.username, "Username.novell");
credential.unLen = sscs_Utf8Strlen(credential.username) + 1;
sscs_Utf8Strcpy((char*)credential.password, "SamplePassword");
credential.pwordLen = sscs_Utf8Strlen(credential.password) + 1;
// sets the credential for this app
rcode = miCASASetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
// get the stuff back now
memset(&credential, 0, sizeof(SSCS_BASIC_CREDENTIAL));
credential.unLen = NSSCS_MAX_USERID_LEN;
credential.pwordLen = NSSCS_MAX_PWORD_LEN;
credential.unFlags = USERNAME_TYPE_CN_F;
// gets the specific credential
rcode = miCASAGetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
if (rcode == NSSCS_SUCCESS)
{
printf("Getting Credential: %s\r\n", appSecretId.id);
printf(" Username: %s\r\n", credential.username);
printf(" Password: %s\r\n", credential.password);
}
else
{
printf("ERROR getting Credential: %d\r\n", rcode);
Pause();
}
printf("Removing Credential\r\n");
rcode = miCASARemoveCredential(
iFlags,
&appSecretId,
NULL,
NULL
);
if (rcode != NSSCS_SUCCESS)
printf("Error removing Credential: %d\r\n", rcode);
// get the stuff back now
memset(&credential, 0, sizeof(SSCS_BASIC_CREDENTIAL));
credential.unLen = NSSCS_MAX_USERID_LEN;
credential.pwordLen = NSSCS_MAX_PWORD_LEN;
credential.unFlags = USERNAME_TYPE_CN_F;
// gets the specific credential
rcode = miCASAGetCredential(
iFlags,
&appSecretId,
NULL,
SSCS_CRED_TYPE_BASIC_F,
&credential,
NULL
);
if (rcode == NSSCS_E_INVALID_SECRET_ID)
printf("Credential does not exist as expected -- SUCCESS\r\n");
else
{
printf("Credential exists, when it should not -- FAILED\r\n");
Pause();
}
printf("Test completed\r\n");
}
}
void RunTests()
{
char runtimes[6];
int iCount = 1;
int iTemp = 0;
int i = 0;
printf("Enter number interations to run (default 1): ");
gets(runtimes);
iTemp = atoi(runtimes);
if (iTemp > 1)
iCount=iTemp;
for (i=0; i<iCount; i++)
{
RunTest();
printf("\r\n");
}
}
void displayMenu()
{
int c;
while (1)
{
printf("\r\n");
printf("********** Menu **********\r\n");
printf("* 1. Add secret *\r\n");
printf("* 2. Display secret *\r\n");
printf("* 3. Remove secret *\r\n");
printf("* 4. Run automated test *\r\n");
printf("* 5. Quit *\r\n");
printf("**************************\r\n");
printf("Select option and press Enter\r\n");
c = getchar();
// get return
getchar();
if (c == '5')
return;
else if (c == '1')
AddSecret();
else if (c == '2')
DisplaySecret();
else if (c == '3')
RemoveSecret();
else if (c == '4')
RunTests();
}
}
/*
* NAME - main
*
* DESCRIPTION
* miCASA test program.
*
*/
int main
(
int argc,
char **argv
)
{ /* beginning of the call */
/* ########################## DECLARATIONS START HERE ######################### */
/* ############################## CODE STARTS HERE ############################ */
printf("***************************************************************\r\n");
printf("************** miCASA Sample program in C **************\r\n");
printf("***************************************************************\r\n");
displayMenu();
exit(0);
/* ########################## CODE ENDS HERE ##################### */
}

12
c_test/c_sample/link.w32 Normal file
View File

@@ -0,0 +1,12 @@
LINK_DEF_BLD = \
echo "$(addprefix ,$(ROOT)obj/w32/md/$(notdir $(OBJS)))" > $(LINKDEF);\
echo "$(ROOT)lib/w32/micasa.lib" >> $(LINKDEF);\
echo "$(MSC)lib/kernel32.lib" >> $(LINKDEF);\
echo "/LIBPATH:$(MSC)lib" >> $(LINKDEF);\
echo "/NODEFAULTLIB:uuid" >> $(LINKDEF);\
echo "/NOLOGO" >> $(LINKDEF);\
echo "/SUBSYSTEM:CONSOLE" >> $(LINKDEF);\
echo "/INCREMENTAL:NO" >> $(LINKDEF);\
echo "/PDB:Release/cSample.pdb" >> $(LINKDEF);\
echo "/OUT:Release/cSample.exe" >> $(LINKDEF);\
echo "/MACHINE:IX86" >> $(LINKDEF);\

View File

@@ -0,0 +1,12 @@
LINK_DEF_BLD = \
echo "$(addprefix ,$(ROOT)obj/w32/mdd/$(notdir $(OBJS)))" > $(LINKDEF);\
echo "$(ROOT)lib/w32/micasa_mdd.lib" >> $(LINKDEF);\
echo "$(MSC)lib/kernel32.lib" >> $(LINKDEF);\
echo "/LIBPATH:$(MSC)lib" >> $(LINKDEF);\
echo "/NODEFAULTLIB:uuid" >> $(LINKDEF);\
echo "/NOLOGO" >> $(LINKDEF);\
echo "/SUBSYSTEM:CONSOLE" >> $(LINKDEF);\
echo "/INCREMENTAL:NO" >> $(LINKDEF);\
echo "/PDB:Debug/cSample.pdb" >> $(LINKDEF);\
echo "/OUT:Debug/cSample.exe" >> $(LINKDEF);\
echo "/MACHINE:IX86" >> $(LINKDEF);

3
c_test/c_sample/objs.lux Normal file
View File

@@ -0,0 +1,3 @@
OBJS=\
cSample.$(O)

3
c_test/c_sample/objs.w32 Normal file
View File

@@ -0,0 +1,3 @@
OBJS=\
cSample.$(O)

26
c_test/c_sample/target Normal file
View File

@@ -0,0 +1,26 @@
include link$(xtra).$(PLAT)
all : $(BIN_NAME)
$(BIN_NAME) : $(OBJS)
@echo Linking $@ ...
@$(LINK_DEF_BLD)
$(LINK)
$(RM) $(LINKDEF)
$(TSTPACK)
@echo
install :
@echo client Installing $< ...
## The binaries
ifeq ($(PLAT),w32)
$(CP) Release/$(BIN_NAME) $(INSTALLDIR)tools/w32
else
$(CP) $(BINDIR)$(basename $(BIN_NAME)).$(BIN) $(INSTALLDIR)tools/lux
endif
clean :
@echo Cleaning ...
$(RM) *.err *.bak *.i *.res $(OBJDIR)*.$(O) $(OBJDIR)*.res Release/*.*