Bug 142183. Do not add GKPassword to gnome-keyring. Provided by Manohar

This commit is contained in:
Jim Norman 2006-01-25 21:24:37 +00:00
parent 85b8d6d5ff
commit ada9ed5d86
3 changed files with 431 additions and 397 deletions

View File

@ -1,8 +1,14 @@
-------------------------------------------------------------------
Wed Jan 25 14:18:52 MST 2006 - jnorman@novell.com
- Bug 142183. Do not add GKPassword to gnome-keyring
Provided by Manohar
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jan 25 14:12:52 MST 2006 - jnorman@novell.com Wed Jan 25 14:12:52 MST 2006 - jnorman@novell.com
- Bug 136784. Prevent multiple instances of GUI - Bug 136784. Prevent multiple instances of GUI
Provided by Manojna Provided by Manohar
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jan 25 21:43:52 CET 2006 - mls@suse.de Wed Jan 25 21:43:52 CET 2006 - mls@suse.de

View File

@ -21,391 +21,423 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Xml; using System.Xml;
using System.IO; using System.IO;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Novell.CASA.DataEngines.Common; using Novell.CASA.DataEngines.Common;
using Novell.CASA.DataEngines.GK; using Novell.CASA.DataEngines.GK;
namespace Novell.CASA.DataEngines namespace Novell.CASA.DataEngines
{ {
/* /*
* This class is implementation of Data engine for Gnome-Keyring. * This class is implementation of Data engine for Gnome-Keyring.
*/ */
class GKEngine : DataEngine class GKEngine : DataEngine
{ {
enum KeyringResultExtended { enum KeyringResultExtended {
GNOME_KEYRING_RESULT_NO_SUCH_ITEM = 128, GNOME_KEYRING_RESULT_NO_SUCH_ITEM = 128,
GNOME_KEYRING_RESULT_CANNOT_DELETE_SECRET_VALUE, GNOME_KEYRING_RESULT_CANNOT_DELETE_SECRET_VALUE,
GNOME_KEYRING_RESULT_MALFORMED_XML, GNOME_KEYRING_RESULT_MALFORMED_XML,
GNOME_KEYRING_RESULT_CANNOT_CREATE_KEYRING, GNOME_KEYRING_RESULT_CANNOT_CREATE_KEYRING,
GNOME_KEYRING_RESULT_ERROR_UNKNOWN GNOME_KEYRING_RESULT_ERROR_UNKNOWN
}; };
public GKEngine() public GKEngine()
{ {
} }
public XmlNode Aggregate() public XmlNode Aggregate()
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
XmlNode rootElem = doc.CreateElement(ConstStrings.CCF_GKTAG); XmlNode rootElem = doc.CreateElement(ConstStrings.CCF_GKTAG);
doc.AppendChild(rootElem); doc.AppendChild(rootElem);
XmlElement keyringElem; XmlElement keyringElem;
ArrayList itemList; ArrayList itemList;
ArrayList attrList; ArrayList attrList;
ItemInfo itemInfo; ItemInfo itemInfo;
KeyringInfo keyringInfo; KeyringInfo keyringInfo;
int itemId; int itemId;
ArrayList keyringList = GnomeKeyring.GKGetKeyrings(); ArrayList keyringList = GnomeKeyring.GKGetKeyrings();
IEnumerator kEtor = keyringList.GetEnumerator(); IEnumerator kEtor = keyringList.GetEnumerator();
IEnumerator iEtor; IEnumerator iEtor;
while(kEtor.MoveNext()) while(kEtor.MoveNext())
{ {
string keyring = (string)(kEtor.Current); string keyring = (string)(kEtor.Current);
keyringElem = doc.CreateElement(ConstStrings.CCF_GKKEYRING); keyringElem = doc.CreateElement(ConstStrings.CCF_GKKEYRING);
XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID); XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
idAttr.Value = keyring; idAttr.Value = keyring;
keyringElem.SetAttributeNode(idAttr); keyringElem.SetAttributeNode(idAttr);
keyringInfo = GnomeKeyring.GKGetKeyringInfo(keyring); keyringInfo = GnomeKeyring.GKGetKeyringInfo(keyring);
itemList = GnomeKeyring.GKGetItems(keyring); itemList = GnomeKeyring.GKGetItems(keyring);
iEtor = itemList.GetEnumerator(); iEtor = itemList.GetEnumerator();
while(iEtor.MoveNext()) while(iEtor.MoveNext())
{ {
itemId = (int)iEtor.Current; itemId = (int)iEtor.Current;
itemInfo = GnomeKeyring.GKGetItemInfo(keyring,itemId); itemInfo = GnomeKeyring.GKGetItemInfo(keyring,itemId);
attrList = GnomeKeyring.GKGetAttributeList(keyring,itemId); attrList = GnomeKeyring.GKGetAttributeList(keyring,itemId);
XmlElement secretElem = doc.CreateElement(ConstStrings.CCF_SECRET); XmlElement secretElem = doc.CreateElement(ConstStrings.CCF_SECRET);
XmlAttribute secIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID); XmlAttribute secIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
secIdAttr.Value = itemInfo.displayName + ":" + itemId; secIdAttr.Value = itemInfo.displayName + ":" + itemId;
secretElem.SetAttributeNode(secIdAttr); secretElem.SetAttributeNode(secIdAttr);
XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE); XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
typeAttr.Value = itemInfo.itemType.ToString(); typeAttr.Value = itemInfo.itemType.ToString();
secretElem.SetAttributeNode(typeAttr); secretElem.SetAttributeNode(typeAttr);
XmlElement keyElem = doc.CreateElement(ConstStrings.CCF_KEY); XmlElement keyElem = null;
XmlAttribute keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID); XmlAttribute keyIdAttr = null;
keyIdAttr.Value = "GKPassword"; XmlElement valueElem = null;
keyElem.SetAttributeNode(keyIdAttr);
if ((itemInfo.secret != null) && (itemInfo.secret.Length != 0))
XmlElement valueElem = doc.CreateElement(ConstStrings.CCF_VALUE); {
valueElem.InnerText = itemInfo.secret; keyElem = doc.CreateElement(ConstStrings.CCF_KEY);
keyElem.AppendChild(valueElem); keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
secretElem.AppendChild(keyElem); keyIdAttr.Value = "GKPassword";
keyElem.SetAttributeNode(keyIdAttr);
IEnumerator attrEtor = (IEnumerator)(attrList.GetEnumerator());
while(attrEtor.MoveNext()) valueElem = doc.CreateElement(ConstStrings.CCF_VALUE);
{ valueElem.InnerText = itemInfo.secret;
Novell.CASA.DataEngines.GK.Attribute attr = (Novell.CASA.DataEngines.GK.Attribute)(attrEtor.Current); keyElem.AppendChild(valueElem);
keyElem = doc.CreateElement(ConstStrings.CCF_KEY); secretElem.AppendChild(keyElem);
keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID); }
keyIdAttr.Value = attr.key;
keyElem.SetAttributeNode(keyIdAttr); IEnumerator attrEtor = (IEnumerator)(attrList.GetEnumerator());
while(attrEtor.MoveNext())
valueElem = doc.CreateElement(ConstStrings.CCF_VALUE); {
valueElem.InnerText = attr.value; Novell.CASA.DataEngines.GK.Attribute attr = (Novell.CASA.DataEngines.GK.Attribute)(attrEtor.Current);
keyElem.AppendChild(valueElem); keyElem = doc.CreateElement(ConstStrings.CCF_KEY);
secretElem.AppendChild(keyElem); keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
} keyIdAttr.Value = attr.key;
keyElem.SetAttributeNode(keyIdAttr);
keyringElem.AppendChild(secretElem);
XmlElement timeElem = doc.CreateElement(ConstStrings.CCF_TIME); valueElem = doc.CreateElement(ConstStrings.CCF_VALUE);
valueElem.InnerText = attr.value;
XmlElement itemCreatedTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME); keyElem.AppendChild(valueElem);
itemCreatedTimeElem.InnerText = itemInfo.mTime.ToString(); secretElem.AppendChild(keyElem);
timeElem.AppendChild(itemCreatedTimeElem); }
XmlElement itemModifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME); keyringElem.AppendChild(secretElem);
itemModifiedTimeElem.InnerText = itemInfo.cTime.ToString(); XmlElement timeElem = doc.CreateElement(ConstStrings.CCF_TIME);
timeElem.AppendChild(itemModifiedTimeElem);
XmlElement itemCreatedTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME);
secretElem.AppendChild(timeElem); itemCreatedTimeElem.InnerText = itemInfo.mTime.ToString();
} timeElem.AppendChild(itemCreatedTimeElem);
XmlElement keyringTimeElem = doc.CreateElement(ConstStrings.CCF_TIME);
XmlElement itemModifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME);
XmlElement createdTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME); itemModifiedTimeElem.InnerText = itemInfo.cTime.ToString();
createdTimeElem.InnerText = keyringInfo.mTime.ToString(); timeElem.AppendChild(itemModifiedTimeElem);
keyringTimeElem.AppendChild(createdTimeElem);
secretElem.AppendChild(timeElem);
XmlElement modifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME); }
modifiedTimeElem.InnerText = keyringInfo.cTime.ToString(); XmlElement keyringTimeElem = doc.CreateElement(ConstStrings.CCF_TIME);
keyringTimeElem.AppendChild(modifiedTimeElem);
XmlElement createdTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME);
keyringElem.AppendChild(keyringTimeElem); createdTimeElem.InnerText = keyringInfo.mTime.ToString();
keyringTimeElem.AppendChild(createdTimeElem);
XmlElement lockElem = doc.CreateElement(ConstStrings.CCF_LOCK);
XmlElement modifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME);
XmlAttribute lockStatusAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKSTATUS); modifiedTimeElem.InnerText = keyringInfo.cTime.ToString();
if( keyringInfo.isLocked == 1 ) keyringTimeElem.AppendChild(modifiedTimeElem);
lockStatusAttr.Value = "locked";
else keyringElem.AppendChild(keyringTimeElem);
lockStatusAttr.Value = "unlocked";
lockElem.SetAttributeNode(lockStatusAttr); XmlElement lockElem = doc.CreateElement(ConstStrings.CCF_LOCK);
XmlAttribute lockOnIdleAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKHAND); XmlAttribute lockStatusAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKSTATUS);
if( keyringInfo.lockOnIdle == 1) if( keyringInfo.isLocked == 1 )
lockOnIdleAttr.Value = "true"; lockStatusAttr.Value = "locked";
else else
lockOnIdleAttr.Value = "false"; lockStatusAttr.Value = "unlocked";
lockElem.SetAttributeNode(lockOnIdleAttr); lockElem.SetAttributeNode(lockStatusAttr);
XmlAttribute lockTimeoutAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKTIME); XmlAttribute lockOnIdleAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKHAND);
lockTimeoutAttr.Value = keyringInfo.lockTimeout.ToString(); if( keyringInfo.lockOnIdle == 1)
lockElem.SetAttributeNode(lockTimeoutAttr); lockOnIdleAttr.Value = "true";
else
keyringElem.AppendChild(lockElem); lockOnIdleAttr.Value = "false";
rootElem.AppendChild(keyringElem); lockElem.SetAttributeNode(lockOnIdleAttr);
}
#if TEST XmlAttribute lockTimeoutAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKTIME);
XmlTextWriter writer = new XmlTextWriter("./gk.xml",null); lockTimeoutAttr.Value = keyringInfo.lockTimeout.ToString();
writer.Formatting = Formatting.Indented; lockElem.SetAttributeNode(lockTimeoutAttr);
doc.Save(writer);
writer.Close(); keyringElem.AppendChild(lockElem);
#endif rootElem.AppendChild(keyringElem);
}
return doc.ChildNodes[0]; #if TEST
} XmlTextWriter writer = new XmlTextWriter("./gk.xml",null);
writer.Formatting = Formatting.Indented;
public int SetSecret(XmlNode secret) doc.Save(writer);
{ writer.Close();
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN; #endif
}
return doc.ChildNodes[0];
}
public int SetSecret(XmlNode secret, int opnType)
{ public int SetSecret(XmlNode secret)
string password = null; {
int retValue; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
}
try
{
int itemid = ExtractSecretId(secret); public int SetSecret(XmlNode secret, int opnType)
string keyringname = ExtractKeyringName(secret); {
string password = "";
NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection(); int retValue;
XmlNodeList keylist = secret.SelectNodes("descendant::Key"); try
foreach (XmlNode tuple in keylist) {
{ int itemid = ExtractSecretId(secret);
//Get the Key string keyringname = ExtractKeyringName(secret);
XmlAttributeCollection at = tuple.Attributes;
String keyname = (at["ID"]).InnerText; NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection();
if (keyname.Equals("GKPassword"))
{ XmlNodeList keylist = secret.SelectNodes("descendant::Key");
password = tuple.ChildNodes[0].InnerText; foreach (XmlNode tuple in keylist)
{
} //Get the Key
else XmlAttributeCollection at = tuple.Attributes;
{ String keyname = (at["ID"]).InnerText;
newNVC.Add(keyname, tuple.ChildNodes[0].InnerText); if (keyname.Equals("GKPassword"))
} {
} password = tuple.ChildNodes[0].InnerText;
if (opnType == ConstStrings.OPERATION_ADD_SECRET ) //Add Item Opn
{ }
else
string strItemType = ExtractItemType(secret); {
string secretName = ExtractSecretName(secret, opnType); newNVC.Add(keyname, tuple.ChildNodes[0].InnerText);
}
return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC)); }
} if (opnType == ConstStrings.OPERATION_ADD_SECRET ) //Add Item Opn
//Modify secret Opn {
if ( password != null) string strItemType = ExtractItemType(secret);
{ string secretName = ExtractSecretName(secret, opnType);
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password); return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC));
if (retValue != 0) }
{
//Modify secret Opn
return retValue; retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
}
} if (retValue != 0)
{
if (newNVC.Count != 0)
{ return retValue;
}
return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC));
} if (newNVC.Count != 0)
return 0; {
}
catch(NullReferenceException n) return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC));
{ }
//Console.WriteLine("Exception in SetSecret = "+n.ToString());
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML; return 0;
} }
catch(Exception e) catch(NullReferenceException n)
{ {
//Console.WriteLine("Exception in SetSecret = "+e.ToString()); //Console.WriteLine("Exception in SetSecret = "+n.ToString());
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN; return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
} }
} catch(Exception e)
{
public int GetSecret(XmlNode secret) //Console.WriteLine("Exception in SetSecret = "+e.ToString());
{ return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
return ConstStrings.CASA_SUCCESS; }
} }
public int Remove(XmlNode secret) public int GetSecret(XmlNode secret)
{ {
try return ConstStrings.CASA_SUCCESS;
{ }
int itemid = ExtractSecretId(secret);
string keyringname = ExtractKeyringName(secret); public int Remove(XmlNode secret)
return (GnomeKeyring.RemoveItem( keyringname, itemid)); {
} try
catch(NullReferenceException n) {
{ int itemid = ExtractSecretId(secret);
//Console.WriteLine("Exception in Remove = "+n.ToString()); string keyringname = ExtractKeyringName(secret);
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML; return (GnomeKeyring.RemoveItem( keyringname, itemid));
} }
catch(Exception e) catch(NullReferenceException n)
{ {
//Console.WriteLine("Exception in Remove = "+n.ToString());
//Console.WriteLine("Exception in Remove = "+e.ToString()); return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN; }
} catch(Exception e)
} {
int ExtractSecretId(XmlNode secret) //Console.WriteLine("Exception in Remove = "+e.ToString());
{ return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
XmlAttributeCollection atcol = secret.Attributes; }
String secretid = atcol["ID"].InnerXml; }
//Check if itemId is present
/*if (secretid.EndsWith(":")) public static Boolean IsStoreAvailable()
{ {
return -2; try
} {
*/ System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(GnomeKeyring));
int itemIdx = secretid.LastIndexOf(":"); return true;
if (itemIdx == -1) }
{ catch(DllNotFoundException d)
return -1; {
} Console.WriteLine("Store Not Available Exception = " + d.ToString());
int itemid = Convert.ToInt32(secretid.Substring(itemIdx + 1)); return false;
return itemid; }
} catch(Exception e)
{
string ExtractSecretName(XmlNode secret, int opnType) Console.WriteLine("Store Not Available Exception = " + e.ToString());
{ return false;
XmlAttributeCollection atcol = secret.Attributes; }
String secretid = atcol["ID"].InnerXml; }
if (opnType == ConstStrings.OPERATION_ADD_SECRET)
{ int ExtractSecretId(XmlNode secret)
return secretid; //Not expecting an item Id {
XmlAttributeCollection atcol = secret.Attributes;
} String secretid = atcol["ID"].InnerXml;
int itemIdx = secretid.LastIndexOf(":"); //Check if itemId is present
//Return substring without itemId /*if (secretid.EndsWith(":"))
return(secretid.Substring(0,itemIdx)); {
} return -2;
}
string ExtractKeyringName(XmlNode secret) */
{ int itemIdx = secretid.LastIndexOf(":");
XmlAttributeCollection atcol; if (itemIdx == -1)
XmlNode parentNode = secret.ParentNode; {
atcol = parentNode.Attributes; return -1;
String keyringname = atcol["ID"].InnerXml; }
return keyringname; int itemid = Convert.ToInt32(secretid.Substring(itemIdx + 1));
} return itemid;
}
string ExtractItemType(XmlNode secret) string ExtractSecretName(XmlNode secret, int opnType)
{ {
XmlAttributeCollection atcol = secret.Attributes; XmlAttributeCollection atcol = secret.Attributes;
String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml; String secretid = atcol["ID"].InnerXml;
return(itemType);
} if (opnType == ConstStrings.OPERATION_ADD_SECRET)
{
return secretid; //Not expecting an item Id
#if TEST }
public static void Main() int itemIdx = secretid.LastIndexOf(":");
{ //Return substring without itemId
return(secretid.Substring(0,itemIdx));
}
GKEngine gk = new GKEngine();
string ExtractKeyringName(XmlNode secret)
{
Console.WriteLine(); XmlAttributeCollection atcol;
Console.WriteLine("********** Menu ***********"); XmlNode parentNode = secret.ParentNode;
Console.WriteLine("* 1. Add secret *"); atcol = parentNode.Attributes;
Console.WriteLine("* 2. Modify secret *"); String keyringname = atcol["ID"].InnerXml;
Console.WriteLine("* 3. Set secret *"); return keyringname;
Console.WriteLine("* 4. Remove secret *"); }
Console.WriteLine("* 5. Refresh *");
Console.WriteLine("* 6. Quit *");
Console.WriteLine("***************************"); string ExtractItemType(XmlNode secret)
Console.WriteLine("For all options the input is the file /root/gktest.xml"); {
XmlAttributeCollection atcol = secret.Attributes;
Console.WriteLine("Select option and Press enter"); String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml;
String line = Console.ReadLine(); return(itemType);
int res = 0; }
if (line.Length > 0)
{
char[] c = line.Substring(0, 1).ToCharArray(); #if TEST
if (c.Length > 0) public static void Main()
{ {
if (c[0].Equals('6'))
return;
if (c[0].Equals('5')) GKEngine gk = new GKEngine();
{
XmlNode node = gk.Aggregate ();
XmlDocument doc = node.OwnerDocument; Console.WriteLine();
XmlTextWriter writer = new XmlTextWriter("/root/gktest.xml",null); Console.WriteLine("********** Menu ***********");
writer.Formatting = Formatting.Indented; Console.WriteLine("* 1. Add secret *");
doc.Save(writer); Console.WriteLine("* 2. Modify secret *");
writer.Close(); Console.WriteLine("* 3. Set secret *");
} Console.WriteLine("* 4. Remove secret *");
else Console.WriteLine("* 5. Refresh *");
{ Console.WriteLine("* 6. Is Store Avail *");
Console.WriteLine("* 7. Quit *");
XmlDocument xmlDoc = new XmlDocument(); Console.WriteLine("***************************");
XmlTextReader tr = new XmlTextReader("/root/gktest.xml"); Console.WriteLine("For all options the input is the file /root/gktest.xml");
tr.Read();
xmlDoc.Load(tr); Console.WriteLine("Select option and Press enter");
XmlNode root = xmlDoc.FirstChild; String line = Console.ReadLine();
if (root == null) int res = 0;
{
Console.WriteLine("Root is null"); if (line.Length > 0)
} {
char[] c = line.Substring(0, 1).ToCharArray();
if (c.Length > 0)
if (c[0].Equals('4')) {
res =gk.Remove(secret); if (c[0].Equals('7'))
else if (c[0].Equals('1')) return;
res = gk.SetSecret(secret, ConstStrings.OPERATION_ADD_SECRET); if (c[0].Equals('6'))
else if (c[0].Equals('2')) {
res = gk.SetSecret(secret, ConstStrings.OPERATION_MODIFY_SECRET); Console.WriteLine("Store Available is = " + GKEngine.IsStoreAvailable());
else if (c[0].Equals('3')) return;
res = gk.SetSecret(secret); }
if (c[0].Equals('5'))
} {
} XmlNode node = gk.Aggregate ();
} XmlDocument doc = node.OwnerDocument;
Console.WriteLine("Result of Operation = " + res); XmlTextWriter writer = new XmlTextWriter("/root/gktest.xml",null);
writer.Formatting = Formatting.Indented;
} doc.Save(writer);
#endif writer.Close();
}
} else
} {
XmlDocument xmlDoc = new XmlDocument();
XmlTextReader tr = new XmlTextReader("/root/gktest.xml");
tr.Read();
xmlDoc.Load(tr);
XmlNode root = xmlDoc.LastChild;
if (root == null)
{
Console.WriteLine("Root is null");
}
XmlNode secret = root.ChildNodes[0].ChildNodes[0];
Console.WriteLine("secret Name \n" + secret.Name);
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);
}
}
}
Console.WriteLine("Result of Operation = " + res);
}
#endif
}
}

