Alpha code for Secret Persistence Policy. In Progress.
This commit is contained in:
@@ -235,6 +235,16 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "PersistentPolicyDialog.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "PolicyDialog.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "SingleApplication.cs"
|
||||
SubType = "Code"
|
||||
|
||||
@@ -102,7 +102,9 @@ namespace Novell.CASA.GUI
|
||||
checkbuttonGnomeKeyring,
|
||||
checkbuttonKdeWallet,
|
||||
checkbuttonCloseMessage,
|
||||
checkbuttonRunInTray;
|
||||
checkbuttonRunInTray,
|
||||
checkbuttonSaveSecrets,
|
||||
checkbuttonDecrypt;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Label label88,
|
||||
@@ -829,6 +831,7 @@ namespace Novell.CASA.GUI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void on_entryFirefoxMP_activate(object obj, EventArgs args)
|
||||
{
|
||||
on_buttonFirefoxMPok_clicked(obj, args);
|
||||
@@ -1707,6 +1710,22 @@ namespace Novell.CASA.GUI
|
||||
config.WriteConfig();
|
||||
}
|
||||
|
||||
public void on_checkbuttonSaveSecrets_toggled(object obj, EventArgs args)
|
||||
{
|
||||
if (checkbuttonSaveSecrets.Active)
|
||||
{
|
||||
entryStorageDirectory.Sensitive = true;
|
||||
buttonChooseDirectory.Sensitive = true;
|
||||
checkbuttonDecrypt.Sensitive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entryStorageDirectory.Sensitive = false;
|
||||
buttonChooseDirectory.Sensitive = false;
|
||||
checkbuttonDecrypt.Sensitive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void okbuttonPreferences_clicked(object abj, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.okbuttonPreferences_clicked() - BEGIN");
|
||||
@@ -2133,7 +2152,7 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
//Choose directory for persistent storage
|
||||
FileChooser fc = new FileChooser(FileChooser.ACTION_CHOOSE_DIR);
|
||||
string sDirectory = fc.GetFile(entryStorageDirectory.Text, null);
|
||||
string sDirectory = fc.GetFile(entryStorageDirectory.Text, null, "*.casa");
|
||||
|
||||
// show the user the directory choosen
|
||||
if (sDirectory != null)
|
||||
@@ -2190,6 +2209,18 @@ namespace Novell.CASA.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void on_policies_activate(object obj, EventArgs args)
|
||||
{
|
||||
//Console.WriteLine("policy Activate");
|
||||
//PolicyDialog pd = new PolicyDialog();
|
||||
//pd.ShowDialog();
|
||||
|
||||
PersistentPolicyDialog ppd = new PersistentPolicyDialog();
|
||||
ppd.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ********************************************************************
|
||||
/// private void HandleQuit()
|
||||
@@ -2249,7 +2280,7 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
DbgFileChooser dbf = new DbgFileChooser();
|
||||
dbf.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
309
CASA/gui/PersistentPolicyDialog.cs
Normal file
309
CASA/gui/PersistentPolicyDialog.cs
Normal file
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
|
||||
using Novell.CASA;
|
||||
using Novell.CASA.CASAPolicy;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for PolicyDialog.
|
||||
/// </summary>
|
||||
public class PersistentPolicyDialog
|
||||
{
|
||||
|
||||
private TreeStore tsPersistentList = new TreeStore(typeof(string));
|
||||
private TreeStore tsNonPersistentList = new TreeStore(typeof(string));
|
||||
|
||||
private PersistencePol policy = null;
|
||||
private bool bChanged = false;
|
||||
|
||||
|
||||
#region Glade Widgets
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView tvPersistentList,
|
||||
tvNonPersistentList;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogPersistentPolicy;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button applybuttonPersistent,
|
||||
buttonMakeNonPersistent,
|
||||
buttonMakePersistent;
|
||||
|
||||
#endregion
|
||||
|
||||
public PersistentPolicyDialog()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
public void ShowDialog()
|
||||
{
|
||||
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogPersistentPolicy", null);
|
||||
gxmlTemp.Autoconnect(this);
|
||||
|
||||
activateMoveButtons(false, false);
|
||||
applybuttonPersistent.Sensitive = false;
|
||||
|
||||
// load store
|
||||
SecretStore ss = SecretStore.getInstance();
|
||||
StringCollection sc = ss.enumerateSecretIDs();
|
||||
StringEnumerator senum = sc.GetEnumerator();
|
||||
|
||||
// load policy
|
||||
policy = (PersistencePol)ICASAPol.GetPolicy(CASAPolType.PERSISTENCE_POL);
|
||||
if (policy == null)
|
||||
{
|
||||
policy = new PersistencePol("Platform", "PersistentPath_NOT USED", 10);
|
||||
}
|
||||
|
||||
while (senum.MoveNext())
|
||||
{
|
||||
string sSecretID = senum.Current;
|
||||
if (policy.GetSecretPolicy(sSecretID, "Persistent", true))
|
||||
{
|
||||
tsPersistentList.AppendValues(sSecretID);
|
||||
}
|
||||
else
|
||||
{
|
||||
//tsNonPersistentList.AppendValues(sSecretID);
|
||||
}
|
||||
}
|
||||
|
||||
// display non-persistent IDs
|
||||
ArrayList al = policy.GetNonpersistentSecretIDs();
|
||||
for (int i=0; i<al.Count; i++)
|
||||
{
|
||||
tsNonPersistentList.AppendValues((string)al[i]);
|
||||
}
|
||||
|
||||
|
||||
// set sortable
|
||||
tsPersistentList.SetSortColumnId(0, Gtk.SortType.Ascending);
|
||||
tsNonPersistentList.SetSortColumnId(0, Gtk.SortType.Ascending);
|
||||
|
||||
// add Columnts
|
||||
tvPersistentList.AppendColumn("Persistent Secrets", new CellRendererText(), "text", 0);
|
||||
tvPersistentList.Columns[0].Clickable = true;
|
||||
tvPersistentList.Columns[0].Clicked +=new EventHandler(PersistentPolicyDialog_Clicked);
|
||||
tvPersistentList.RowActivated +=new RowActivatedHandler(tvPersistentList_RowActivated);
|
||||
tvPersistentList.ButtonReleaseEvent += new ButtonReleaseEventHandler(tvPersistentList_ButtonReleaseEvent);
|
||||
|
||||
|
||||
tvNonPersistentList.AppendColumn("Non-Persistent Secrets", new CellRendererText(), "text", 0);
|
||||
tvNonPersistentList.Columns[0].Clickable = true;
|
||||
tvNonPersistentList.Columns[0].Clicked +=new EventHandler(NonPersistentPolicyDialog_Clicked);
|
||||
tvNonPersistentList.RowActivated +=new RowActivatedHandler(tvNonPeristentList_RowActivated);
|
||||
tvNonPersistentList.ButtonReleaseEvent +=new ButtonReleaseEventHandler(tvNonPersistentList_ButtonReleaseEvent);
|
||||
|
||||
|
||||
// hook up the model
|
||||
tvPersistentList.Model = tsPersistentList;
|
||||
tvNonPersistentList.Model = tsNonPersistentList;
|
||||
}
|
||||
|
||||
public void on_applybuttonPersistent_clicked(object obj, EventArgs args)
|
||||
{
|
||||
if (bChanged)
|
||||
{
|
||||
// enumerate ts, setting the policy for each secret
|
||||
TreeIter iter;
|
||||
|
||||
if(tsPersistentList.GetIterFirst(out iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
string secretID = (string)tsPersistentList.GetValue(iter,0);
|
||||
|
||||
// set policy
|
||||
if (policy != null)
|
||||
{
|
||||
policy.SetSecretPolicy(secretID, "Persistent", "True", "True");
|
||||
}
|
||||
}
|
||||
while( tsPersistentList.IterNext(ref iter) );
|
||||
}
|
||||
|
||||
if(tsNonPersistentList.GetIterFirst(out iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
string secretID = (string)tsNonPersistentList.GetValue(iter,0);
|
||||
|
||||
// set policy
|
||||
if (policy != null)
|
||||
{
|
||||
policy.SetSecretPolicy(secretID, "Persistent", "False", "True");
|
||||
}
|
||||
}
|
||||
while( tsNonPersistentList.IterNext(ref iter) );
|
||||
}
|
||||
|
||||
// save policy now
|
||||
ICASAPol.SetPolicy(policy);
|
||||
bChanged = false;
|
||||
applybuttonPersistent.Sensitive = false;
|
||||
activateMoveButtons(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void on_okbutton_clicked(object obj, EventArgs args)
|
||||
{
|
||||
if (bChanged)
|
||||
{
|
||||
on_applybuttonPersistent_clicked(obj, args);
|
||||
}
|
||||
|
||||
closeDialog();
|
||||
}
|
||||
|
||||
public void on_cancelbutton_clicked(object obj, EventArgs args)
|
||||
{
|
||||
closeDialog();
|
||||
}
|
||||
|
||||
private void closeDialog()
|
||||
{
|
||||
if (dialogPersistentPolicy != null)
|
||||
{
|
||||
dialogPersistentPolicy.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void tvPersistentList_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
MakeNonPersistent();
|
||||
}
|
||||
|
||||
private void MakeNonPersistent()
|
||||
{
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
String selected;
|
||||
|
||||
if( tvPersistentList.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue (iter, 0);
|
||||
tsNonPersistentList.AppendValues(selected);
|
||||
tsPersistentList.Remove(ref iter);
|
||||
bChanged = true;
|
||||
applybuttonPersistent.Sensitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void on_buttonMakeNonPersistent_clicked(object o, EventArgs args)
|
||||
{
|
||||
MakeNonPersistent();
|
||||
}
|
||||
|
||||
public void on_buttonMakePersistent_clicked(object o, EventArgs args)
|
||||
{
|
||||
MakePersistent();
|
||||
}
|
||||
|
||||
private void tvNonPeristentList_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
MakePersistent();
|
||||
}
|
||||
|
||||
private void MakePersistent()
|
||||
{
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
String selected;
|
||||
|
||||
if( tvNonPersistentList.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue (iter, 0);
|
||||
tsPersistentList.AppendValues(selected);
|
||||
tsNonPersistentList.Remove(ref iter);
|
||||
bChanged = true;
|
||||
applybuttonPersistent.Sensitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void PersistentPolicyDialog_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
int iColID = 0;
|
||||
Gtk.SortType sortType = Gtk.SortType.Ascending;
|
||||
|
||||
bool bReturn = tsPersistentList.GetSortColumnId(out iColID, out sortType);
|
||||
if (bReturn)
|
||||
{
|
||||
if (sortType == Gtk.SortType.Ascending)
|
||||
{
|
||||
tsPersistentList.SetSortColumnId(0, Gtk.SortType.Descending);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsPersistentList.SetSortColumnId(0, Gtk.SortType.Ascending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NonPersistentPolicyDialog_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
int iColID = 0;
|
||||
Gtk.SortType sortType = Gtk.SortType.Ascending;
|
||||
|
||||
bool bReturn = tsNonPersistentList.GetSortColumnId(out iColID, out sortType);
|
||||
if (bReturn)
|
||||
{
|
||||
if (sortType == Gtk.SortType.Ascending)
|
||||
{
|
||||
tsNonPersistentList.SetSortColumnId(0, Gtk.SortType.Descending);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsNonPersistentList.SetSortColumnId(0, Gtk.SortType.Ascending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tvPersistentList_ButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
|
||||
{
|
||||
activateMoveButtons(true, false);
|
||||
}
|
||||
|
||||
private void tvNonPersistentList_ButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
|
||||
{
|
||||
activateMoveButtons(false, true);
|
||||
}
|
||||
|
||||
|
||||
private void activateMoveButtons(bool bMakeNonPersist, bool bMakePersist)
|
||||
{
|
||||
if (bMakeNonPersist)
|
||||
{
|
||||
buttonMakeNonPersistent.Sensitive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonMakeNonPersistent.Sensitive = false;
|
||||
}
|
||||
|
||||
if (bMakePersist)
|
||||
{
|
||||
buttonMakePersistent.Sensitive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonMakePersistent.Sensitive = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user