Remove old cli project, add new one. (for windows)
This commit is contained in:
parent
e753b7a91d
commit
277c32c091
@ -1,294 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
|
||||
using Novell.CASA;
|
||||
|
||||
namespace Novell.CASA
|
||||
{
|
||||
class CASAUtil
|
||||
{
|
||||
|
||||
private static string m_sAppname = "CASAcli";
|
||||
private static string m_sKeyChainID = SecretStore.SERVER_KEY_CHAIN;
|
||||
private static string ENV_KEY_VALUE = "KEYVALUE";
|
||||
|
||||
private const int MODE_GET_CREDENTIAL = 1;
|
||||
private const int MODE_SET_CREDENTIAL = 2;
|
||||
private const int MODE_DELETE_CREDENTIAL = 3;
|
||||
|
||||
private static SecretStore m_ss = SecretStore.GetInstance();
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
|
||||
m_sAppname = proc.ProcessName;
|
||||
|
||||
try
|
||||
{
|
||||
if (args.Length > 0)
|
||||
ParseArgs(args);
|
||||
else
|
||||
ShowBasicHelp();
|
||||
}
|
||||
catch (Novell.CASA.miCasaException mce)
|
||||
{
|
||||
Console.WriteLine("Error occured: {0}", mce.GetMessage());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
static void ParseArgs(string[] args)
|
||||
{
|
||||
string sUsername = null;
|
||||
string sPassword = null;
|
||||
string sCredname = null;
|
||||
string sKeyname = null;
|
||||
string sValue = null;
|
||||
int iMode = 0;
|
||||
|
||||
|
||||
for (int i = 0; i<args.Length; i++)
|
||||
{
|
||||
string arg = args[i];
|
||||
if (arg.StartsWith("--"))
|
||||
{
|
||||
arg = arg.Substring(1);
|
||||
}
|
||||
|
||||
if (arg.ToLower().StartsWith("-h"))
|
||||
{
|
||||
ShowUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.ToLower().StartsWith("-l"))
|
||||
{
|
||||
ListCredentials();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-g"))
|
||||
{
|
||||
iMode = MODE_GET_CREDENTIAL;
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-s"))
|
||||
{
|
||||
iMode = MODE_SET_CREDENTIAL;
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-d"))
|
||||
{
|
||||
iMode = MODE_DELETE_CREDENTIAL;
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-n"))
|
||||
{
|
||||
// get next arg as username
|
||||
if (i + 1 < args.Length)
|
||||
{
|
||||
sCredname = args[++i];
|
||||
}
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-k"))
|
||||
{
|
||||
// get next arg as username
|
||||
if (i + 1 < args.Length)
|
||||
{
|
||||
sKeyname = args[++i];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
else if (arg.ToLower().StartsWith("-v"))
|
||||
{
|
||||
// get next arg as username
|
||||
if (i + 1 < args.Length)
|
||||
{
|
||||
sValue = args[++i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
else if (arg.ToLower().StartsWith("-u"))
|
||||
{
|
||||
// get next arg as username
|
||||
if (i + 1 < args.Length)
|
||||
{
|
||||
sUsername = args[++i];
|
||||
}
|
||||
}
|
||||
|
||||
else if (arg.ToLower().StartsWith("-p"))
|
||||
{
|
||||
// get next arg as password
|
||||
if (i + 1 < args.Length)
|
||||
{
|
||||
sPassword = args[++i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid arg: {0}", arg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we get here, check for operation
|
||||
if (iMode > 0)
|
||||
{
|
||||
// did we get a credential name?
|
||||
if (sCredname == null)
|
||||
{
|
||||
Console.WriteLine("No credential name entered");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (iMode)
|
||||
{
|
||||
case MODE_GET_CREDENTIAL:
|
||||
{
|
||||
// get named credential and display it.
|
||||
Console.WriteLine("Getting {0}", sCredname);
|
||||
DisplaySecret(m_ss.GetSecret(m_sKeyChainID, 0, sCredname, Secret.SS_CREDSET, ""));
|
||||
break;
|
||||
}
|
||||
case MODE_SET_CREDENTIAL:
|
||||
{
|
||||
Console.WriteLine("Setting {0}", sCredname);
|
||||
Secret secret = m_ss.GetSecret(m_sKeyChainID, 0, sCredname, Secret.SS_CREDSET, "");
|
||||
|
||||
if (sKeyname != null)
|
||||
{
|
||||
|
||||
// get the value from the KEYVALUE environment variable
|
||||
sValue = Environment.GetEnvironmentVariable(ENV_KEY_VALUE);
|
||||
|
||||
|
||||
if ((sValue != null) && (sValue.Length > 0))
|
||||
{
|
||||
secret.SetKeyValuePair(sKeyname, sValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No value found for named Key");
|
||||
Console.WriteLine(" Set the value using the KEYVALUE environment variable");
|
||||
Console.WriteLine(" Example: KEYVALUE=[value] {0} -s -n [credname] -k [keyname]", m_sAppname);
|
||||
Console.WriteLine();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sPassword != null)
|
||||
{
|
||||
secret.SetKeyValuePair("Password", sPassword);
|
||||
}
|
||||
|
||||
if (sUsername != null)
|
||||
{
|
||||
secret.SetKeyValuePair("CN", sUsername);
|
||||
}
|
||||
|
||||
m_ss.SetSecret(0, m_sKeyChainID, secret, Secret.SS_CREDSET);
|
||||
|
||||
break;
|
||||
}
|
||||
case MODE_DELETE_CREDENTIAL:
|
||||
{
|
||||
Console.WriteLine("Deleting {0}", sCredname);
|
||||
m_ss.RemoveSecret(0, m_sKeyChainID, "", sCredname, Secret.SS_CREDSET);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ShowBasicHelp()
|
||||
{
|
||||
Console.WriteLine("Try '{0} --help' for more infomation", m_sAppname);
|
||||
}
|
||||
|
||||
private static void ShowUsage()
|
||||
{
|
||||
ShowDescription();
|
||||
|
||||
Console.WriteLine(" Usage: {0} [OPTIONS]", m_sAppname);
|
||||
Console.WriteLine(" Options");
|
||||
Console.WriteLine(" -l, --list List all credentials used by services");
|
||||
Console.WriteLine(" -h, --help Displays this help screen");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -s, --set Sets the named credential");
|
||||
Console.WriteLine(" -g, --get Gets and displays the named credential");
|
||||
Console.WriteLine(" -d, --del Deletes the named credential");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -n, --name Specify the credential name");
|
||||
Console.WriteLine(" -k, --key Specify the key name to set");
|
||||
//Console.WriteLine(" -v, --value Specify the value for the key to set");
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine(" Examples");
|
||||
Console.WriteLine(" {0} --get -n MyCredential", m_sAppname);
|
||||
Console.WriteLine(" {0} --del -n MyCredential", m_sAppname);
|
||||
Console.WriteLine(" KEYVALUE=admin {0} --set -n MyCredential -k CN", m_sAppname);
|
||||
Console.WriteLine(" KEYVALUE=password {0} --set -n MyCredential -k Password", m_sAppname);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void ShowDescription()
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" Description:");
|
||||
Console.WriteLine(" This program is a simply utility to display, set, and delete");
|
||||
Console.WriteLine(" credentials used by services on this computer. Because credentials");
|
||||
Console.WriteLine(" are scoped by the UID of the running process, you must run");
|
||||
Console.WriteLine(" this utility as the same UID as the service being configured.");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private static void ListCredentials()
|
||||
{
|
||||
|
||||
StringCollection sc = m_ss.EnumerateSecretIDs(m_sKeyChainID);
|
||||
|
||||
StringEnumerator se = sc.GetEnumerator();
|
||||
while (se.MoveNext())
|
||||
{
|
||||
string sSecretID = (string)se.Current;
|
||||
Secret secret = m_ss.GetSecret(m_sKeyChainID, 0, sSecretID.Substring(11), Secret.SS_CREDSET, "");
|
||||
DisplaySecret(secret);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DisplaySecret(Secret secret)
|
||||
{
|
||||
|
||||
Console.WriteLine(" Name: {0}", secret.GetID());
|
||||
NameValueCollection nvc = secret.GetKeyValueCollection();
|
||||
|
||||
for (int i = 0; i < nvc.Count; i++)
|
||||
{
|
||||
string sKeyname = nvc.Keys[i];
|
||||
if (sKeyname.ToLower().StartsWith("p"))
|
||||
{
|
||||
Console.WriteLine(" key: {0} (*******)", nvc.Keys[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(" key: {0} ({1})", nvc.Keys[i], nvc.Get(i));
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B4182B62-2F56-4835-9479-403FFA134E5D}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CASAUtil</RootNamespace>
|
||||
<AssemblyName>CASAUtil</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CASAUtil.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\sharp\NSSCSWrapper\Novell.CASA.miCASAWrapper.csproj">
|
||||
<Project>{E21DD887-22F4-4935-9851-409715F663B0}</Project>
|
||||
<Name>Novell.CASA.miCASAWrapper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
208
CASA/cli/CASAcli.vcproj
Normal file
208
CASA/cli/CASAcli.vcproj
Normal file
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="CASAcli"
|
||||
ProjectGUID="{4AFEB4A4-C9D7-4EAD-BCE4-BA84E00ACA23}"
|
||||
RootNamespace="CASAcli"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/sshtst.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib micasa.lib"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\micasadk\Release"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="micasa.lib odbc32.lib odbccp32.lib"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\micasadk\Release"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\casacli.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
Loading…
Reference in New Issue
Block a user