Copy feature added. Users can copy secrets from one store to another.

This commit is contained in:
Jim Norman 2006-10-12 22:28:20 +00:00
parent 2589b94ba9
commit 30617fb4c2
9 changed files with 15476 additions and 14503 deletions

View File

@ -1,3 +1,10 @@
Thu Oct 12 16:26:13 MDT 2006 - jnorman@novell.com
- Copy feature added. Users can copy secrets from one store
to another.
-------------------------------------------------------------------
Wed Oct 11 15:29:13 IST 2006 - smanojna@novell.com
- Some fixes for Distribution of Firefox Password Manager secrets.

View File

@ -84,11 +84,13 @@ public class Common
public static int MAX_STORES = 10;
public static string STORENAME_MICASA = "miCASA",
public static string STORENAME_MICASA = "miCASA",
STORENAME_FIREFOX = "Firefox",
STORENAME_MOZILLA = "Mozilla",
STORENAME_KDEWALLET = "KDE Wallet",
STORENAME_GNOMEKEYRING = "GNOME Keyring";
public static string[] saStoreNameList = {"miCASA", "Firefox", "Mozilla", "KDE Wallet", "GNOME Keyring"};
///##############################################################

288
CASA/gui/CopySecret.cs Normal file
View File

@ -0,0 +1,288 @@
using System;
using System.Text;
using System.Collections;
using Gtk;
using Glade;
namespace Novell.CASA.GUI
{
/// <summary>
/// Summary description for CopySecret.
/// </summary>
public class CopySecret
{
#region Glade Widgets
[Glade.Widget]
Gtk.Dialog dialogCopySecret;
[Glade.Widget]
Gtk.CheckButton checkbuttonMiCASA,
checkbuttonFPM,
checkbuttonMPM,
checkbuttonKDE,
checkbuttonGNOME;
[Glade.Widget]
Gtk.Entry
entryMiCASA,
entryFPM,
entryMPM,
entryKDE,
entryGNOME;
[Glade.Widget]
Gtk.Label
labelMiCASA,
labelFPM,
labelMPM,
labelKDE,
labelGNOME;
#endregion
private string m_sSecretID = "http://www.novell.com";
private string[] m_saKeys;
private string[] m_saValues;
public CopySecret(string sSrcSecretID, string[] saKeys, string[] saValues)
{
m_sSecretID = sSrcSecretID;
m_saKeys = saKeys;
m_saValues = saValues;
}
public void Show()
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogCopySecret", null);
gxmlTemp.Autoconnect (this);
InitDialog();
dialogCopySecret.Show();
}
private void InitDialog()
{
if (Common.IS_MICASA)
{
checkbuttonMiCASA.Visible = checkbuttonMiCASA.Sensitive = Common.IS_MICASA_AVAILABLE;
checkbuttonMiCASA.Toggled += new EventHandler(checkbuttonMiCASA_Toggled);
labelMiCASA.Visible = entryMiCASA.Visible = Common.IS_MICASA_AVAILABLE;
if (m_sSecretID.StartsWith("http:"))
entryMiCASA.Text = m_sSecretID.Substring(7);
else
entryMiCASA.Text = m_sSecretID;
}
if (Common.IS_FIREFOX)
{
checkbuttonFPM.Visible = checkbuttonFPM.Sensitive = Common.IS_FIREFOX_AVAILABLE;
checkbuttonFPM.Toggled += new EventHandler(checkbuttonFPM_Toggled);
labelFPM.Visible = entryFPM.Visible = Common.IS_FIREFOX_AVAILABLE;
if (!m_sSecretID.StartsWith("http:"))
entryFPM.Text = "http://"+m_sSecretID;
else
entryFPM.Text = m_sSecretID;
}
if (Common.IS_MOZILLA)
{
checkbuttonMPM.Visible = checkbuttonMPM.Sensitive = Common.IS_MOZILLA_AVAILABLE;
checkbuttonMPM.Toggled += new EventHandler(checkbuttonMPM_Toggled);
labelMPM.Visible = entryMPM.Visible = Common.IS_MOZILLA_AVAILABLE;
entryMPM.Text = m_sSecretID;
}
if (Common.IS_KDEWALLET)
{
checkbuttonKDE.Visible = checkbuttonKDE.Sensitive = Common.IS_KDEWALLET_AVAILABLE;
checkbuttonKDE.Toggled += new EventHandler(checkbuttonKDE_Toggled);
labelKDE.Visible = entryKDE.Visible = Common.IS_KDEWALLET_AVAILABLE;
entryKDE.Text = m_sSecretID;
}
if (Common.IS_GNOMEKEYRING)
{
checkbuttonGNOME.Visible = checkbuttonGNOME.Sensitive = Common.IS_GNOMEKEYRING_AVAILABLE;
checkbuttonGNOME.Toggled += new EventHandler(checkbuttonGNOME_Toggled);
labelGNOME.Visible = entryGNOME.Visible = Common.IS_GNOMEKEYRING_AVAILABLE;
entryGNOME.Text = m_sSecretID;
}
}
public void on_buttonCopyCancel_clicked(object obj, EventArgs args)
{
if (dialogCopySecret != null)
{
dialogCopySecret.Destroy();
}
}
public void on_buttonCopyOK_clicked(object obj, EventArgs args)
{
StringBuilder sb = new StringBuilder();
// copy to micasa
if ((checkbuttonMiCASA.Active) && (entryMiCASA.Text.Length > 0))
{
sb.Append(DoCopy(entryMiCASA.Text, Common.STORE_MICASA));
sb.Append("\r\n");
}
// copy to Firefox
if ((checkbuttonFPM.Active) && (entryFPM.Text.Length > 0))
{
sb.Append(DoCopy(entryFPM.Text, Common.STORE_FIREFOX));
sb.Append("\r\n");
}
// copy to Mozilla
if ((checkbuttonMPM.Active) && (entryMPM.Text.Length > 0))
{
sb.Append(DoCopy(entryMPM.Text, Common.STORE_MOZILLA));
sb.Append("\r\n");
}
// copy to kde wallet
if ((checkbuttonKDE.Active) && entryKDE.Text.Length > 0)
{
sb.Append(DoCopy(entryKDE.Text, Common.STORE_KDEWALLET));
sb.Append("\r\n");
}
// copy to GNOME keyring
if ((checkbuttonGNOME.Active) && entryGNOME.Text.Length > 0)
{
sb.Append(DoCopy(entryGNOME.Text, Common.STORE_GNOMEKEYRING));
sb.Append("\r\n");
}
if (sb.Length > 0)
{
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Copy to ...\r\n" + sb.ToString());
}
else
{
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "No stores selected");
}
if (dialogCopySecret != null)
{
dialogCopySecret.Destroy();
}
}
private void checkbuttonMiCASA_Toggled(object sender, EventArgs e)
{
entryMiCASA.Sensitive = checkbuttonMiCASA.Active;
}
private void checkbuttonFPM_Toggled(object sender, EventArgs e)
{
entryFPM.Sensitive = checkbuttonFPM.Active;
}
private void checkbuttonMPM_Toggled(object sender, EventArgs e)
{
entryMPM.Sensitive = checkbuttonMPM.Active;
}
private void checkbuttonKDE_Toggled(object sender, EventArgs e)
{
entryKDE.Sensitive = checkbuttonKDE.Active;
}
private void checkbuttonGNOME_Toggled(object sender, EventArgs e)
{
entryGNOME.Sensitive = checkbuttonGNOME.Active;
}
private string DoCopy(string sNewSecretName, int iTargetStore)
{
Logger.DbgLog("GUI:CopySecret.DoCopy() - BEGIN");
TreeModel model;
TreeIter iter;
TreeModel modelSecret;
TreeIter iterSecret, iterKey;
string[] NativeKeys = null,
NativeValues = null;
try
{
NativeKeys = new string[Common.MAX_NATIVE_ELEMENTS];
NativeValues = new string[Common.MAX_NATIVE_ELEMENTS];
NativeKeys[Common.INDEX_NATIVEINFO_FOLDERNAME] = Common.NATIVEINFO_FOLDERNAME;
NativeKeys[Common.INDEX_NATIVEINFO_TYPEID] = Common.NATIVEINFO_TYPEID;
NativeKeys[Common.INDEX_NATIVEINFO_SYNC] = Common.NATIVEINFO_SYNC;
NativeKeys[Common.INDEX_NATIVEINFO_SYNCTYPE] = Common.NATIVEINFO_SYNCTYPE;
NativeKeys[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = Common.NATIVEINFO_MODIFIEDTIME;
NativeValues[Common.INDEX_NATIVEINFO_FOLDERNAME] = null;
if (iTargetStore == Common.STORE_FIREFOX)
{
NativeValues[Common.INDEX_NATIVEINFO_TYPEID] = "Signon";
}
else if (iTargetStore == Common.STORE_GNOMEKEYRING)
{
NativeValues[Common.INDEX_NATIVEINFO_TYPEID] = "Network Password";
}
else
{
NativeValues[Common.INDEX_NATIVEINFO_TYPEID] = null;
}
NativeValues[Common.INDEX_NATIVEINFO_SYNC] = null;
NativeValues[Common.INDEX_NATIVEINFO_SYNCTYPE] = null;
NativeValues[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = null;
TreeStore tsTargetSecret;
TreeView tvTargetSecret = new TreeView();
if (iTargetStore == Common.STORE_FIREFOX)
{
ArrayList arrIsPassword = new ArrayList();
for (int i=0; i<m_saKeys.Length; i++)
{
if (m_saKeys[i].ToLower().IndexOf("pass") > -1)
arrIsPassword.Add(true);
else
arrIsPassword.Add(false);
}
bool[] IsPassword = (bool[])arrIsPassword.ToArray(typeof(bool));
tsTargetSecret = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]), typeof(bool[]));
iterSecret = tsTargetSecret.AppendValues(sNewSecretName, m_saKeys, m_saValues, DataEngines.AD.GetDefaultProfileName(Common.STORE_FIREFOX), NativeKeys, NativeValues, IsPassword);
}
else
{
tsTargetSecret = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
iterSecret = tsTargetSecret.AppendValues(sNewSecretName, m_saKeys, m_saValues, "Default", NativeKeys, NativeValues);
}
modelSecret = tvTargetSecret.Model = tsTargetSecret;
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(iTargetStore, Common.OPERATION_ADD_SECRET, "", "", ref modelSecret, ref iterSecret) )
{
return Common.saStoreNameList[iTargetStore] + " Success";
}
else
{
return Common.saStoreNameList[iTargetStore] + " Failed";
}
}
catch (Exception e)
{
return (Common.saStoreNameList[iTargetStore] + " : " + e.ToString());
}
}
}
}

