- Added support for ADD/MODIFY/DELETE functionalities for Keyring and
Kwallet stores in A-Dlib. .....................................................................
This commit is contained in:
parent
b8aedf332e
commit
f610a50037
@ -155,6 +155,85 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
Modifying a Secret
|
||||
|
||||
SetSecret will modify the Value(s) of a Key(s) for an existing secret
|
||||
SetSecret will also add new secrets
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XMLNode
|
||||
1. If a Key node of a secret is missing then that key will be deleted
|
||||
2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as
|
||||
Gnome Api's do not allow it.
|
||||
3. All Time nodes for a Secret need not be passed as they cannot be set.
|
||||
4. Keyring attributes have a fixed datatype of Int and String.
|
||||
Currently we support only String types. To support int types CCF needs to be modified accordingly.
|
||||
5. SetSecret overloaded method, without the opnType parameter, is not supported for GnomeKeyring
|
||||
|
||||
opnType : Operation Type
|
||||
ConstStrings.OPERATION_ADD_SECRET
|
||||
ConstStrings.OPERATION_MODIFY_SECRET
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
*********************************************************************************/
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType, int StoreID)
|
||||
{
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
return micasaengine.SetSecret(secret, opnType);
|
||||
if (StoreID == ConstStrings.CASA_STORE_KWALLET)
|
||||
return kwEngine.SetSecret(secret, opnType);
|
||||
if (StoreID == ConstStrings.CASA_STORE_GK)
|
||||
return gkEngine.SetSecret(secret, opnType);
|
||||
else
|
||||
{
|
||||
#if LINUX
|
||||
Logger.DbgLog("A-D Lib:Failed to Set Secret in to miCASA");
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
Modifying a Secret
|
||||
|
||||
SetSecret will modify the Value(s) of a Key(s) for an existing secret
|
||||
SetSecret will also add new secrets
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XMLNode
|
||||
1. If a Key node of a secret is missing then that key will be deleted
|
||||
2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as
|
||||
Gnome Api's do not allow it.
|
||||
3. All Time nodes for a Secret need not be passed as they cannot be set.
|
||||
4. Keyring attributes have a fixed datatype of Int and String.
|
||||
Currently we support only String types. To support int types CCF needs to be modified accordingly.
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
*********************************************************************************/
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
{
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
@ -191,7 +270,27 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
Remove will delete a Secret.
|
||||
|
||||
public int Remove(XmlNode secret, int StoreID)
|
||||
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XmlNode
|
||||
1. This node will be deleted from its parent.
|
||||
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
|
||||
*********************************************************************************/
|
||||
|
||||
public int Remove(XmlNode secret, int StoreID)
|
||||
{
|
||||
@ -278,7 +377,7 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("KWallet some issue");
|
||||
//Console.WriteLine("KWallet some issue");
|
||||
return ConstStrings.CASA_STORE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.5.*")]
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
|
@ -160,21 +160,26 @@ namespace Novell.CASA.DataEngines
|
||||
|
||||
return doc.ChildNodes[0];
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
string password = null;
|
||||
int retValue;
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine("In SetSecret Name = "+ secret.Name);
|
||||
int itemid = ExtractSecretId(secret);
|
||||
string keyringname = ExtractKeyringName(secret);
|
||||
|
||||
NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection();
|
||||
|
||||
XmlNodeList keylist = secret.SelectNodes("descendant::Key");
|
||||
Console.WriteLine("In SetSecret");
|
||||
foreach (XmlNode tuple in keylist)
|
||||
{
|
||||
//Get the Key
|
||||
@ -190,36 +195,42 @@ namespace Novell.CASA.DataEngines
|
||||
newNVC.Add(keyname, tuple.ChildNodes[0].InnerText);
|
||||
}
|
||||
}
|
||||
if (itemid == -2) //Add Item Opn
|
||||
if (opnType == ConstStrings.OPERATION_ADD_SECRET ) //Add Item Opn
|
||||
{
|
||||
|
||||
string strItemType = ExtractItemType(secret);
|
||||
string secretName = ExtractSecretName(secret);
|
||||
string secretName = ExtractSecretName(secret, opnType);
|
||||
|
||||
return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC));
|
||||
}
|
||||
//Modify secret Opn
|
||||
|
||||
if ( password != null)
|
||||
{
|
||||
|
||||
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
|
||||
if (retValue != 0)
|
||||
{
|
||||
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (newNVC.Count != 0)
|
||||
{
|
||||
|
||||
return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
Console.WriteLine("Exception in SetSecret = "+n.ToString());
|
||||
//Console.WriteLine("Exception in SetSecret = "+n.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Exception in SetSecret = "+e.ToString());
|
||||
//Console.WriteLine("Exception in SetSecret = "+e.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
@ -228,6 +239,7 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
try
|
||||
@ -238,13 +250,13 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
Console.WriteLine("Exception in Remove = "+n.ToString());
|
||||
//Console.WriteLine("Exception in Remove = "+n.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
Console.WriteLine("Exception in Remove = "+e.ToString());
|
||||
//Console.WriteLine("Exception in Remove = "+e.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
@ -253,13 +265,12 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("In Extract Secret Id");
|
||||
//Check if itemId is present
|
||||
if (secretid.EndsWith(":"))
|
||||
/*if (secretid.EndsWith(":"))
|
||||
{
|
||||
Console.WriteLine("In Extract Secret Id : Add Opn");
|
||||
return -2;
|
||||
}
|
||||
*/
|
||||
int itemIdx = secretid.LastIndexOf(":");
|
||||
if (itemIdx == -1)
|
||||
{
|
||||
@ -269,14 +280,18 @@ namespace Novell.CASA.DataEngines
|
||||
return itemid;
|
||||
}
|
||||
|
||||
string ExtractSecretName(XmlNode secret)
|
||||
string ExtractSecretName(XmlNode secret, int opnType)
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("In Extract Secret name");
|
||||
|
||||
if (opnType == ConstStrings.OPERATION_ADD_SECRET)
|
||||
{
|
||||
return secretid; //Not expecting an item Id
|
||||
|
||||
}
|
||||
int itemIdx = secretid.LastIndexOf(":");
|
||||
Console.WriteLine("Extracting Secret Name Last Index Of : = " + itemIdx);
|
||||
//Check if itemId is present
|
||||
//Return substring without itemId
|
||||
return(secretid.Substring(0,itemIdx));
|
||||
}
|
||||
|
||||
@ -284,7 +299,6 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode;
|
||||
Console.WriteLine("In Extract Keyring Name");
|
||||
atcol = parentNode.Attributes;
|
||||
String keyringname = atcol["ID"].InnerXml;
|
||||
return keyringname;
|
||||
@ -295,7 +309,6 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml;
|
||||
Console.WriteLine("In ExtractItemType");
|
||||
return(itemType);
|
||||
}
|
||||
|
||||
@ -306,16 +319,17 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
|
||||
Console.WriteLine("Hello there");
|
||||
GKEngine gk = new GKEngine();
|
||||
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("********** Menu ***********");
|
||||
Console.WriteLine("* 1. Set secret *");
|
||||
Console.WriteLine("* 2. Remove secret *");
|
||||
Console.WriteLine("* 3. Refresh *");
|
||||
Console.WriteLine("* 4. Quit *");
|
||||
Console.WriteLine("* 1. Add secret *");
|
||||
Console.WriteLine("* 2. Modify secret *");
|
||||
Console.WriteLine("* 3. Set secret *");
|
||||
Console.WriteLine("* 4. Remove secret *");
|
||||
Console.WriteLine("* 5. Refresh *");
|
||||
Console.WriteLine("* 6. Quit *");
|
||||
Console.WriteLine("***************************");
|
||||
Console.WriteLine("For all options the input is the file /root/gktest.xml");
|
||||
|
||||
@ -328,9 +342,9 @@ namespace Novell.CASA.DataEngines
|
||||
char[] c = line.Substring(0, 1).ToCharArray();
|
||||
if (c.Length > 0)
|
||||
{
|
||||
if (c[0].Equals('4'))
|
||||
if (c[0].Equals('6'))
|
||||
return;
|
||||
if (c[0].Equals('3'))
|
||||
if (c[0].Equals('5'))
|
||||
{
|
||||
XmlNode node = gk.Aggregate ();
|
||||
XmlDocument doc = node.OwnerDocument;
|
||||
@ -351,22 +365,17 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
Console.WriteLine("Root is null");
|
||||
}
|
||||
Console.WriteLine("Root is not null\n");
|
||||
Console.WriteLine("Root Name \n" + root.Name);
|
||||
Console.WriteLine("Keyring Name \n" + root.ChildNodes[0].Name);
|
||||
Console.WriteLine("Secret Name \n" + root.ChildNodes[0].ChildNodes[0].Name);
|
||||
XmlNode secret = root.ChildNodes[0].ChildNodes[0];
|
||||
Console.WriteLine("secret Name \n" + secret.Name);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (c[0].Equals('2'))
|
||||
if (c[0].Equals('4'))
|
||||
res =gk.Remove(secret);
|
||||
else if (c[0].Equals('1'))
|
||||
res = gk.SetSecret(secret, ConstStrings.OPERATION_ADD_SECRET);
|
||||
else if (c[0].Equals('2'))
|
||||
res = gk.SetSecret(secret, ConstStrings.OPERATION_MODIFY_SECRET);
|
||||
else if (c[0].Equals('3'))
|
||||
res = gk.SetSecret(secret);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ namespace Novell.CASA.DataEngines
|
||||
|
||||
int GetSecret(XmlNode secret);
|
||||
|
||||
int SetSecret(XmlNode secret, int opnType);
|
||||
|
||||
int SetSecret(XmlNode secret);
|
||||
|
||||
int Remove(XmlNode secret);
|
||||
|
@ -188,9 +188,10 @@ namespace Novell.CASA.DataEngines
|
||||
idattr.Value = secid;
|
||||
Secret.SetAttributeNode(idattr);
|
||||
|
||||
XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
|
||||
/*XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
|
||||
typeAttr.Value = entryType;
|
||||
Secret.SetAttributeNode(typeAttr);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -290,77 +291,62 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
SetSecret will modify the Value(s) of a Key(s) for an existing secret
|
||||
SetSecret will also add new secrets
|
||||
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XMLNode
|
||||
1. If a Key node of a secret is missing then that key will be deleted
|
||||
2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as
|
||||
Gnome Api's do not allow it.
|
||||
|
||||
3. All Time nodes for a Secret need not be passed as they cannot be set.
|
||||
4. Keyring attributes have a fixed datatype of Int and String. Currently we support only String types.
|
||||
To support int types CCF needs to be modified accordingly.
|
||||
5. To signify that a GnomeKeyring secret should be added, append the secret's ID with a ":".
|
||||
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET;
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
***************************************************************************************/
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string walletName = ExtractWalletName(secret);
|
||||
string folderName = ExtractFolderName(secret);
|
||||
string keyName = ExtractKeyName(secret);
|
||||
int secretType = ExtractSecretType(secret);
|
||||
|
||||
if (secretType != 3) //Type not Map
|
||||
{
|
||||
|
||||
string value = secret.ChildNodes[0].ChildNodes[0].InnerText; //Secret.Key.Value
|
||||
|
||||
return(kwallet.SetSecret(walletName, folderName, secretType, keyName, value, value.Length));
|
||||
}
|
||||
else //If type is Map
|
||||
{
|
||||
|
||||
NameValueCollection nvc = new NameValueCollection();
|
||||
|
||||
for (int i =0; i< secret.ChildNodes.Count; i++)
|
||||
{
|
||||
|
||||
XmlNode key = secret.ChildNodes[i];
|
||||
XmlAttributeCollection atcol;
|
||||
atcol = key.Attributes;
|
||||
String keyMapName = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("Map Ele KeyName = " + keyMapName);
|
||||
|
||||
string value = key.ChildNodes[0].InnerText; //Secret.Key.Value
|
||||
Console.WriteLine("Map Ele Value = " + value);
|
||||
|
||||
nvc.Add(keyMapName,value);
|
||||
}
|
||||
|
||||
|
||||
return(kwallet.SetSecret(walletName, folderName,keyName,nvc));
|
||||
}
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
return SetSecret(secret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -369,25 +355,6 @@ namespace Novell.CASA.DataEngines
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
Remove will delete a Secret.
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XmlNode
|
||||
1. This node will be deleted from its parent.
|
||||
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET;
|
||||
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull. Error code is same as above
|
||||
|
||||
**************************************************************************************/
|
||||
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
try
|
||||
@ -395,7 +362,6 @@ namespace Novell.CASA.DataEngines
|
||||
string walletName = ExtractWalletName(secret);
|
||||
string folderName = ExtractFolderName(secret);
|
||||
string keyName = ExtractKeyName(secret);
|
||||
int secretType = ExtractSecretType(secret);
|
||||
int res = kwallet.DeleteSecret(walletName, folderName, keyName);
|
||||
if (res == 0)
|
||||
{
|
||||
@ -406,13 +372,13 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
@ -421,10 +387,8 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode.ParentNode.ParentNode;
|
||||
Console.WriteLine("In Extract Wallet Name ");
|
||||
atcol = parentNode.Attributes;
|
||||
String walletname = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("In Extract Wallet Name Wallet Name = " + walletname);
|
||||
return walletname;
|
||||
}
|
||||
|
||||
@ -432,20 +396,16 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode.ParentNode; //Folder.Type.Secret
|
||||
Console.WriteLine("In Extract Folder Name ");
|
||||
atcol = parentNode.Attributes;
|
||||
String foldername = atcol["Name"].InnerXml;
|
||||
Console.WriteLine("In Extract Folder Name Folder Name = " + foldername);
|
||||
return foldername;
|
||||
}
|
||||
|
||||
string ExtractKeyName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
Console.WriteLine("In Extract Key Name ");
|
||||
atcol = secret.Attributes;
|
||||
String keyname = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("In Extract Key Name Key Name = " + keyname);
|
||||
return keyname;
|
||||
}
|
||||
|
||||
@ -453,10 +413,8 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode; //Type.Secret
|
||||
Console.WriteLine("In Extract Entry Type ");
|
||||
atcol = parentNode.Attributes;
|
||||
String entryType = atcol["ID"].InnerXml;
|
||||
Console.WriteLine("In Extract Entry Type = " + entryType);
|
||||
if (entryType.CompareTo("Passwords")== 0)
|
||||
{
|
||||
return 1;
|
||||
@ -476,16 +434,17 @@ namespace Novell.CASA.DataEngines
|
||||
#if TEST
|
||||
public static void Main()
|
||||
{
|
||||
Console.WriteLine("Hello there");
|
||||
KWalletEngine kw = new KWalletEngine();
|
||||
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("********** Menu ***********");
|
||||
Console.WriteLine("* 1. Set secret *");
|
||||
Console.WriteLine("* 2. Remove secret *");
|
||||
Console.WriteLine("* 3. Refresh *");
|
||||
Console.WriteLine("* 4. Quit *");
|
||||
Console.WriteLine("* 1. Add secret *");
|
||||
Console.WriteLine("* 2. Modify secret *");
|
||||
Console.WriteLine("* 3. Set secret *");
|
||||
Console.WriteLine("* 4. Remove secret *");
|
||||
Console.WriteLine("* 5. Refresh *");
|
||||
Console.WriteLine("* 6. Quit *");
|
||||
Console.WriteLine("***************************");
|
||||
Console.WriteLine("For all options the input is the file /root/kwtest.xml");
|
||||
|
||||
@ -500,9 +459,9 @@ namespace Novell.CASA.DataEngines
|
||||
char[] c = line.Substring(0, 1).ToCharArray();
|
||||
if (c.Length > 0)
|
||||
{
|
||||
if (c[0].Equals('4'))
|
||||
if (c[0].Equals('6'))
|
||||
return;
|
||||
if (c[0].Equals('3'))
|
||||
if (c[0].Equals('5'))
|
||||
kw.Aggregate ();
|
||||
else
|
||||
{
|
||||
@ -516,17 +475,15 @@ namespace Novell.CASA.DataEngines
|
||||
{
|
||||
Console.WriteLine("Root is null");
|
||||
}
|
||||
Console.WriteLine("Root is not null\n");
|
||||
Console.WriteLine("Root Name \n" + root.Name);
|
||||
Console.WriteLine("Wallet Name \n" + root.ChildNodes[0].Name);
|
||||
Console.WriteLine("Folder Name \n" + root.ChildNodes[0].ChildNodes[0].Name);
|
||||
Console.WriteLine("Type Name \n" + root.ChildNodes[0].ChildNodes[0].ChildNodes[0].Name);
|
||||
Console.WriteLine("Secret Name \n" + root.ChildNodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[0].Name);
|
||||
XmlNode secret = root.ChildNodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[0];
|
||||
|
||||
if (c[0].Equals('2'))
|
||||
if (c[0].Equals('4'))
|
||||
res =kw.Remove(secret);
|
||||
else if (c[0].Equals('1'))
|
||||
res = kw.SetSecret(secret,ConstStrings.OPERATION_ADD_SECRET);
|
||||
else if (c[0].Equals('2'))
|
||||
res = kw.SetSecret(secret,ConstStrings.OPERATION_MODIFY_SECRET);
|
||||
else if (c[0].Equals('3'))
|
||||
res = kw.SetSecret(secret);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.5.*")]
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
|
@ -127,7 +127,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
info = null;
|
||||
}
|
||||
return info;
|
||||
@ -139,15 +139,15 @@ namespace Novell.CASA.DataEngines.GK
|
||||
return;
|
||||
try
|
||||
{
|
||||
Console.WriteLine("lockOnIdle = " + info.lockOnIdle);
|
||||
Console.WriteLine("lockTimeout = " + info.lockTimeout);
|
||||
Console.WriteLine("mTime = " + info.mTime);
|
||||
Console.WriteLine("cTime = " + info.cTime);
|
||||
Console.WriteLine("isLocked = " + info.isLocked);
|
||||
//Console.WriteLine("lockOnIdle = " + info.lockOnIdle);
|
||||
//Console.WriteLine("lockTimeout = " + info.lockTimeout);
|
||||
//Console.WriteLine("mTime = " + info.mTime);
|
||||
//Console.WriteLine("cTime = " + info.cTime);
|
||||
//Console.WriteLine("isLocked = " + info.isLocked);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
info = null;
|
||||
}
|
||||
return info;
|
||||
@ -193,15 +193,15 @@ namespace Novell.CASA.DataEngines.GK
|
||||
return;
|
||||
try
|
||||
{
|
||||
Console.WriteLine("CS : itemType = " + info.itemType);
|
||||
Console.WriteLine("CS : displayName = " + info.displayName);
|
||||
Console.WriteLine("CS : secret = " + info.secret);
|
||||
Console.WriteLine("CS : mTime = " + info.mTime);
|
||||
Console.WriteLine("CS : cTime = " + info.cTime);
|
||||
//Console.WriteLine("CS : itemType = " + info.itemType);
|
||||
//Console.WriteLine("CS : displayName = " + info.displayName);
|
||||
//Console.WriteLine("CS : secret = " + info.secret);
|
||||
//Console.WriteLine("CS : mTime = " + info.mTime);
|
||||
//Console.WriteLine("CS : cTime = " + info.cTime);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
@ -253,7 +253,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
@ -293,7 +293,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
@ -310,14 +310,14 @@ namespace Novell.CASA.DataEngines.GK
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
attr = (Attribute)(etor.Current);
|
||||
Console.WriteLine("CS : AttrType = " + attr.type);
|
||||
Console.WriteLine("CS : AttrKey = " + attr.key);
|
||||
Console.WriteLine("CS : AttrValue = " + attr.value);
|
||||
//Console.WriteLine("CS : AttrType = " + attr.type);
|
||||
//Console.WriteLine("CS : AttrKey = " + attr.key);
|
||||
//Console.WriteLine("CS : AttrValue = " + attr.value);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
|
||||
public static int CreateSecret(String keyringName, string strItemType, string displayName, string password, NameValueCollection nvc)
|
||||
{
|
||||
Console.WriteLine("In CreateSecret ");
|
||||
//Console.WriteLine("In CreateSecret ");
|
||||
int itemType = 3; //No Type
|
||||
IntPtr[] arrptr = new IntPtr[nvc.Count];
|
||||
if(strItemType.CompareTo("Generic Secret") == 0 )
|
||||
@ -368,13 +368,13 @@ namespace Novell.CASA.DataEngines.GK
|
||||
{
|
||||
itemType = 2;
|
||||
}
|
||||
Console.WriteLine("In CreateSecret ItemType = "+itemType);
|
||||
//Console.WriteLine("In CreateSecret ItemType = "+itemType);
|
||||
for(int i=0; i < nvc.Count; i++)
|
||||
{
|
||||
string key = nvc.GetKey(i);
|
||||
Console.WriteLine("In CreateSecret Key "+i + " = " + key);
|
||||
//Console.WriteLine("In CreateSecret Key "+i + " = " + key);
|
||||
string value = nvc.Get(key);
|
||||
Console.WriteLine("In CreateSecret Value "+i + " = " + value);
|
||||
//Console.WriteLine("In CreateSecret Value "+i + " = " + value);
|
||||
Attribute attr = new Attribute();
|
||||
attr.type=0;
|
||||
attr.key=key;
|
||||
@ -383,7 +383,7 @@ namespace Novell.CASA.DataEngines.GK
|
||||
Marshal.StructureToPtr(attr,ptr,false);
|
||||
arrptr[i] = ptr;
|
||||
}
|
||||
Console.WriteLine("Calling Create item ");
|
||||
//Console.WriteLine("Calling Create item ");
|
||||
int ret = CreateItem(keyringName, itemType, displayName, password, arrptr, nvc.Count);
|
||||
FreeIntPtrArray(arrptr);
|
||||
return ret;
|
||||
|
@ -51,14 +51,14 @@ CreateItemInKeyring(char *keyring, int32_t itemType, char *display_name, char *s
|
||||
OperationCompleted cbData;
|
||||
|
||||
int i;
|
||||
printf("ad.gk.c : CreateItemInKeyring : Keyring %s, itemType %d displayname %s, secret %s \n",keyring,itemType, display_name,secret);
|
||||
//printf("ad.gk.c : CreateItemInKeyring : Keyring %s, itemType %d displayname %s, secret %s \n",keyring,itemType, display_name,secret);
|
||||
cbData.OperationName = "Create Item";
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
attributes = gnome_keyring_attribute_list_new ();
|
||||
for (i=0; i< attrcnt; i++)
|
||||
{
|
||||
printf("as.gk.c : CreateItemInKeyring : In key %s \n", attrs[i]->key);
|
||||
//printf("as.gk.c : CreateItemInKeyring : In key %s \n", attrs[i]->key);
|
||||
attribute.name = g_strdup (attrs[i]->key);
|
||||
attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
|
||||
attribute.value.string = g_strdup (attrs[i]->value);
|
||||
@ -332,15 +332,15 @@ SetItemAttributes (char *keyring, guint32 itemid, Attribute **attrs, int length)
|
||||
GnomeKeyringAttribute attribute;
|
||||
OperationCompleted cbData;
|
||||
int i;
|
||||
printf("ad_gk.c : In SetItemAttributes\n");
|
||||
printf("ad_gk.c : Keyring %s, itemid %d\n",keyring,itemid);
|
||||
//printf("ad_gk.c : In SetItemAttributes\n");
|
||||
//printf("ad_gk.c : Keyring %s, itemid %d\n",keyring,itemid);
|
||||
cbData.OperationName = "Set Item Attributes";
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
attributes = gnome_keyring_attribute_list_new ();
|
||||
for (i=0; i< length; i++)
|
||||
{
|
||||
printf("ad_gk.c : In key %s \n", attrs[i]->key);
|
||||
//printf("ad_gk.c : In key %s \n", attrs[i]->key);
|
||||
attribute.name = g_strdup (attrs[i]->key);
|
||||
attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
|
||||
attribute.value.string = g_strdup (attrs[i]->value);
|
||||
|
@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.5.*")]
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
|
@ -65,14 +65,13 @@ public class kwallet
|
||||
{
|
||||
return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen ));
|
||||
}
|
||||
|
||||
|
||||
public static int SetSecret(string walletName, string folderName, string keyName, NameValueCollection nvc)
|
||||
{
|
||||
|
||||
//IntPtr[] mapele = new IntPtr[nvc.Count * 2];
|
||||
String[,] mapele = new String[nvc.Count,2 ];
|
||||
String str=" ";
|
||||
|
||||
int j=0;
|
||||
for (int i=0; i< nvc.Count; i++)
|
||||
{
|
||||
mapele[i,0] = nvc.GetKey(i);
|
||||
@ -81,52 +80,9 @@ public class kwallet
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
for (int i=0; i< nvc.Count; i++)
|
||||
{
|
||||
str = String.Concat(str,nvc.GetKey(i));
|
||||
str = String.Concat(str, "\0");
|
||||
str = String.Concat(str,nvc.Get(nvc.GetKey(i)));
|
||||
str = String.Concat(str, "\0");
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
char[] strarr = str.ToCharArray();
|
||||
|
||||
/*for (int i=0; i< nvc.Count; i++)
|
||||
{
|
||||
|
||||
string strKey = nvc.GetKey(i);
|
||||
Console.WriteLine("Key is " + strKey);
|
||||
//IntPtr ptr1 = Marshal.AllocHGlobal(strKey.Length);
|
||||
//Marshal.StructureToPtr(strKey,ptr1,false);
|
||||
|
||||
IntPtr ptr1 = Marshal.StringToHGlobalAnsi(strKey);
|
||||
string strValue = nvc.Get(strKey);
|
||||
//IntPtr ptr2 = Marshal.AllocHGlobal(strValue.Length);
|
||||
//Marshal.StructureToPtr(strValue,ptr2,false);
|
||||
IntPtr ptr2 = Marshal.StringToHGlobalAnsi(strValue);
|
||||
Console.WriteLine("Value is " + strValue);
|
||||
//IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(kv));
|
||||
// Marshal.StructureToPtr(kv,ptr,false);
|
||||
mapele[j++] = ptr1;
|
||||
Console.WriteLine("Pointer is " +ptr1);
|
||||
mapele[j++] = ptr2;
|
||||
Console.WriteLine("Pointer is " +ptr2);
|
||||
}
|
||||
*/
|
||||
//IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(mapele));
|
||||
//Marshal.StructureToPtr(mapele,ptr,false);
|
||||
|
||||
/*string[] str = {"a","bb","ccc"};
|
||||
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(str));
|
||||
Marshal.StructureToPtr(str,ptr,false);
|
||||
*/
|
||||
/*Console.WriteLine("Setting Map Entry Keys name is " + keyName); */
|
||||
return(SetMapEntry(walletName, folderName, keyName, mapele, nvc.Count));
|
||||
}
|
||||
|
||||
public static int DeleteSecret(string walletName, string folderName, string keyName)
|
||||
{
|
||||
return(RemoveEntry(walletName, folderName, keyName));
|
||||
|
@ -47,7 +47,7 @@ using namespace KWallet;
|
||||
|
||||
// Read the secret from the entry
|
||||
QByteArray value;
|
||||
printf("kwallet: Read Key entered\n");
|
||||
//printf("kwallet: Read Key entered\n");
|
||||
|
||||
if (wallet->readEntry(key, value)==0)
|
||||
{
|
||||
@ -103,13 +103,13 @@ using namespace KWallet;
|
||||
|
||||
} else
|
||||
{
|
||||
printf("Could not read the entry..inner IF\n");
|
||||
//printf("Could not read the entry..inner IF\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
printf("Could not read the entry Inside wallet->readkey\n");
|
||||
//printf("Could not read the entry Inside wallet->readkey\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,11 @@ namespace Novell.CASA.DataEngines
|
||||
return false;
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
return SetSecret(secret);
|
||||
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user