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

@ -101,15 +101,22 @@ namespace Novell.CASA.DataEngines
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);
XmlElement valueElem = doc.CreateElement(ConstStrings.CCF_VALUE); if ((itemInfo.secret != null) && (itemInfo.secret.Length != 0))
valueElem.InnerText = itemInfo.secret; {
keyElem.AppendChild(valueElem); keyElem = doc.CreateElement(ConstStrings.CCF_KEY);
secretElem.AppendChild(keyElem); keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
keyIdAttr.Value = "GKPassword";
keyElem.SetAttributeNode(keyIdAttr);
valueElem = doc.CreateElement(ConstStrings.CCF_VALUE);
valueElem.InnerText = itemInfo.secret;
keyElem.AppendChild(valueElem);
secretElem.AppendChild(keyElem);
}
IEnumerator attrEtor = (IEnumerator)(attrList.GetEnumerator()); IEnumerator attrEtor = (IEnumerator)(attrList.GetEnumerator());
while(attrEtor.MoveNext()) while(attrEtor.MoveNext())
@ -192,7 +199,7 @@ namespace Novell.CASA.DataEngines
public int SetSecret(XmlNode secret, int opnType) public int SetSecret(XmlNode secret, int opnType)
{ {
string password = null; string password = "";
int retValue; int retValue;
try try
@ -226,24 +233,22 @@ namespace Novell.CASA.DataEngines
return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC)); return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC));
} }
//Modify secret Opn
if ( password != null) //Modify secret Opn
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
if (retValue != 0)
{ {
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
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)
@ -284,6 +289,26 @@ namespace Novell.CASA.DataEngines
} }
} }
public static Boolean IsStoreAvailable()
{
try
{
System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(GnomeKeyring));
return true;
}
catch(DllNotFoundException d)
{
Console.WriteLine("Store Not Available Exception = " + d.ToString());
return false;
}
catch(Exception e)
{
Console.WriteLine("Store Not Available Exception = " + e.ToString());
return false;
}
}
int ExtractSecretId(XmlNode secret) int ExtractSecretId(XmlNode secret)
{ {
XmlAttributeCollection atcol = secret.Attributes; XmlAttributeCollection atcol = secret.Attributes;
@ -352,7 +377,8 @@ namespace Novell.CASA.DataEngines
Console.WriteLine("* 3. Set secret *"); Console.WriteLine("* 3. Set secret *");
Console.WriteLine("* 4. Remove secret *"); Console.WriteLine("* 4. Remove secret *");
Console.WriteLine("* 5. Refresh *"); Console.WriteLine("* 5. Refresh *");
Console.WriteLine("* 6. Quit *"); Console.WriteLine("* 6. Is Store Avail *");
Console.WriteLine("* 7. 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");
@ -365,8 +391,13 @@ 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('6')) if (c[0].Equals('7'))
return; return;
if (c[0].Equals('6'))
{
Console.WriteLine("Store Available is = " + GKEngine.IsStoreAvailable());
return;
}
if (c[0].Equals('5')) if (c[0].Equals('5'))
{ {
XmlNode node = gk.Aggregate (); XmlNode node = gk.Aggregate ();
@ -383,13 +414,14 @@ namespace Novell.CASA.DataEngines
XmlTextReader tr = new XmlTextReader("/root/gktest.xml"); XmlTextReader tr = new XmlTextReader("/root/gktest.xml");
tr.Read(); tr.Read();
xmlDoc.Load(tr); xmlDoc.Load(tr);
XmlNode root = xmlDoc.FirstChild; XmlNode root = xmlDoc.LastChild;
if (root == null) if (root == null)
{ {
Console.WriteLine("Root is 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')) if (c[0].Equals('4'))
res =gk.Remove(secret); res =gk.Remove(secret);
else if (c[0].Equals('1')) else if (c[0].Equals('1'))

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");
@ -659,7 +656,6 @@ public class GnomeKeyring : Store
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 = "";