View File

@ -222,8 +222,8 @@ public class Firefox : Store
if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() )
{
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = true;
cmiLink.Sensitive = cmiCopy.Sensitive = false;
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiCopy.Sensitive = true;
cmiLink.Sensitive = false;
}
else
{
@ -1210,8 +1210,31 @@ public class Firefox : Store
/// </summary>
public void OnCopyActivated(object obj, EventArgs args)
{
TreeModel model;
TreeIter iter;
try
{
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
{
string selected = null;
string[] saKeys, saValues;
selected = (string) model.GetValue (iter, 0);
saKeys = (string[]) model.GetValue(iter, 1);
saValues = (string[]) model.GetValue(iter, 2);
CopySecret cs = new CopySecret(selected, saKeys, saValues);
cs.Show();
}
}
catch
{
}
}
///#######################################################################
/// VALIDATE STRINGS FOR SPECIAL CHARACTERS

View File

@ -243,7 +243,10 @@ public class GnomeKeyring : Store
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
if( 0 != tvSecretIDGnomeKeyring.Selection.CountSelectedRows() )
cmiLink.Sensitive = cmiCopy.Sensitive = false;
{
cmiLink.Sensitive = false;
cmiCopy.Sensitive = true;
}
else
cmiNewKey.Sensitive = cmiView.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
}
@ -929,6 +932,23 @@ public class GnomeKeyring : Store
/// </summary>
public void OnCopyActivated(object obj, EventArgs args)
{
Logger.DbgLog("GUI:GnomeKeyring.OnCopyActivated() - BEGIN");
if( 0 != tvSecretIDGnomeKeyring.Selection.CountSelectedRows() )
{
TreeModel model;
TreeIter iter;
string selected = null;
if( tvSecretIDGnomeKeyring.Selection.GetSelected (out model, out iter) )
{
selected = (string) model.GetValue (iter, 0);
string[] saKeys = (string[]) model.GetValue(iter, 1);
string[] saValues = (string[]) model.GetValue(iter, 2);
CopySecret cs = new CopySecret(selected, saKeys, saValues);
cs.Show();
}
}
Logger.DbgLog("GUI:GnomeKeyring.OnCopyActivated() - END");
}

View File

@ -242,7 +242,10 @@ public class KdeWallet : Store
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
if( 0 != tvSecretIDKdeWallet.Selection.CountSelectedRows() )
cmiLink.Sensitive = cmiCopy.Sensitive = false;
{
cmiLink.Sensitive = false;
cmiCopy.Sensitive = true;
}
else
cmiNewKey.Sensitive = cmiView.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
}
@ -926,7 +929,23 @@ public class KdeWallet : Store
/// </summary>
public void OnCopyActivated(object obj, EventArgs args)
{
Logger.DbgLog("GUI:KdeWallet.OnCopyActivated() - BEGIN");
if( 0 != tvSecretIDKdeWallet.Selection.CountSelectedRows() )
{
TreeModel model;
TreeIter iter;
string selected = null;
if( tvSecretIDKdeWallet.Selection.GetSelected (out model, out iter) )
{
selected = (string) model.GetValue (iter, 0);
string[] saKeys = (string[]) model.GetValue(iter, 1);
string[] saValues = (string[]) model.GetValue(iter, 2);
CopySecret cs = new CopySecret(selected, saKeys, saValues);
cs.Show();
}
}
Logger.DbgLog("GUI:KdeWallet.OnCopyActivated() - END");
}

View File

@ -60,6 +60,7 @@ MODULE_EXT =exe
CSFILES =$(srcdir)/AssemblyInfo.cs \
$(srcdir)/CasaMain.cs \
$(srcdir)/CasaTray.cs \
$(srcdir)/CopySecret.cs \
$(srcdir)/DbgFileChooser.cs \
$(srcdir)/TrayLib.cs \
$(srcdir)/ExportSecrets.cs \

