- Added support for ADD/MODIFY/DELETE functionalities for Keyring and

Kwallet stores in A-Dlib.
.....................................................................
This commit is contained in:
smanojna 2006-01-06 11:57:25 +00:00
parent b8aedf332e
commit f610a50037
12 changed files with 231 additions and 204 deletions

View File

@ -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) public int SetSecret(XmlNode secret, int StoreID)
{ {
if (StoreID == ConstStrings.CASA_STORE_MICASA) 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) public int Remove(XmlNode secret, int StoreID)
{ {
@ -278,7 +377,7 @@ namespace Novell.CASA.DataEngines
} }
else else
{ {
Console.WriteLine("KWallet some issue"); //Console.WriteLine("KWallet some issue");
return ConstStrings.CASA_STORE_NOT_AVAILABLE; return ConstStrings.CASA_STORE_NOT_AVAILABLE;
} }

View File

@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // 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 // In order to sign your assembly you must specify a key to use. Refer to the

View File

@ -160,21 +160,26 @@ namespace Novell.CASA.DataEngines
return doc.ChildNodes[0]; return doc.ChildNodes[0];
} }
public int SetSecret(XmlNode secret) public int SetSecret(XmlNode secret)
{
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
}
public int SetSecret(XmlNode secret, int opnType)
{ {
string password = null; string password = null;
int retValue; int retValue;
try try
{ {
Console.WriteLine("In SetSecret Name = "+ secret.Name);
int itemid = ExtractSecretId(secret); int itemid = ExtractSecretId(secret);
string keyringname = ExtractKeyringName(secret); string keyringname = ExtractKeyringName(secret);
NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection(); NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection();
XmlNodeList keylist = secret.SelectNodes("descendant::Key"); XmlNodeList keylist = secret.SelectNodes("descendant::Key");
Console.WriteLine("In SetSecret");
foreach (XmlNode tuple in keylist) foreach (XmlNode tuple in keylist)
{ {
//Get the Key //Get the Key
@ -190,36 +195,42 @@ namespace Novell.CASA.DataEngines
newNVC.Add(keyname, tuple.ChildNodes[0].InnerText); 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 strItemType = ExtractItemType(secret);
string secretName = ExtractSecretName(secret); string secretName = ExtractSecretName(secret, opnType);
return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC)); return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC));
} }
//Modify secret Opn //Modify secret Opn
if ( password != null) if ( password != null)
{ {
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password); retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
if (retValue != 0) if (retValue != 0)
{ {
return retValue; return retValue;
} }
} }
if (newNVC.Count != 0) if (newNVC.Count != 0)
{ {
return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC)); return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC));
} }
return 0; return 0;
} }
catch(NullReferenceException n) 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; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
} }
catch(Exception e) 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; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
} }
} }
@ -228,6 +239,7 @@ namespace Novell.CASA.DataEngines
{ {
return ConstStrings.CASA_SUCCESS; return ConstStrings.CASA_SUCCESS;
} }
public int Remove(XmlNode secret) public int Remove(XmlNode secret)
{ {
try try
@ -238,13 +250,13 @@ namespace Novell.CASA.DataEngines
} }
catch(NullReferenceException n) 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; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
} }
catch(Exception e) 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; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
} }
} }
@ -253,13 +265,12 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol = secret.Attributes; XmlAttributeCollection atcol = secret.Attributes;
String secretid = atcol["ID"].InnerXml; String secretid = atcol["ID"].InnerXml;
Console.WriteLine("In Extract Secret Id");
//Check if itemId is present //Check if itemId is present
if (secretid.EndsWith(":")) /*if (secretid.EndsWith(":"))
{ {
Console.WriteLine("In Extract Secret Id : Add Opn");
return -2; return -2;
} }
*/
int itemIdx = secretid.LastIndexOf(":"); int itemIdx = secretid.LastIndexOf(":");
if (itemIdx == -1) if (itemIdx == -1)
{ {
@ -269,14 +280,18 @@ namespace Novell.CASA.DataEngines
return itemid; return itemid;
} }
string ExtractSecretName(XmlNode secret) string ExtractSecretName(XmlNode secret, int opnType)
{ {
XmlAttributeCollection atcol = secret.Attributes; XmlAttributeCollection atcol = secret.Attributes;
String secretid = atcol["ID"].InnerXml; 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(":"); int itemIdx = secretid.LastIndexOf(":");
Console.WriteLine("Extracting Secret Name Last Index Of : = " + itemIdx); //Return substring without itemId
//Check if itemId is present
return(secretid.Substring(0,itemIdx)); return(secretid.Substring(0,itemIdx));
} }
@ -284,7 +299,6 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
XmlNode parentNode = secret.ParentNode; XmlNode parentNode = secret.ParentNode;
Console.WriteLine("In Extract Keyring Name");
atcol = parentNode.Attributes; atcol = parentNode.Attributes;
String keyringname = atcol["ID"].InnerXml; String keyringname = atcol["ID"].InnerXml;
return keyringname; return keyringname;
@ -295,7 +309,6 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol = secret.Attributes; XmlAttributeCollection atcol = secret.Attributes;
String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml; String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml;
Console.WriteLine("In ExtractItemType");
return(itemType); return(itemType);
} }
@ -306,16 +319,17 @@ namespace Novell.CASA.DataEngines
{ {
Console.WriteLine("Hello there");
GKEngine gk = new GKEngine(); GKEngine gk = new GKEngine();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("********** Menu ***********"); Console.WriteLine("********** Menu ***********");
Console.WriteLine("* 1. Set secret *"); Console.WriteLine("* 1. Add secret *");
Console.WriteLine("* 2. Remove secret *"); Console.WriteLine("* 2. Modify secret *");
Console.WriteLine("* 3. Refresh *"); Console.WriteLine("* 3. Set secret *");
Console.WriteLine("* 4. Quit *"); Console.WriteLine("* 4. Remove secret *");
Console.WriteLine("* 5. Refresh *");
Console.WriteLine("* 6. Quit *");
Console.WriteLine("***************************"); Console.WriteLine("***************************");
Console.WriteLine("For all options the input is the file /root/gktest.xml"); 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(); char[] c = line.Substring(0, 1).ToCharArray();
if (c.Length > 0) if (c.Length > 0)
{ {
if (c[0].Equals('4')) if (c[0].Equals('6'))
return; return;
if (c[0].Equals('3')) if (c[0].Equals('5'))
{ {
XmlNode node = gk.Aggregate (); XmlNode node = gk.Aggregate ();
XmlDocument doc = node.OwnerDocument; XmlDocument doc = node.OwnerDocument;
@ -351,22 +365,17 @@ namespace Novell.CASA.DataEngines
{ {
Console.WriteLine("Root is null"); 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('4'))
if (c[0].Equals('2'))
res =gk.Remove(secret); res =gk.Remove(secret);
else if (c[0].Equals('1')) 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); res = gk.SetSecret(secret);
} }
} }
} }

