From 277c32c09153eff0086ad44d9997e5eea2fb46a8 Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Tue, 10 Jul 2007 17:42:05 +0000 Subject: [PATCH] Remove old cli project, add new one. (for windows) --- CASA/cli/CASAUtil.cs | 294 --------------------------------------- CASA/cli/CASAUtil.csproj | 53 ------- CASA/cli/CASAcli.vcproj | 208 +++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 347 deletions(-) delete mode 100644 CASA/cli/CASAUtil.cs delete mode 100644 CASA/cli/CASAUtil.csproj create mode 100644 CASA/cli/CASAcli.vcproj diff --git a/CASA/cli/CASAUtil.cs b/CASA/cli/CASAUtil.cs deleted file mode 100644 index a07eaf30..00000000 --- a/CASA/cli/CASAUtil.cs +++ /dev/null @@ -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 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(); - - } - } -} diff --git a/CASA/cli/CASAUtil.csproj b/CASA/cli/CASAUtil.csproj deleted file mode 100644 index 5c809e1f..00000000 --- a/CASA/cli/CASAUtil.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {B4182B62-2F56-4835-9479-403FFA134E5D} - Exe - Properties - CASAUtil - CASAUtil - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - {E21DD887-22F4-4935-9851-409715F663B0} - Novell.CASA.miCASAWrapper - - - - - - - - \ No newline at end of file diff --git a/CASA/cli/CASAcli.vcproj b/CASA/cli/CASAcli.vcproj new file mode 100644 index 00000000..d74c4e71 --- /dev/null +++ b/CASA/cli/CASAcli.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +