Bug 265898. CLI change, use KEYVALUE environment variable

when setting a named key.
This commit is contained in:
Jim Norman 2007-05-02 16:12:10 +00:00
parent 73c638a6f8
commit 9e5e0452a1
2 changed files with 26 additions and 11 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed May 2 10:04:42 MDT 2007 - jnorman@novell.com
- Bug 265898. CLI change. Read the KEYVALUE environment variable
when setting the value of a key.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue May 1 09:15:13 MDT 2007 - jnorman@novell.com Tue May 1 09:15:13 MDT 2007 - jnorman@novell.com

View File

@ -11,6 +11,8 @@ namespace Novell.CASA
private static string m_sAppname = "CASAcli"; private static string m_sAppname = "CASAcli";
private static string m_sKeyChainID = SecretStore.SERVER_KEY_CHAIN; 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_GET_CREDENTIAL = 1;
private const int MODE_SET_CREDENTIAL = 2; private const int MODE_SET_CREDENTIAL = 2;
private const int MODE_DELETE_CREDENTIAL = 3; private const int MODE_DELETE_CREDENTIAL = 3;
@ -103,6 +105,7 @@ namespace Novell.CASA
} }
} }
/*
else if (arg.ToLower().StartsWith("-v")) else if (arg.ToLower().StartsWith("-v"))
{ {
// get next arg as username // get next arg as username
@ -111,6 +114,7 @@ namespace Novell.CASA
sValue = args[++i]; sValue = args[++i];
} }
} }
*/
else if (arg.ToLower().StartsWith("-u")) else if (arg.ToLower().StartsWith("-u"))
{ {
@ -163,14 +167,21 @@ namespace Novell.CASA
if (sKeyname != null) if (sKeyname != null)
{ {
if (sValue != 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); secret.SetKeyValuePair(sKeyname, sValue);
} }
else else
{ {
Console.WriteLine("No value entered for named Key"); Console.WriteLine("No value found for named Key");
Console.WriteLine("Example: {0} -s -n [credname] -k [keyname] -v [value]", m_sAppname); 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; return;
} }
} }
@ -197,10 +208,7 @@ namespace Novell.CASA
} }
} }
} }
} }
private static void ShowBasicHelp() private static void ShowBasicHelp()
@ -223,14 +231,15 @@ namespace Novell.CASA
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(" -n, --name Specify the credential name"); Console.WriteLine(" -n, --name Specify the credential name");
Console.WriteLine(" -k, --key Specify the key name to set"); Console.WriteLine(" -k, --key Specify the key name to set");
Console.WriteLine(" -v, --value Specify the value for the key to set"); //Console.WriteLine(" -v, --value Specify the value for the key to set");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(" Examples"); Console.WriteLine(" Examples");
Console.WriteLine(" {0} --get -n MyCredential", m_sAppname); Console.WriteLine(" {0} --get -n MyCredential", m_sAppname);
Console.WriteLine(" {0} --set -n MyCredential -k CN -v admin", m_sAppname);
Console.WriteLine(" {0} --set -n MyCredential -k Password -v password", m_sAppname);
Console.WriteLine(" {0} --del -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);
} }