View File

@ -17,6 +17,8 @@ namespace Novell.CASA.DataEngines
int GetSecret(XmlNode secret); int GetSecret(XmlNode secret);
int SetSecret(XmlNode secret, int opnType);
int SetSecret(XmlNode secret); int SetSecret(XmlNode secret);
int Remove(XmlNode secret); int Remove(XmlNode secret);

View File

@ -188,9 +188,10 @@ namespace Novell.CASA.DataEngines
idattr.Value = secid; idattr.Value = secid;
Secret.SetAttributeNode(idattr); Secret.SetAttributeNode(idattr);
XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE); /*XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
typeAttr.Value = entryType; typeAttr.Value = entryType;
Secret.SetAttributeNode(typeAttr); 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) public int SetSecret(XmlNode secret)
{ {
try try
{ {
string walletName = ExtractWalletName(secret); string walletName = ExtractWalletName(secret);
string folderName = ExtractFolderName(secret); string folderName = ExtractFolderName(secret);
string keyName = ExtractKeyName(secret); string keyName = ExtractKeyName(secret);
int secretType = ExtractSecretType(secret); int secretType = ExtractSecretType(secret);
if (secretType != 3) //Type not Map if (secretType != 3) //Type not Map
{ {
string value = secret.ChildNodes[0].ChildNodes[0].InnerText; //Secret.Key.Value string value = secret.ChildNodes[0].ChildNodes[0].InnerText; //Secret.Key.Value
return(kwallet.SetSecret(walletName, folderName, secretType, keyName, value, value.Length)); return(kwallet.SetSecret(walletName, folderName, secretType, keyName, value, value.Length));
} }
else //If type is Map else //If type is Map
{ {
NameValueCollection nvc = new NameValueCollection(); NameValueCollection nvc = new NameValueCollection();
for (int i =0; i< secret.ChildNodes.Count; i++) for (int i =0; i< secret.ChildNodes.Count; i++)
{ {
XmlNode key = secret.ChildNodes[i]; XmlNode key = secret.ChildNodes[i];
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
atcol = key.Attributes; atcol = key.Attributes;
String keyMapName = atcol["ID"].InnerXml; String keyMapName = atcol["ID"].InnerXml;
Console.WriteLine("Map Ele KeyName = " + keyMapName);
string value = key.ChildNodes[0].InnerText; //Secret.Key.Value string value = key.ChildNodes[0].InnerText; //Secret.Key.Value
Console.WriteLine("Map Ele Value = " + value);
nvc.Add(keyMapName,value); nvc.Add(keyMapName,value);
} }
return(kwallet.SetSecret(walletName, folderName,keyName,nvc)); return(kwallet.SetSecret(walletName, folderName,keyName,nvc));
} }
} }
catch(NullReferenceException n) 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; return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
} }
catch(Exception e) 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; 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; 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) public int Remove(XmlNode secret)
{ {
try try
@ -395,7 +362,6 @@ namespace Novell.CASA.DataEngines
string walletName = ExtractWalletName(secret); string walletName = ExtractWalletName(secret);
string folderName = ExtractFolderName(secret); string folderName = ExtractFolderName(secret);
string keyName = ExtractKeyName(secret); string keyName = ExtractKeyName(secret);
int secretType = ExtractSecretType(secret);
int res = kwallet.DeleteSecret(walletName, folderName, keyName); int res = kwallet.DeleteSecret(walletName, folderName, keyName);
if (res == 0) if (res == 0)
{ {
@ -406,13 +372,13 @@ namespace Novell.CASA.DataEngines
} }
catch(NullReferenceException n) 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; return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
} }
catch(Exception e) 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; return (int)KWalletResult.KWALLET_RESULT_UNKNOWN_ERROR;
} }
} }
@ -421,10 +387,8 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
XmlNode parentNode = secret.ParentNode.ParentNode.ParentNode; XmlNode parentNode = secret.ParentNode.ParentNode.ParentNode;
Console.WriteLine("In Extract Wallet Name ");
atcol = parentNode.Attributes; atcol = parentNode.Attributes;
String walletname = atcol["ID"].InnerXml; String walletname = atcol["ID"].InnerXml;
Console.WriteLine("In Extract Wallet Name Wallet Name = " + walletname);
return walletname; return walletname;
} }
@ -432,20 +396,16 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
XmlNode parentNode = secret.ParentNode.ParentNode; //Folder.Type.Secret XmlNode parentNode = secret.ParentNode.ParentNode; //Folder.Type.Secret
Console.WriteLine("In Extract Folder Name ");
atcol = parentNode.Attributes; atcol = parentNode.Attributes;
String foldername = atcol["Name"].InnerXml; String foldername = atcol["Name"].InnerXml;
Console.WriteLine("In Extract Folder Name Folder Name = " + foldername);
return foldername; return foldername;
} }
string ExtractKeyName(XmlNode secret) string ExtractKeyName(XmlNode secret)
{ {
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
Console.WriteLine("In Extract Key Name ");
atcol = secret.Attributes; atcol = secret.Attributes;
String keyname = atcol["ID"].InnerXml; String keyname = atcol["ID"].InnerXml;
Console.WriteLine("In Extract Key Name Key Name = " + keyname);
return keyname; return keyname;
} }
@ -453,10 +413,8 @@ namespace Novell.CASA.DataEngines
{ {
XmlAttributeCollection atcol; XmlAttributeCollection atcol;
XmlNode parentNode = secret.ParentNode; //Type.Secret XmlNode parentNode = secret.ParentNode; //Type.Secret
Console.WriteLine("In Extract Entry Type ");
atcol = parentNode.Attributes; atcol = parentNode.Attributes;
String entryType = atcol["ID"].InnerXml; String entryType = atcol["ID"].InnerXml;
Console.WriteLine("In Extract Entry Type = " + entryType);
if (entryType.CompareTo("Passwords")== 0) if (entryType.CompareTo("Passwords")== 0)
{ {
return 1; return 1;
@ -476,16 +434,17 @@ namespace Novell.CASA.DataEngines
#if TEST #if TEST
public static void Main() public static void Main()
{ {
Console.WriteLine("Hello there");
KWalletEngine kw = new KWalletEngine(); KWalletEngine kw = new KWalletEngine();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("********** Menu ***********"); Console.WriteLine("********** Menu ***********");
Console.WriteLine("* 1. Set secret *"); Console.WriteLine("* 1. Add secret *");
Console.WriteLine("* 2. Remove secret *"); Console.WriteLine("* 2. Modify secret *");
Console.WriteLine("* 3. Refresh *"); Console.WriteLine("* 3. Set secret *");
Console.WriteLine("* 4. Quit *"); Console.WriteLine("* 4. Remove secret *");
Console.WriteLine("* 5. Refresh *");
Console.WriteLine("* 6. Quit *");
Console.WriteLine("***************************"); Console.WriteLine("***************************");
Console.WriteLine("For all options the input is the file /root/kwtest.xml"); 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(); char[] c = line.Substring(0, 1).ToCharArray();
if (c.Length > 0) if (c.Length > 0)
{ {
if (c[0].Equals('4')) if (c[0].Equals('6'))
return; return;
if (c[0].Equals('3')) if (c[0].Equals('5'))
kw.Aggregate (); kw.Aggregate ();
else else
{ {
@ -516,17 +475,15 @@ namespace Novell.CASA.DataEngines
{ {
Console.WriteLine("Root is null"); 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]; 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); res =kw.Remove(secret);
else if (c[0].Equals('1')) 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); res = kw.SetSecret(secret);
} }
} }

View File

@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // 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 // In order to sign your assembly you must specify a key to use. Refer to the

View File

@ -127,7 +127,7 @@ namespace Novell.CASA.DataEngines.GK
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
info = null; info = null;
} }
return info; return info;
@ -139,15 +139,15 @@ namespace Novell.CASA.DataEngines.GK
return; return;
try try
{ {
Console.WriteLine("lockOnIdle = " + info.lockOnIdle); //Console.WriteLine("lockOnIdle = " + info.lockOnIdle);
Console.WriteLine("lockTimeout = " + info.lockTimeout); //Console.WriteLine("lockTimeout = " + info.lockTimeout);
Console.WriteLine("mTime = " + info.mTime); //Console.WriteLine("mTime = " + info.mTime);
Console.WriteLine("cTime = " + info.cTime); //Console.WriteLine("cTime = " + info.cTime);
Console.WriteLine("isLocked = " + info.isLocked); //Console.WriteLine("isLocked = " + info.isLocked);
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
} }
} }
@ -181,7 +181,7 @@ namespace Novell.CASA.DataEngines.GK
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
info = null; info = null;
} }
return info; return info;
@ -193,15 +193,15 @@ namespace Novell.CASA.DataEngines.GK
return; return;
try try
{ {
Console.WriteLine("CS : itemType = " + info.itemType); //Console.WriteLine("CS : itemType = " + info.itemType);
Console.WriteLine("CS : displayName = " + info.displayName); //Console.WriteLine("CS : displayName = " + info.displayName);
Console.WriteLine("CS : secret = " + info.secret); //Console.WriteLine("CS : secret = " + info.secret);
Console.WriteLine("CS : mTime = " + info.mTime); //Console.WriteLine("CS : mTime = " + info.mTime);
Console.WriteLine("CS : cTime = " + info.cTime); //Console.WriteLine("CS : cTime = " + info.cTime);
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
} }
} }
@ -226,7 +226,7 @@ namespace Novell.CASA.DataEngines.GK
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
retList = null; retList = null;
} }
return retList; return retList;
@ -253,7 +253,7 @@ namespace Novell.CASA.DataEngines.GK
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
retList = null; retList = null;
} }
return retList; return retList;
@ -293,7 +293,7 @@ namespace Novell.CASA.DataEngines.GK
} }
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
retList = null; retList = null;
} }
return retList; return retList;
@ -310,14 +310,14 @@ namespace Novell.CASA.DataEngines.GK
while(etor.MoveNext()) while(etor.MoveNext())
{ {
attr = (Attribute)(etor.Current); attr = (Attribute)(etor.Current);
Console.WriteLine("CS : AttrType = " + attr.type); //Console.WriteLine("CS : AttrType = " + attr.type);
Console.WriteLine("CS : AttrKey = " + attr.key); //Console.WriteLine("CS : AttrKey = " + attr.key);
Console.WriteLine("CS : AttrValue = " + attr.value); //Console.WriteLine("CS : AttrValue = " + attr.value);
} }
} }
catch(Exception e) 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) 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 int itemType = 3; //No Type
IntPtr[] arrptr = new IntPtr[nvc.Count]; IntPtr[] arrptr = new IntPtr[nvc.Count];
if(strItemType.CompareTo("Generic Secret") == 0 ) if(strItemType.CompareTo("Generic Secret") == 0 )
@ -368,13 +368,13 @@ namespace Novell.CASA.DataEngines.GK
{ {
itemType = 2; itemType = 2;
} }
Console.WriteLine("In CreateSecret ItemType = "+itemType); //Console.WriteLine("In CreateSecret ItemType = "+itemType);
for(int i=0; i < nvc.Count; i++) for(int i=0; i < nvc.Count; i++)
{ {
string key = nvc.GetKey(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); string value = nvc.Get(key);
Console.WriteLine("In CreateSecret Value "+i + " = " + value); //Console.WriteLine("In CreateSecret Value "+i + " = " + value);
Attribute attr = new Attribute(); Attribute attr = new Attribute();
attr.type=0; attr.type=0;
attr.key=key; attr.key=key;
@ -383,7 +383,7 @@ namespace Novell.CASA.DataEngines.GK
Marshal.StructureToPtr(attr,ptr,false); Marshal.StructureToPtr(attr,ptr,false);
arrptr[i] = ptr; arrptr[i] = ptr;
} }
Console.WriteLine("Calling Create item "); //Console.WriteLine("Calling Create item ");
int ret = CreateItem(keyringName, itemType, displayName, password, arrptr, nvc.Count); int ret = CreateItem(keyringName, itemType, displayName, password, arrptr, nvc.Count);
FreeIntPtrArray(arrptr); FreeIntPtrArray(arrptr);
return ret; return ret;

View File

@ -51,14 +51,14 @@ CreateItemInKeyring(char *keyring, int32_t itemType, char *display_name, char *s
OperationCompleted cbData; OperationCompleted cbData;
int i; 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"; cbData.OperationName = "Create Item";
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
attributes = gnome_keyring_attribute_list_new (); attributes = gnome_keyring_attribute_list_new ();
for (i=0; i< attrcnt; i++) 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.name = g_strdup (attrs[i]->key);
attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING; attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
attribute.value.string = g_strdup (attrs[i]->value); attribute.value.string = g_strdup (attrs[i]->value);
@ -332,15 +332,15 @@ SetItemAttributes (char *keyring, guint32 itemid, Attribute **attrs, int length)
GnomeKeyringAttribute attribute; GnomeKeyringAttribute attribute;
OperationCompleted cbData; OperationCompleted cbData;
int i; int i;
printf("ad_gk.c : In SetItemAttributes\n"); //printf("ad_gk.c : In SetItemAttributes\n");
printf("ad_gk.c : Keyring %s, itemid %d\n",keyring,itemid); //printf("ad_gk.c : Keyring %s, itemid %d\n",keyring,itemid);
cbData.OperationName = "Set Item Attributes"; cbData.OperationName = "Set Item Attributes";
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
attributes = gnome_keyring_attribute_list_new (); attributes = gnome_keyring_attribute_list_new ();
for (i=0; i< length; i++) 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.name = g_strdup (attrs[i]->key);
attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING; attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
attribute.value.string = g_strdup (attrs[i]->value); attribute.value.string = g_strdup (attrs[i]->value);

View File

@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // 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 // In order to sign your assembly you must specify a key to use. Refer to the

View File

@ -65,14 +65,13 @@ public class kwallet
{ {
return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen )); return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen ));
} }
public static int SetSecret(string walletName, string folderName, string keyName, NameValueCollection nvc) 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[,] mapele = new String[nvc.Count,2 ];
String str=" ";
int j=0;
for (int i=0; i< nvc.Count; i++) for (int i=0; i< nvc.Count; i++)
{ {
mapele[i,0] = nvc.GetKey(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)); return(SetMapEntry(walletName, folderName, keyName, mapele, nvc.Count));
} }
public static int DeleteSecret(string walletName, string folderName, string keyName) public static int DeleteSecret(string walletName, string folderName, string keyName)
{ {
return(RemoveEntry(walletName, folderName, keyName)); return(RemoveEntry(walletName, folderName, keyName));

View File

@ -47,7 +47,7 @@ using namespace KWallet;
// Read the secret from the entry // Read the secret from the entry
QByteArray value; QByteArray value;
printf("kwallet: Read Key entered\n"); //printf("kwallet: Read Key entered\n");
if (wallet->readEntry(key, value)==0) if (wallet->readEntry(key, value)==0)
{ {
@ -103,13 +103,13 @@ using namespace KWallet;
} else } else
{ {
printf("Could not read the entry..inner IF\n"); //printf("Could not read the entry..inner IF\n");
return -1; return -1;
} }
} else } else
{ {
printf("Could not read the entry Inside wallet->readkey\n"); //printf("Could not read the entry Inside wallet->readkey\n");
return -1; return -1;
} }

View File

@ -151,7 +151,11 @@ namespace Novell.CASA.DataEngines
return false; return false;
} }
public int SetSecret(XmlNode secret, int opnType)
{
return SetSecret(secret);
}
public int SetSecret(XmlNode secret) public int SetSecret(XmlNode secret)
{ {