View File

@ -240,7 +240,7 @@ public class MiCasa : Store
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
if( 0 != tvSecretIDMiCasa.Selection.CountSelectedRows() )
cmiCopy.Sensitive = false;
cmiCopy.Sensitive = true;
else
cmiNewKey.Sensitive = cmiView.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
}
@ -957,7 +957,29 @@ public class MiCasa : Store
/// </summary>
public void OnCopyActivated(object obj, EventArgs args)
{
Logger.DbgLog("GUI:MiCasa.OnCopyActivated() - BEGIN");
if( 0 != tvSecretIDMiCasa.Selection.CountSelectedRows() )
{
TreeModel model;
TreeIter iter;
string selected = null;
string[] saKeys, saValues;
if( tvSecretIDMiCasa.Selection.GetSelected (out model, out iter) )
{
selected = (string) model.GetValue (iter, 0);
if (selected.StartsWith("SS_CredSet"))
selected = selected.Substring(11);
saKeys = (string[]) model.GetValue(iter, 1);
saValues = (string[]) model.GetValue(iter, 2);
CopySecret cs = new CopySecret(selected, saKeys, saValues);
cs.Show();
}
}
}
public void on_helpbuttonLinkKeys_clicked(object obj, EventArgs args)

File diff suppressed because it is too large Load Diff