View File

@ -412,7 +412,7 @@ public class GnomeKeyring : Store
TreeIter iterKey; TreeIter iterKey;
if(tvKeyValue.Selection.GetSelected (out modelKey, out iterKey)) if(tvKeyValue.Selection.GetSelected (out modelKey, out iterKey))
if( "GKPassword" != (string)tsKeyValue.GetValue(iterKey,0) && false == (bool)tsKeyValue.GetValue(iterKey,3) ) if( false == (bool)tsKeyValue.GetValue(iterKey,3) )
arrDeletedKeys.Add(tsKeyValue.GetValue(iterKey,0)); arrDeletedKeys.Add(tsKeyValue.GetValue(iterKey,0));
if( 0 != tvKeyValue.Selection.CountSelectedRows() ) if( 0 != tvKeyValue.Selection.CountSelectedRows() )
@ -421,11 +421,8 @@ public class GnomeKeyring : Store
TreeIter iter; TreeIter iter;
tvKeyValue.Selection.GetSelected (out model, out iter); tvKeyValue.Selection.GetSelected (out model, out iter);
if( "GKPassword" != (string)tsKeyValue.GetValue(iter,0) ) tsKeyValue.Remove(ref iter);
{ tvKeyValue.ColumnsAutosize();
tsKeyValue.Remove(ref iter);
tvKeyValue.ColumnsAutosize();
}
} }
Logger.DbgLog("GUI:GnomeKeyring.on_buttonNewRemove_clicked() - END"); Logger.DbgLog("GUI:GnomeKeyring.on_buttonNewRemove_clicked() - END");
@ -658,8 +655,7 @@ public class GnomeKeyring : Store
tvKeyValue.AppendColumn("Value",cellEditable,"text",2); tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Linked",new CellRendererText(),"text",4); tvKeyValue.AppendColumn("Linked",new CellRendererText(),"text",4);
tvKeyValue.Model = tsKeyValue; tvKeyValue.Model = tsKeyValue;
tsKeyValue.Clear(); tsKeyValue.Clear();
tsKeyValue.AppendValues("GKPassword", "novell", "********", true, "No");
entrySecretID.HasFocus = true; entrySecretID.HasFocus = true;
entrySecretID.Text = ""; entrySecretID.Text = "";