Moving micasa 1.5 trunk to Novell forge.
247
c_gui/CASAManager.csproj
Normal file
@@ -0,0 +1,247 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{A1A805D0-B400-4D11-A772-348CE13F1046}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "CASAManager"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "WinExe"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = ""
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "false"
|
||||
OutputPath = "Debug\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "true"
|
||||
OutputPath = "Release\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.A-D"
|
||||
Project = "{25D49F34-F655-4CCF-93F1-449243AF7A32}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.CASAPolicy"
|
||||
Project = "{636A9D7E-BFB5-4EB9-96F8-51FF85A98826}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.Common"
|
||||
Project = "{57CD94A2-5B4A-40C3-8189-CB760FB78357}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.miCASAWrapper"
|
||||
Project = "{E21DD887-22F4-4935-9851-409715F663B0}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "pango-sharp"
|
||||
AssemblyName = "pango-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\pango-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "rsvg-sharp"
|
||||
AssemblyName = "rsvg-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\rsvg-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "atk-sharp"
|
||||
AssemblyName = "atk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\atk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gdk-sharp"
|
||||
AssemblyName = "gdk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\gdk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glade-sharp"
|
||||
AssemblyName = "glade-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\glade-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glib-sharp"
|
||||
AssemblyName = "glib-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\glib-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gtk-sharp"
|
||||
AssemblyName = "gtk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\gtk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "CasaMain.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Firefox.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "GnomeKeyring.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "KdeWallet.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Logger.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MiCasa.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Mozilla.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Store.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "StoreDataInterface.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "StorePolicyInterface.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\casa-1.5.glade"
|
||||
BuildAction = "None"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\casa-1.5.gladep"
|
||||
BuildAction = "None"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\casa-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\firefox-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\keyring-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\kwallet-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\micasa-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\mozilla-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\novell-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\Readme.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
48
c_gui/CASAManager.csproj.user
Normal file
@@ -0,0 +1,48 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
</Settings>
|
||||
</Build>
|
||||
<OtherProjectSettings
|
||||
CopyProjectDestinationFolder = ""
|
||||
CopyProjectUncPath = ""
|
||||
CopyProjectOption = "0"
|
||||
ProjectView = "ProjectFiles"
|
||||
ProjectTrust = "0"
|
||||
/>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
2
c_gui/CASAManager.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
mono /opt/novell/CASA/bin/CASAManager.exe &
|
||||
1068
c_gui/CasaMain.cs
Normal file
237
c_gui/Common.cs
Normal file
@@ -0,0 +1,237 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : Common.cs
|
||||
/// DESCRIPTION : Class for defining constants and common static
|
||||
/// methods.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 24 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
|
||||
public class Common
|
||||
{
|
||||
|
||||
public const int STORE_MICASA = 0,
|
||||
STORE_FIREFOX = 1,
|
||||
STORE_MOZILLA = 2,
|
||||
STORE_KDEWALLET = 3,
|
||||
STORE_GNOMEKEYRING = 4;
|
||||
|
||||
public static bool IS_MICASA = true,
|
||||
IS_FIREFOX = false,
|
||||
IS_MOZILLA = false,
|
||||
IS_KDEWALLET = false,
|
||||
IS_GNOMEKEYRING = false;
|
||||
|
||||
public static bool IS_LINUX = false,
|
||||
IS_WINDOWS = false;
|
||||
|
||||
public static string GladeFile = null,
|
||||
DebugLogFile = null;
|
||||
|
||||
|
||||
///##############################################################
|
||||
/// SPI CONSTANTS
|
||||
///
|
||||
|
||||
public static int MAX_STORES = 10;
|
||||
|
||||
public static string STORENAME_MICASA = "miCASA",
|
||||
STORENAME_FIREFOX = "Firefox",
|
||||
STORENAME_MOZILLA = "Mozilla",
|
||||
STORENAME_KDEWALLET = "KDE KWallet",
|
||||
STORENAME_GNOMEKEYRING = "GNOME Keyring";
|
||||
|
||||
|
||||
///##############################################################
|
||||
/// SDI CONSTANTS
|
||||
///
|
||||
|
||||
//Operations
|
||||
public static int OPERATION_ADD_SECRET = 0,
|
||||
OPERATION_ADD_KEY = 1,
|
||||
OPERATION_MODIFY_KEY = 2,
|
||||
OPERATION_DELETE_SECRET = 3,
|
||||
OPERATION_DELETE_KEY = 4;
|
||||
|
||||
//Limits
|
||||
public static int MAX_ARRAY_ELEMENTS = 10;
|
||||
public static int MAX_NATIVE_ELEMENTS = 5;
|
||||
|
||||
public static string NATIVEINFO_FOLDERNAME = "Folder Name";
|
||||
public static string NATIVEINFO_TYPEID = "Type of Secret";
|
||||
public static string NATIVEINFO_SYNC = "Syncronization Status";
|
||||
public static string NATIVEINFO_SYNCTYPE = "Syncronization Type";
|
||||
public static string NATIVEINFO_MODIFIEDTIME = "Last Modified Time";
|
||||
|
||||
public static int INDEX_NATIVEINFO_FOLDERNAME = 0,
|
||||
INDEX_NATIVEINFO_TYPEID = 1,
|
||||
INDEX_NATIVEINFO_SYNC = 2,
|
||||
INDEX_NATIVEINFO_SYNCTYPE = 3,
|
||||
INDEX_NATIVEINFO_MODIFIEDTIME = 4;
|
||||
|
||||
///##############################################################
|
||||
/// ERROR CODES
|
||||
|
||||
public static int STATUS_SUCCESS = 0,
|
||||
STATUS_FAILURE = 1,
|
||||
|
||||
// POLICY STATUS CODE RANGE: 2 - 20
|
||||
STATUS_POLICY_COULDNOTBESAVED = 2,
|
||||
STATUS_POLICY_POLICYNOTFOUND = 3,
|
||||
|
||||
// STORE STATUS CODE RANGE: 21 - 40
|
||||
STATUS_STORE_INVALIDSTOREID = 21,
|
||||
STATUS_STORE_DATANOTFOUNDINSTORE = 22,
|
||||
STATUS_STORE_UNSUPPORTEDOPERATION = 23,
|
||||
STATUS_STORE_ADINITFAILED = 24,
|
||||
STATUS_STORE_AGGREGATEFAILED = 25,
|
||||
STATUS_STORE_READFAILED = 26,
|
||||
STATUS_STORE_UPDATEFAILED = 27;
|
||||
|
||||
|
||||
///##############################################################
|
||||
/// STATIC ROUTINES
|
||||
|
||||
public static void ShowErrorDialog(Exception exp)
|
||||
{
|
||||
Console.WriteLine("CASA-EXCEPTION: " + exp.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ShowErrorDialog(int errorCode)
|
||||
{
|
||||
Console.WriteLine("CASA-ERROR: " + errorCode);
|
||||
}
|
||||
|
||||
///#######################################################################
|
||||
/// READ PLATFORM
|
||||
|
||||
/// <summary>
|
||||
/// Routine to read the operating system of the target machine.
|
||||
/// IS_LINUX, IS_WINDOWS flags are set.
|
||||
/// Path to Glade file is set in this routine.
|
||||
/// </summary>
|
||||
public static void ReadPlatform()
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - BEGIN");
|
||||
|
||||
int platform = (int)Environment.OSVersion.Platform;
|
||||
|
||||
if ( (128 == platform) || (4 == platform) )
|
||||
{
|
||||
IS_LINUX = true;
|
||||
GladeFile = "/opt/novell/CASA/images/casa-1.5.glade";
|
||||
//GladeFile = "./images/casa-1.5.glade";
|
||||
|
||||
if( !File.Exists(GladeFile) )
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - ERROR: Glade file could not be found.");
|
||||
//Gtk.Application.Quit();
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - IS_LINUX = " + IS_LINUX);
|
||||
}
|
||||
else
|
||||
{
|
||||
IS_WINDOWS = true;
|
||||
//Common.GladeFile = Environment.GetEnvironmentVariable("HOMEDRIVE") + "\\Program Files\\Novell\\CASA\\images\\casa-1.5.glade";
|
||||
GladeFile = "..\\images\\casa-1.5.glade";
|
||||
if( !File.Exists(GladeFile) )
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - ERROR: Glade file could not be found.");
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - IS_WINDOWS = " + IS_WINDOWS);
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.SetGladeFilePath() - END");
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// SINGLE INSTANCE CHECK
|
||||
|
||||
/// <summary>
|
||||
/// MainWindow delete window handler
|
||||
/// </summary>
|
||||
|
||||
public static bool CheckForSingleInstance()
|
||||
{
|
||||
bool bRet=false;;
|
||||
|
||||
if( true == IS_LINUX )
|
||||
{
|
||||
Process mgrProcess = null;
|
||||
StreamReader sReader = null;
|
||||
|
||||
try
|
||||
{
|
||||
mgrProcess = new Process();
|
||||
ProcessStartInfo mgrProcessStartInfo = new ProcessStartInfo("ps" );
|
||||
mgrProcessStartInfo.Arguments = "h";
|
||||
mgrProcessStartInfo.UseShellExecute = false;
|
||||
mgrProcessStartInfo.RedirectStandardOutput = true;
|
||||
mgrProcess.StartInfo = mgrProcessStartInfo;
|
||||
mgrProcess.Start();
|
||||
mgrProcess.WaitForExit();
|
||||
sReader = mgrProcess.StandardOutput;
|
||||
string str = sReader.ReadLine();
|
||||
int num = 0;
|
||||
while( str != null)
|
||||
{
|
||||
str = sReader.ReadLine();
|
||||
if(str != null)
|
||||
{
|
||||
if(str.EndsWith("CASAManager.exe"))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( num > 1 )
|
||||
bRet = true;
|
||||
else
|
||||
bRet = false;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.CheckIfAnotherInstanceIsRunning() " + e.ToString());
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
if(mgrProcess != null)
|
||||
mgrProcess.Close();
|
||||
if(sReader != null)
|
||||
sReader.Close();
|
||||
//return bRet;
|
||||
|
||||
}
|
||||
else if( true == IS_WINDOWS )
|
||||
{
|
||||
bRet = false;
|
||||
//return(false);
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
31
c_gui/Firefox.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : Firefox.cs
|
||||
/// DESCRIPTION : GUI implementation of Firefox store.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 26 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
public class Firefox : Store
|
||||
{
|
||||
public override void AggregateStore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ViewKeyValues()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
477
c_gui/GnomeKeyring.cs
Normal file
@@ -0,0 +1,477 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : GnomeKeyring.cs
|
||||
/// DESCRIPTION : GUI implementation of GNOME-Keyring store.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 26 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
|
||||
public class GnomeKeyring : Store
|
||||
{
|
||||
|
||||
Gtk.TreeStore tsSecretIDGnomeKeyring,
|
||||
tsNativeInfoGnomeKeyring,
|
||||
tsKeyValue;
|
||||
|
||||
CellRendererText cellEditable;
|
||||
|
||||
public bool IS_STORE_AGGREGATED = false;
|
||||
|
||||
#region Glade Widgets
|
||||
|
||||
[Glade.Widget]
|
||||
public Gtk.TreeView tvSecretIDGnomeKeyring;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView tvKeyValue,
|
||||
tvNativeInfoGnomeKeyring;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogManageSecret,
|
||||
dialogLogin;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Menu menuRightClick;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entrySecretID,
|
||||
entryKey,
|
||||
entryValue,
|
||||
entryMasterPassword3,
|
||||
entryMasterPassword4;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.CheckButton cbuttonShowPassword;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Label label86,
|
||||
label88;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button buttonNewAdd,
|
||||
buttonNewRemove,
|
||||
buttonManageOk;
|
||||
[Glade.Widget]
|
||||
Gtk.MenuItem cmiNew,
|
||||
cmiDelete,
|
||||
cmiView,
|
||||
cmiLink,
|
||||
cmiCopy;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// CONSTRUCTOR
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public GnomeKeyring()
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.GnomeKeyring() - BEGIN");
|
||||
|
||||
/// SecretID TreeStore
|
||||
tvSecretIDGnomeKeyring = (Gtk.TreeView)CasaMain.gxml.GetWidget("tvSecretIDGnomeKeyring");
|
||||
tsSecretIDGnomeKeyring = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
|
||||
tvSecretIDGnomeKeyring.AppendColumn("Secret-ID",new CellRendererText(),"text",0);
|
||||
tvSecretIDGnomeKeyring.Model = tsSecretIDGnomeKeyring;
|
||||
tvSecretIDGnomeKeyring.RowActivated += new RowActivatedHandler(OntvSecretIDGnomeKeyringRowActivated);
|
||||
tvSecretIDGnomeKeyring.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClicked);
|
||||
tvSecretIDGnomeKeyring.CursorChanged += new EventHandler(OnCursorChanged);
|
||||
/// NativeInfo TreeStore
|
||||
tvNativeInfoGnomeKeyring = (Gtk.TreeView)CasaMain.gxml.GetWidget("tvNativeInfoGnomeKeyring");
|
||||
tsNativeInfoGnomeKeyring = new TreeStore(typeof(string), typeof(string));
|
||||
tvNativeInfoGnomeKeyring.AppendColumn("NativeKey",new CellRendererText(),"text",0);
|
||||
tvNativeInfoGnomeKeyring.AppendColumn("NativeValue",new CellRendererText(),"text",1);
|
||||
tvNativeInfoGnomeKeyring.Model = tsNativeInfoGnomeKeyring;
|
||||
tvNativeInfoGnomeKeyring.ModifyBase(StateType.Normal,new Gdk.Color(0xff,0xff,0xe6));
|
||||
/// Aggregate the store
|
||||
//AggregateStore();
|
||||
|
||||
Logger.DbgLog("GUI:GnomeKeyring.GnomeKeyring() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// AGGREGATE STORE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void AggregateStore()
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.AggregateStore() - BEGIN");
|
||||
|
||||
try
|
||||
{
|
||||
tsSecretIDGnomeKeyring.Clear();
|
||||
StoreDataInterface.AggregateStore(Common.STORE_GNOMEKEYRING);
|
||||
StoreDataInterface.ReadStore(Common.STORE_GNOMEKEYRING,ref tsSecretIDGnomeKeyring);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.AggregateStore() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:GnomeKeyring.AggregateStore() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// DISPLAY NATIVE INFO
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void OnCursorChanged(object obj, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnCursorChanged() - BEGIN");
|
||||
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected = null;
|
||||
string[] NativeKeys = null,
|
||||
NativeValues = null;
|
||||
|
||||
if( tvSecretIDGnomeKeyring.Selection.GetSelected (out model, out iter) )
|
||||
selected = (string) model.GetValue(iter, 0);
|
||||
|
||||
if( (null != selected) && (selected.Length > 0) )
|
||||
{
|
||||
tsNativeInfoGnomeKeyring.Clear();
|
||||
/// Populate NativeInfo
|
||||
tsNativeInfoGnomeKeyring.AppendValues("Keyring Name","= "+ model.GetValue(iter,3));
|
||||
NativeKeys = (string[]) model.GetValue(iter, 4);
|
||||
NativeValues= (string[]) model.GetValue(iter, 5);
|
||||
for( int i=0; i< NativeKeys.Length; i++ )
|
||||
if( (NativeValues[i] != null) && (NativeValues[i] != "") )
|
||||
tsNativeInfoGnomeKeyring.AppendValues(NativeKeys[i], "= "+NativeValues[i]);
|
||||
tvNativeInfoGnomeKeyring.ShowAll();
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnCursorChanged() - END");
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// RIGHT-CLICK CONTEXT MENU
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnRightClicked(object obj, ButtonReleaseEventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - BEGIN");
|
||||
|
||||
if( 3 == args.Event.Button )
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - Context menu opened.");
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "menuRightClick", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
|
||||
if( 0 != tvSecretIDGnomeKeyring.Selection.CountSelectedRows() )
|
||||
cmiNew.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
|
||||
else
|
||||
cmiNew.Sensitive = cmiView.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - END");
|
||||
}
|
||||
|
||||
///#######################################################################
|
||||
/// VIEW KEY-VALUES
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void ViewKeyValues()
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.ViewKeyValues() - BEGIN");
|
||||
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected= null;
|
||||
string[] keys = null,
|
||||
values = null;
|
||||
try
|
||||
{
|
||||
if( tvSecretIDGnomeKeyring.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue(iter, 0);
|
||||
keys = (string[]) model.GetValue(iter, 1);
|
||||
values = (string[]) model.GetValue(iter, 2);
|
||||
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogManageSecret.TransientFor = (Gtk.Window)CasaMain.gxml.GetWidget("windowMain");
|
||||
dialogManageSecret.Title = "VIEW";
|
||||
|
||||
cellEditable = new CellRendererText();
|
||||
cellEditable.Editable = false;
|
||||
//cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
|
||||
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3
|
||||
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool));
|
||||
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
|
||||
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
|
||||
|
||||
entrySecretID.Text=selected;
|
||||
for( int i=0; i< keys.Length; i++ )
|
||||
{
|
||||
if( (null != keys[i]) && (null != values[i]) )
|
||||
tsKeyValue.AppendValues(keys[i], values[i], "********", false);
|
||||
|
||||
}
|
||||
tvKeyValue.Model = tsKeyValue;
|
||||
entryKey.Sensitive = entryValue.Sensitive = buttonNewAdd.Sensitive = buttonNewRemove.Sensitive = buttonManageOk.Sensitive = false;
|
||||
}
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.ViewKeyValues() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:GnomeKeyring.ViewKeyValues() - END");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EDIT KEY-VALUE
|
||||
/// </summary>
|
||||
public void OnKeyValueEdited(object obj, EditedArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ADD BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonNewAdd_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// REMOVE BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonNewRemove_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SHOW PASSWORD CHECK BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_cbuttonShowPassword_toggled(object obj, EventArgs args)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
Console.WriteLine("Manojna........");
|
||||
if( tvKeyValue.Model.IterNChildren() > 0 )
|
||||
if( true == cbuttonShowPassword.Active)
|
||||
{
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogLogin.TransientFor = dialogManageSecret;
|
||||
|
||||
label86.Text = "Enter your Master Password to view passwords";
|
||||
entryMasterPassword3.Text="";
|
||||
entryMasterPassword3.HasFocus = true;
|
||||
label88.Hide();
|
||||
entryMasterPassword4.Hide();
|
||||
dialogLogin.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
||||
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
|
||||
tvKeyValue.InsertColumn(tvCol, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void okbuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if( tvKeyValue.Model.IterNChildren() > 0 )
|
||||
|
||||
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
|
||||
{
|
||||
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
||||
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
|
||||
tvKeyValue.InsertColumn(tvCol, 1);
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
// prompt user
|
||||
MessageDialog md=new MessageDialog(dialogLogin,Gtk.DialogFlags.Modal,
|
||||
Gtk.MessageType.Warning,
|
||||
Gtk.ButtonsType.Ok,
|
||||
"Master Password incorrect");
|
||||
|
||||
md.Response +=new ResponseHandler(md_Response2);
|
||||
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
||||
md.Modal = true;
|
||||
md.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
cbuttonShowPassword.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
||||
{
|
||||
cbuttonShowPassword.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
||||
{
|
||||
if( "" != entryMasterPassword3.Text )
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
||||
{
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
private void md_Response2(object o, ResponseArgs args)
|
||||
{
|
||||
MessageDialog md = (MessageDialog)o;
|
||||
if (md != null)
|
||||
{
|
||||
md.Destroy();
|
||||
entryMasterPassword3.Text="";
|
||||
entryMasterPassword3.HasFocus = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MANAGE SECRET-ID DIALOG OK-BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonManageOk_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MANAGE SECRET-ID DIALOG CANCEL-BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonManageCancel_clicked(object obj, EventArgs args)
|
||||
{
|
||||
tsKeyValue.Dispose();
|
||||
dialogManageSecret.Destroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SECRET-ID DOUBLE CLICKED
|
||||
/// </summary>
|
||||
private void OntvSecretIDGnomeKeyringRowActivated( object obj, RowActivatedArgs args )
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OntvSecretIDGnomeKeyringRowActivated() - ViewKeyValues() called.");
|
||||
ViewKeyValues();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// VIEW KEY-VALUES CALLED VIA MAIN-MENU/CONTEXT-MENU
|
||||
/// </summary>
|
||||
public void OnViewActivated(object obj, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.OnViewActivated() - ViewKeyValues() called.");
|
||||
ViewKeyValues();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// ADD NEW SECRET
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnNewSecretActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// ADD NEW KEY-VALUES TO EXISTING SECRET
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnNewKeyActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// LINK
|
||||
|
||||
/// <summary>
|
||||
/// LINK Key-Values
|
||||
/// </summary>
|
||||
public void OnLinkActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// COPY
|
||||
|
||||
/// <summary>
|
||||
/// COPY Key-Values
|
||||
/// </summary>
|
||||
public void OnCopyActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
// DELETE SECRET
|
||||
|
||||
/// <summary>
|
||||
/// DELETE Secret
|
||||
/// </summary>
|
||||
public void OnDeleteActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
479
c_gui/KdeWallet.cs
Normal file
@@ -0,0 +1,479 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : KdeWallet.cs
|
||||
/// DESCRIPTION : GUI implementation of KDE-Wallet store.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 26 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
public class KdeWallet : Store
|
||||
{
|
||||
|
||||
Gtk.TreeStore tsSecretIDKdeWallet,
|
||||
tsNativeInfoKdeWallet,
|
||||
tsKeyValue;
|
||||
|
||||
CellRendererText cellEditable;
|
||||
|
||||
public bool IS_STORE_AGGREGATED = false;
|
||||
|
||||
#region Glade Widgets
|
||||
|
||||
[Glade.Widget]
|
||||
public Gtk.TreeView tvSecretIDKdeWallet;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView tvKeyValue,
|
||||
tvNativeInfoKdeWallet;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogManageSecret,
|
||||
dialogLogin;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Menu menuRightClick;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entrySecretID,
|
||||
entryKey,
|
||||
entryValue,
|
||||
entryMasterPassword3,
|
||||
entryMasterPassword4;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.CheckButton cbuttonShowPassword;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Label label86,
|
||||
label88;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button buttonNewAdd,
|
||||
buttonNewRemove,
|
||||
buttonManageOk;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.MenuItem cmiNew,
|
||||
cmiDelete,
|
||||
cmiView,
|
||||
cmiLink,
|
||||
cmiCopy;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// CONSTRUCTOR
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public KdeWallet()
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.KdeWallet() - BEGIN");
|
||||
|
||||
/// SecretID TreeStore
|
||||
tvSecretIDKdeWallet = (Gtk.TreeView)CasaMain.gxml.GetWidget("tvSecretIDKdeWallet");
|
||||
tsSecretIDKdeWallet = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
|
||||
tvSecretIDKdeWallet.AppendColumn("Secret-ID",new CellRendererText(),"text",0);
|
||||
tvSecretIDKdeWallet.Model = tsSecretIDKdeWallet;
|
||||
tvSecretIDKdeWallet.RowActivated += new RowActivatedHandler(OntvSecretIDKdeWalletRowActivated);
|
||||
tvSecretIDKdeWallet.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClicked);
|
||||
tvSecretIDKdeWallet.CursorChanged += new EventHandler(OnCursorChanged);
|
||||
/// NativeInfo TreeStore
|
||||
tvNativeInfoKdeWallet = (Gtk.TreeView)CasaMain.gxml.GetWidget("tvNativeInfoKdeWallet");
|
||||
tsNativeInfoKdeWallet = new TreeStore(typeof(string), typeof(string));
|
||||
tvNativeInfoKdeWallet.AppendColumn("NativeKey",new CellRendererText(),"text",0);
|
||||
tvNativeInfoKdeWallet.AppendColumn("NativeValue",new CellRendererText(),"text",1);
|
||||
tvNativeInfoKdeWallet.Model = tsNativeInfoKdeWallet;
|
||||
tvNativeInfoKdeWallet.ModifyBase(StateType.Normal,new Gdk.Color(0xff,0xff,0xe6));
|
||||
/// Aggregate the store
|
||||
//AggregateStore();
|
||||
|
||||
Logger.DbgLog("GUI:KdeWallet.KdeWallet() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// AGGREGATE STORE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void AggregateStore()
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.AggregateStore() - BEGIN");
|
||||
|
||||
try
|
||||
{
|
||||
tsSecretIDKdeWallet.Clear();
|
||||
StoreDataInterface.AggregateStore(Common.STORE_KDEWALLET);
|
||||
StoreDataInterface.ReadStore(Common.STORE_KDEWALLET,ref tsSecretIDKdeWallet);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.AggregateStore() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:KdeWallet.AggregateStore() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// DISPLAY NATIVE INFO
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void OnCursorChanged(object obj, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.OnCursorChanged() - BEGIN");
|
||||
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected = null;
|
||||
string[] NativeKeys = null,
|
||||
NativeValues = null;
|
||||
|
||||
if( tvSecretIDKdeWallet.Selection.GetSelected (out model, out iter) )
|
||||
selected = (string) model.GetValue(iter, 0);
|
||||
|
||||
if( (null != selected) && (selected.Length > 0) )
|
||||
{
|
||||
tsNativeInfoKdeWallet.Clear();
|
||||
/// Populate NativeInfo
|
||||
tsNativeInfoKdeWallet.AppendValues("Wallet Name", "= "+model.GetValue(iter,3));
|
||||
NativeKeys = (string[]) model.GetValue(iter, 4);
|
||||
NativeValues = (string[]) model.GetValue(iter, 5);
|
||||
for( int i=0; i< NativeKeys.Length; i++ )
|
||||
if( (null != NativeValues[i]) && ("" != NativeValues[i]) )
|
||||
tsNativeInfoKdeWallet.AppendValues(NativeKeys[i], "= "+NativeValues[i]);
|
||||
tvNativeInfoKdeWallet.ShowAll();
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:KdeWallet.OnCursorChanged() - END");
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// RIGHT-CLICK CONTEXT MENU
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnRightClicked(object obj, ButtonReleaseEventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.OnRightClicked() - BEGIN");
|
||||
|
||||
if( 3 == args.Event.Button )
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - Context menu opened.");
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "menuRightClick", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
|
||||
|
||||
if( 0 != tvSecretIDKdeWallet.Selection.CountSelectedRows() )
|
||||
cmiNew.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
|
||||
else
|
||||
cmiNew.Sensitive = cmiView.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiDelete.Sensitive = false;
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:GnomeKeyring.OnRightClicked() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:KdeWallet.OnRightClicked() - END");
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// VIEW KEY-VALUES
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void ViewKeyValues()
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.ViewKeyValues() - BEGIN");
|
||||
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected = null;
|
||||
string[] keys = null,
|
||||
values = null;
|
||||
|
||||
try
|
||||
{
|
||||
if( tvSecretIDKdeWallet.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue(iter, 0);
|
||||
keys = (string[]) model.GetValue(iter, 1);
|
||||
values = (string[]) model.GetValue(iter, 2);
|
||||
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogManageSecret.TransientFor = (Gtk.Window)CasaMain.gxml.GetWidget("windowMain");
|
||||
dialogManageSecret.Title = "VIEW";
|
||||
|
||||
cellEditable = new CellRendererText();
|
||||
cellEditable.Editable = false;
|
||||
//cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
|
||||
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3
|
||||
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool));
|
||||
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
|
||||
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
|
||||
|
||||
entrySecretID.Text = selected;
|
||||
for( int i=0; i< keys.Length; i++ )
|
||||
{
|
||||
if( (null != keys[i]) && (null != values[i]) )
|
||||
tsKeyValue.AppendValues(keys[i], values[i], "********", false);
|
||||
}
|
||||
tvKeyValue.Model = tsKeyValue;
|
||||
entryKey.Sensitive = entryValue.Sensitive = buttonNewAdd.Sensitive = buttonNewRemove.Sensitive = buttonManageOk.Sensitive = false;
|
||||
}
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.ViewKeyValues() - EXCEPTION" + exp.ToString());
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:KdeWallet.ViewKeyValues() - END");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EDIT KEY-VALUE
|
||||
/// </summary>
|
||||
public void OnKeyValueEdited(object obj, EditedArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ADD BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonNewAdd_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// REMOVE BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonNewRemove_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SHOW PASSWORD CHECK BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_cbuttonShowPassword_toggled(object obj, EventArgs args)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if( tvKeyValue.Model.IterNChildren() > 0 )
|
||||
if( true == cbuttonShowPassword.Active)
|
||||
{
|
||||
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogLogin.TransientFor = dialogManageSecret;
|
||||
|
||||
label86.Text = "Enter your Master Password to view passwords";
|
||||
entryMasterPassword3.Text="";
|
||||
entryMasterPassword3.HasFocus = true;
|
||||
label88.Hide();
|
||||
entryMasterPassword4.Hide();
|
||||
dialogLogin.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
||||
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
|
||||
tvKeyValue.InsertColumn(tvCol, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void okbuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if( tvKeyValue.Model.IterNChildren() > 0 )
|
||||
|
||||
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
|
||||
{
|
||||
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
||||
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
|
||||
tvKeyValue.InsertColumn(tvCol, 1);
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
// prompt user
|
||||
MessageDialog md=new MessageDialog(dialogLogin,Gtk.DialogFlags.Modal,
|
||||
Gtk.MessageType.Warning,
|
||||
Gtk.ButtonsType.Ok,
|
||||
"Master Password incorrect");
|
||||
|
||||
md.Response +=new ResponseHandler(md_Response2);
|
||||
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
||||
md.Modal = true;
|
||||
md.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
cbuttonShowPassword.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
||||
{
|
||||
cbuttonShowPassword.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
||||
{
|
||||
if( "" != entryMasterPassword3.Text )
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
||||
{
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
private void md_Response2(object o, ResponseArgs args)
|
||||
{
|
||||
MessageDialog md = (MessageDialog)o;
|
||||
if (md != null)
|
||||
{
|
||||
md.Destroy();
|
||||
entryMasterPassword3.Text="";
|
||||
entryMasterPassword3.HasFocus = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// MANAGE SECRET-ID DIALOG OK-BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonManageOk_clicked(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MANAGE SECRET-ID DIALOG CANCEL-BUTTON CLICKED
|
||||
/// </summary>
|
||||
public void on_buttonManageCancel_clicked(object obj, EventArgs args)
|
||||
{
|
||||
tsKeyValue.Dispose();
|
||||
dialogManageSecret.Destroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SECRET-ID DOUBLE CLICKED
|
||||
/// </summary>
|
||||
private void OntvSecretIDKdeWalletRowActivated( object obj, RowActivatedArgs args )
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.OntvSecretIDKdeWalletRowActivated() - SecretID double clicked.");
|
||||
ViewKeyValues();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// VIEW KEY-VALUES CALLED VIA MAIN-MENU/CONTEXT-MENU
|
||||
/// </summary>
|
||||
public void OnViewActivated(object obj, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:KdeWallet.OnViewActivated() - ViewKeyValues() called.");
|
||||
ViewKeyValues();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// ADD NEW SECRET
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnNewSecretActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// ADD NEW KEY-VALUES TO EXISTING SECRET
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void OnNewKeyActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// LINK
|
||||
|
||||
/// <summary>
|
||||
/// LINK Key-Values
|
||||
/// </summary>
|
||||
public void OnLinkActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// COPY
|
||||
|
||||
/// <summary>
|
||||
/// COPY Key-Values
|
||||
/// </summary>
|
||||
public void OnCopyActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
// DELETE SECRET
|
||||
|
||||
/// <summary>
|
||||
/// DELETE Secret
|
||||
/// </summary>
|
||||
public void OnDeleteActivated(object obj, EventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
106
c_gui/Logger.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : Logger.cs
|
||||
/// DESCRIPTION : Debug Log implementation Class.
|
||||
/// AUTHORS :
|
||||
/// CREATED ON :
|
||||
/// UPDATED ON :
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
class Logger
|
||||
{
|
||||
private static string debugLog = null;
|
||||
private static Stream debugStream= null;
|
||||
private static Mutex dbgmutex = new Mutex();
|
||||
|
||||
|
||||
static Logger()
|
||||
{
|
||||
#if DEBUG
|
||||
debugLog = GetHomeDir() + "/.CASAManager.logs";
|
||||
|
||||
// Set up for Debug
|
||||
|
||||
if( File.Exists( debugLog ) )
|
||||
{
|
||||
File.Delete( debugLog );
|
||||
}
|
||||
|
||||
debugStream = File.Create(debugLog);
|
||||
|
||||
Debug.Listeners.Add(new TextWriterTraceListener(debugStream));
|
||||
Debug.AutoFlush = true;
|
||||
Debug.Indent();
|
||||
Debug.WriteLine("Debug Log created");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public static void logbreak()
|
||||
{
|
||||
dbgmutex.WaitOne();
|
||||
Debug.WriteLine(" ") ;
|
||||
Debug.WriteLine("----------------------------------------------------") ;
|
||||
Debug.WriteLine(" ") ;
|
||||
dbgmutex.ReleaseMutex();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The log format is Time stamp :Component name: Error description
|
||||
public static void DbgLog(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
dbgmutex.WaitOne();
|
||||
|
||||
Debug.Write(DateTime.Now.ToLongTimeString());
|
||||
Debug.Write(" " + DateTime.Now.ToLongDateString());
|
||||
Debug.Write(":");
|
||||
Debug.WriteLine(message);
|
||||
|
||||
dbgmutex.ReleaseMutex();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void ExpLog(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
dbgmutex.WaitOne();
|
||||
|
||||
Debug.Write(DateTime.Now.ToLongTimeString());
|
||||
Debug.Write(" " + DateTime.Now.ToLongDateString());
|
||||
Debug.Write(": Exception encountered - ");
|
||||
Debug.WriteLine(message);
|
||||
Debug.WriteLine(" ") ;
|
||||
StackTrace st = new StackTrace();
|
||||
Debug.WriteLine(st.ToString());
|
||||
|
||||
dbgmutex.ReleaseMutex();
|
||||
#endif
|
||||
}
|
||||
static string GetHomeDir()
|
||||
{
|
||||
int platform = (int)Environment.OSVersion.Platform;
|
||||
|
||||
if ( (platform == 128) || ( platform == 4) )
|
||||
{
|
||||
return System.Environment.GetEnvironmentVariable("HOME");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (System.Environment.GetEnvironmentVariable("HOMEDRIVE")) +
|
||||
(System.Environment.GetEnvironmentVariable("HOMEPATH"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
20
c_gui/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# configure environment
|
||||
#
|
||||
TARGET = CASAManager
|
||||
CS_NAME = $(TARGET)$(xtra).$(EXE)
|
||||
include global.mak
|
||||
include defaults.$(PLAT)
|
||||
include rules.mak
|
||||
|
||||
|
||||
#
|
||||
# target object and source files
|
||||
#
|
||||
include src.$(PLAT)
|
||||
include objs.$(PLAT)
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
include target.cs
|
||||
1117
c_gui/MiCasa.cs
Normal file
30
c_gui/Mozilla.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : Mozilla.cs
|
||||
/// DESCRIPTION : GUI implementation of Mozilla store.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 24 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
public class Mozilla : Store
|
||||
{
|
||||
public override void AggregateStore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ViewKeyValues()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
37
c_gui/Store.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : Store.cs
|
||||
/// DESCRIPTION : A parent class that abstracts the store classes.
|
||||
/// AUTHORS : CSL.Manojna
|
||||
/// UPDATED ON : 21 Sept, 05
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
public abstract class Store
|
||||
{
|
||||
|
||||
///#######################################################################
|
||||
/// <summary>
|
||||
/// Clears the TreeStore and invokes ReadStore() to aggregate
|
||||
/// respective stores.
|
||||
/// </summary>
|
||||
public abstract void AggregateStore();
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract void ViewKeyValues();
|
||||
|
||||
}
|
||||
}
|
||||
///##################################################################
|
||||
/// END OF FILE
|
||||
///##################################################################
|
||||
610
c_gui/StoreDataInterface.cs
Normal file
@@ -0,0 +1,610 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : StoreDataInterface.cs
|
||||
/// DESCRIPTION : Implementation of Store Data Interface for CASA.
|
||||
/// Abstracts the back-end and acts as an interface
|
||||
/// to the GUI.
|
||||
/// AUTHORS : Manohar, CSL.Manojna
|
||||
/// UPDATED ON : 24 Sept, 2005
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Xml.Xsl;
|
||||
using GLib;
|
||||
using Gtk;
|
||||
using Novell.CASA.DataEngines;
|
||||
|
||||
|
||||
public class StoreDataInterface
|
||||
{
|
||||
|
||||
private static XmlDocument ccfDoc;
|
||||
private static AD ad;
|
||||
|
||||
private static string CCFXML_ELEMENT_MICASA_KEYCHAIN = "Keychain",
|
||||
CCFXML_ELEMENT_GKEYRING_KEYRING = "Keyring",
|
||||
CCFXML_ELEMENT_KWALLET_WALLET = "Wallet",
|
||||
CCFXML_ELEMENT_SECRET = "Secret",
|
||||
CCFXML_ELEMENT_FOLDER = "Folder",
|
||||
CCFXML_ATTRIBUTE_FOLDERNAME = "Name",
|
||||
CCFXML_ELEMENT_TYPE = "Type",
|
||||
CCFXML_ELEMENT_KEY = "Key",
|
||||
CCFXML_ELEMENT_VALUE = "Value",
|
||||
CCFXML_ELEMENT_TIME = "Time",
|
||||
CCFXML_ELEMENT_TIME_ZONE = "Zone",
|
||||
CCFXML_ELEMENT_TIME_CREATION = "Creation",
|
||||
CCFXML_ELEMENT_TIME_MODIFIED = "Modified",
|
||||
CCFXML_ELEMENT_TIME_ACCESSED = "Accessed",
|
||||
CCFXML_ATTRIBUTE_ID = "ID",
|
||||
CCFXML_ATTRIBUTE_MICASA_SYNCH = "Synch",
|
||||
CCFXML_ATTRIBUTE_GKEYRING_TYPE = "Type";
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// INIT
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the CCF from miCASA-D
|
||||
/// </summary>
|
||||
public static int Init()
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.StoreDataInterface() - BEGIN");
|
||||
|
||||
try
|
||||
{
|
||||
ccfDoc = new XmlDocument();
|
||||
ad = new AD();
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.Init() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog( exp );
|
||||
return( Common.STATUS_STORE_ADINITFAILED );
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:StoreDataInterface.StoreDataInterface() - END");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// AGGREGATE A SPECIFIC STORE
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the CCF from miCASA-D
|
||||
/// </summary>
|
||||
public static int AggregateStore(int storeIDentifier)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.AggregateStore()");
|
||||
|
||||
try
|
||||
{
|
||||
return( ad.AggregateStore(ccfDoc, storeIDentifier) );
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.AggregateStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
return( Common.STATUS_STORE_AGGREGATEFAILED );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// REFRESH ALL STORES
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the CCF from miCASA-D
|
||||
/// </summary>
|
||||
public static int RefreshAllStores()
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.RefreshAllStores() - BEGIN");
|
||||
|
||||
try
|
||||
{
|
||||
ccfDoc = ad.Aggregate();
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.RefreshAllStores() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
return( Common.STATUS_STORE_AGGREGATEFAILED );
|
||||
}
|
||||
Logger.DbgLog("GUI:StoreDataInterface.RefreshAllStores() - END");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// READ STORE
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GUI Data store
|
||||
/// </summary>
|
||||
public static int ReadStore(int storeIDentifier,ref Gtk.TreeStore ls)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.ReadStore()");
|
||||
|
||||
//Common Keys
|
||||
string storeChainKey = CCFXML_ELEMENT_MICASA_KEYCHAIN;
|
||||
|
||||
//TreeStore structure
|
||||
string secretID = null;
|
||||
string[] strKeyArray = null;
|
||||
string[] strValueArray = null;
|
||||
string storeID = null;
|
||||
string[] strNativeKeyArray = new string[Common.MAX_NATIVE_ELEMENTS];
|
||||
string[] strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
|
||||
|
||||
//Vars for ccf data
|
||||
string folderName = null;
|
||||
string typeID = null;
|
||||
string modifiedTime = null;
|
||||
string synch = null;
|
||||
string synchType = null;
|
||||
|
||||
//Flags & Variables
|
||||
bool bKey = false;
|
||||
bool bEndOfSecret = false;
|
||||
|
||||
//bool bEndOfTime=false;
|
||||
string ccfPath = null;
|
||||
|
||||
//Counters
|
||||
int noOfSecretsFound = 0;
|
||||
int noOfKeys = 0;
|
||||
int noOfKeysFound = 0;
|
||||
|
||||
//Init Native Information TypeNames
|
||||
strNativeKeyArray[Common.INDEX_NATIVEINFO_FOLDERNAME] = Common.NATIVEINFO_FOLDERNAME;
|
||||
strNativeKeyArray[Common.INDEX_NATIVEINFO_TYPEID] = Common.NATIVEINFO_TYPEID;
|
||||
strNativeKeyArray[Common.INDEX_NATIVEINFO_SYNC] = Common.NATIVEINFO_SYNC;
|
||||
strNativeKeyArray[Common.INDEX_NATIVEINFO_SYNCTYPE] = Common.NATIVEINFO_SYNCTYPE;
|
||||
strNativeKeyArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = Common.NATIVEINFO_MODIFIEDTIME;
|
||||
|
||||
//Form the XPATH Query definitions
|
||||
if( storeIDentifier == Common.STORE_MICASA )
|
||||
{
|
||||
ccfPath = "//CCF/miCASA";
|
||||
storeChainKey = CCFXML_ELEMENT_MICASA_KEYCHAIN;
|
||||
}
|
||||
else if( storeIDentifier == Common.STORE_GNOMEKEYRING )
|
||||
{
|
||||
ccfPath = "//CCF/GK";
|
||||
storeChainKey = CCFXML_ELEMENT_GKEYRING_KEYRING;
|
||||
}
|
||||
else if( storeIDentifier == Common.STORE_KDEWALLET )
|
||||
{
|
||||
ccfPath = "//CCF/KWallet";
|
||||
storeChainKey = CCFXML_ELEMENT_KWALLET_WALLET;
|
||||
}
|
||||
else
|
||||
return( Common.STATUS_STORE_INVALIDSTOREID );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
XPathNavigator nav = ccfDoc.CreateNavigator();
|
||||
XPathNodeIterator iter = null;
|
||||
string ccfExtPath = null;
|
||||
|
||||
//Query on the CCF and point to the store
|
||||
iter = nav.Select(ccfPath);
|
||||
if( 0 == iter.Count )
|
||||
return( Common.STATUS_STORE_DATANOTFOUNDINSTORE );
|
||||
|
||||
//Enumerate all store instances [storeID's-Keychain\Wallet\Profile\Keyring]
|
||||
while( iter.MoveNext() )
|
||||
{//Get Next Store instance. Ideally this should always be 1
|
||||
|
||||
//Get all descendants of this store. Ideally this should always be keychains
|
||||
//So this should get all keychains of this store.
|
||||
XPathNodeIterator iterSecret = iter.Current.SelectDescendants( XPathNodeType.Element,false );
|
||||
|
||||
while( iterSecret.MoveNext() )
|
||||
{//Enumerate this Keychain\Wallet\Profile\Keyring
|
||||
|
||||
if( true == iterSecret.Current.HasAttributes )
|
||||
{//Elements With attributes, get the attributes first before going to next sub element
|
||||
|
||||
if( iterSecret.Current.Name.Equals(storeChainKey) )
|
||||
{//miCASA-KeyChain //GK-Keyring //KWallet-Wallet
|
||||
|
||||
iterSecret.Current.MoveToFirstAttribute();
|
||||
do
|
||||
{
|
||||
//Keychain\Wallet\Profile\Keyring ID
|
||||
if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_ID) )
|
||||
{
|
||||
storeID = iterSecret.Current.Value;
|
||||
}
|
||||
|
||||
}while( iterSecret.Current.MoveToNextAttribute() );
|
||||
|
||||
iterSecret.Current.MoveToParent();
|
||||
}
|
||||
else if( iterSecret.Current.Name.Equals(CCFXML_ELEMENT_SECRET) )
|
||||
{//miCASA-KeyChain-Secret:secretID
|
||||
|
||||
noOfSecretsFound++;
|
||||
iterSecret.Current.MoveToFirstAttribute();
|
||||
do
|
||||
{
|
||||
if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_ID) )
|
||||
{
|
||||
secretID = iterSecret.Current.Value;
|
||||
}
|
||||
else if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_MICASA_SYNCH) )
|
||||
{
|
||||
synch = iterSecret.Current.Value;
|
||||
}
|
||||
else if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_GKEYRING_TYPE) )
|
||||
{
|
||||
synchType = iterSecret.Current.Value;
|
||||
}
|
||||
|
||||
}while( iterSecret.Current.MoveToNextAttribute() );
|
||||
|
||||
iterSecret.Current.MoveToParent();
|
||||
|
||||
//Now get more details about the secret
|
||||
//End of secret is after read of all keys of the secret
|
||||
{
|
||||
XPathNodeIterator secIter;
|
||||
ccfExtPath = "Key";
|
||||
secIter = iterSecret.Current.Select(ccfExtPath);
|
||||
noOfKeys = secIter.Count;
|
||||
|
||||
//Reinit arrays to the no of keys for this secret
|
||||
strKeyArray = new string[noOfKeys];
|
||||
strValueArray = new string[noOfKeys];
|
||||
|
||||
//Get Last Modified Time for the secret
|
||||
ccfExtPath = CCFXML_ELEMENT_TIME + "/" + CCFXML_ELEMENT_TIME_MODIFIED;
|
||||
secIter = iterSecret.Current.Select(ccfExtPath);
|
||||
|
||||
if( 0 != secIter.Count )
|
||||
{
|
||||
while( secIter.MoveNext() )
|
||||
{//Enumerate the Time Nodes of this secret
|
||||
if( secIter.Current.Name.Equals(CCFXML_ELEMENT_TIME_MODIFIED) )
|
||||
{//miCASA-KeyChain-Secret-Key-Value-Time-modified
|
||||
|
||||
modifiedTime = secIter.Current.Value;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if( iterSecret.Current.Name.Equals(CCFXML_ELEMENT_KEY) )
|
||||
{//miCASA-KeyChain-Secret-Key:ID
|
||||
iterSecret.Current.MoveToFirstAttribute();
|
||||
do
|
||||
{
|
||||
if( (iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_ID)) && (noOfKeysFound<=noOfKeys) )
|
||||
{
|
||||
bKey = true;
|
||||
strKeyArray[noOfKeysFound] = iterSecret.Current.Value; //KeyName
|
||||
}
|
||||
}while( iterSecret.Current.MoveToNextAttribute() );
|
||||
iterSecret.Current.MoveToParent();
|
||||
|
||||
}
|
||||
else if( iterSecret.Current.Name.Equals(CCFXML_ELEMENT_FOLDER) )
|
||||
{//Folder:
|
||||
iterSecret.Current.MoveToFirstAttribute();
|
||||
do
|
||||
{
|
||||
if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_FOLDERNAME) )
|
||||
{//Folder:Name
|
||||
folderName = iterSecret.Current.Value;
|
||||
}
|
||||
}while( iterSecret.Current.MoveToNextAttribute() );
|
||||
iterSecret.Current.MoveToParent();
|
||||
|
||||
}
|
||||
else if( iterSecret.Current.Name.Equals(CCFXML_ELEMENT_TYPE) )
|
||||
{//Type:
|
||||
iterSecret.Current.MoveToFirstAttribute();
|
||||
do
|
||||
{
|
||||
if( iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_ID) )
|
||||
{//Type:ID
|
||||
typeID = iterSecret.Current.Value;
|
||||
}
|
||||
}while( iterSecret.Current.MoveToNextAttribute() );
|
||||
iterSecret.Current.MoveToParent();
|
||||
|
||||
}
|
||||
}//Elements Without attributes,Get element values and then go to next subelement
|
||||
else if( iterSecret.Current.Name.Equals(CCFXML_ELEMENT_VALUE) )
|
||||
{//miCASA-KeyChain-Secret-Key-Value:<Value>
|
||||
if( true == bKey )
|
||||
{
|
||||
//Update Corresponding KeyValue
|
||||
strValueArray[noOfKeysFound++] = iterSecret.Current.Value; //KeyValue
|
||||
bKey = false;
|
||||
|
||||
//Are alll keys read? If so its the end of the secret
|
||||
if( noOfKeysFound == noOfKeys )
|
||||
bEndOfSecret = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Update this Secret to the GUI Store
|
||||
if( true == bEndOfSecret )
|
||||
{
|
||||
//Updating TreeStore Native Array structure
|
||||
strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
|
||||
|
||||
strNativeValueArray[Common.INDEX_NATIVEINFO_FOLDERNAME] = folderName;
|
||||
strNativeValueArray[Common.INDEX_NATIVEINFO_TYPEID] = typeID;
|
||||
strNativeValueArray[Common.INDEX_NATIVEINFO_SYNC] = synch;
|
||||
strNativeValueArray[Common.INDEX_NATIVEINFO_SYNCTYPE] = synchType;
|
||||
strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = modifiedTime;
|
||||
//Console.WriteLine("folderName="+folderName+"\n"+"typeID="+typeID+"\n"+"synch="+synch+"\n"+"synchType="+synchType+"\n"+"modifiedTime="+modifiedTime);
|
||||
|
||||
ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray);
|
||||
|
||||
//Re-Initialize for next iteration
|
||||
secretID = "";
|
||||
noOfKeysFound = 0;
|
||||
noOfKeys = 0;
|
||||
bKey = false;
|
||||
//bTime=false;- For Use Later
|
||||
bEndOfSecret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.ReadStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog( exp );
|
||||
return( Common.STATUS_STORE_READFAILED );
|
||||
}
|
||||
ShowDocOnConsole("READ STORE:");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// UPDATE STORE: ADD NEW secret/keyvalue, MODIFY keyvalue, DELETE secret
|
||||
|
||||
/// <summary>
|
||||
/// Supported Update Functionalities - on miCASA Store only
|
||||
/// </summary>
|
||||
public static int UpdateStore(int storeIDentifier,int operation,string keyID,string valueToBeModfied,ref TreeModel model,ref TreeIter iter)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore()");
|
||||
|
||||
//TreeStore row elements
|
||||
string SecretID = null;
|
||||
string keyChainID = null;
|
||||
string[] strKeyArray = new string[Common.MAX_ARRAY_ELEMENTS];
|
||||
string[] strValueArray = new string[Common.MAX_ARRAY_ELEMENTS];
|
||||
|
||||
|
||||
//XPATH query strings
|
||||
string ccfKeyChainPath = null;
|
||||
string ccfSecretPath = null;
|
||||
|
||||
//Intialization of New Secret\Key elements
|
||||
XmlElement newKeychainElement = ccfDoc.CreateElement(CCFXML_ELEMENT_MICASA_KEYCHAIN);
|
||||
XmlElement newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
|
||||
XmlElement newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
|
||||
|
||||
//Reading and Initialzing from the passed iter object
|
||||
SecretID = (string) model.GetValue (iter, 0);
|
||||
strKeyArray = (string[]) model.GetValue (iter, 1);
|
||||
strValueArray = (string[]) model.GetValue (iter, 2);
|
||||
keyChainID = (string) model.GetValue (iter, 3);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//Form the query to reach to an element for modify\delete\add
|
||||
if( Common.STORE_MICASA == storeIDentifier )
|
||||
{
|
||||
if( Common.OPERATION_MODIFY_KEY == operation || Common.OPERATION_DELETE_KEY == operation )
|
||||
{
|
||||
ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
{
|
||||
//ccfSecretPath="//CCF/miCASA/Keychain[@ID='"+keyChainID+"']/Secret[@ID='"+SecretID+"']";
|
||||
ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']";
|
||||
ccfSecretPath = "Secret[@ID='" + SecretID + "']";
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']";
|
||||
ccfSecretPath = "";
|
||||
|
||||
//Create the Secret element
|
||||
newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
|
||||
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_ID,SecretID);
|
||||
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_MICASA_SYNCH,"NSL");
|
||||
|
||||
//Add all keys from strKeyArray to the new secret
|
||||
for( int i=0; i< strKeyArray.Length; i++)
|
||||
{
|
||||
XmlElement newKey = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKey.SetAttribute(CCFXML_ATTRIBUTE_ID,strKeyArray[i]);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = strValueArray[i];
|
||||
newKey.AppendChild(newValue);
|
||||
newSecretElement.AppendChild(newKey);
|
||||
}
|
||||
|
||||
//Time
|
||||
XmlElement newTime = ccfDoc.CreateElement(CCFXML_ELEMENT_TIME);
|
||||
XmlElement newZone = ccfDoc.CreateElement(CCFXML_ELEMENT_TIME_ZONE);
|
||||
newZone.InnerText = "IST";
|
||||
newTime.AppendChild(newZone);
|
||||
XmlElement newCreateTime = ccfDoc.CreateElement(CCFXML_ELEMENT_TIME_CREATION);
|
||||
newCreateTime.InnerText = "1234";
|
||||
newTime.AppendChild(newCreateTime);
|
||||
XmlElement newModifiedTime = ccfDoc.CreateElement(CCFXML_ELEMENT_TIME_MODIFIED);
|
||||
newModifiedTime.InnerText = "5678";
|
||||
newTime.AppendChild(newModifiedTime);
|
||||
XmlElement newAccessedTime = ccfDoc.CreateElement(CCFXML_ELEMENT_TIME_ACCESSED);
|
||||
newAccessedTime.InnerText = "9012";
|
||||
newTime.AppendChild(newAccessedTime);
|
||||
newSecretElement.AppendChild(newTime);
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
ccfSecretPath = "";
|
||||
|
||||
//Create the Key element
|
||||
//strKeyArray[0]-[n] -If Support needed for multiple keys at once
|
||||
newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = valueToBeModfied;
|
||||
newKeyElement.AppendChild(newValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
return( Common.STATUS_STORE_UNSUPPORTEDOPERATION );
|
||||
|
||||
//Execute the query for modify\delete\add
|
||||
if( Common.OPERATION_MODIFY_KEY == operation )
|
||||
{
|
||||
//For Modify operation get to the Node in the tree which needs to be modified
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keylist = root.SelectNodes(ccfSecretPath);
|
||||
foreach ( XmlNode key in keylist )
|
||||
{
|
||||
key.ChildNodes[0].InnerText=valueToBeModfied ;
|
||||
ad.SetSecret(key.ParentNode,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
{
|
||||
//Delete the specific secret from the keychain
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
|
||||
foreach( XmlNode keychain in keychainNodeList )
|
||||
{
|
||||
XmlNodeList secretNodelist = keychain.SelectNodes(ccfSecretPath);
|
||||
foreach ( XmlNode secret in secretNodelist )
|
||||
{
|
||||
ad.Remove(secret,storeIDentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_KEY == operation )
|
||||
{
|
||||
//For Modify operation get to the Node in the tree which needs to be modified
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keylist = root.SelectNodes(ccfSecretPath);
|
||||
|
||||
foreach ( XmlNode key in keylist )
|
||||
{
|
||||
//key.ChildNodes[0].InnerText=valueToBeModfied ;
|
||||
XmlNode keyParentNode = key.ParentNode;
|
||||
key.ParentNode.RemoveChild(key);
|
||||
ad.SetSecret(keyParentNode,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
//Add a new secret to the keychain
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
|
||||
if( (null == keychainNodeList) || (0 == keychainNodeList.Count) )
|
||||
{
|
||||
newKeychainElement = ccfDoc.CreateElement(CCFXML_ELEMENT_MICASA_KEYCHAIN);
|
||||
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
|
||||
ccfKeyChainPath = "//CCF/miCASA";
|
||||
keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode miCASANode = keychainNodeList.Item(0);
|
||||
|
||||
if( null != miCASANode )
|
||||
{
|
||||
miCASANode.AppendChild(newKeychainElement);
|
||||
newKeychainElement.AppendChild(newSecretElement);
|
||||
ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
keychainNodeList = root.SelectNodes(ccfSecretPath);
|
||||
XmlNode SecretNode = keychainNodeList.Item(0);
|
||||
ad.SetSecret(SecretNode,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlNode keychain = keychainNodeList.Item(0);
|
||||
keychain.AppendChild(newSecretElement);
|
||||
XmlNode lastChild = keychain.LastChild;
|
||||
ad.SetSecret(lastChild,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
//Add a new KN\KV to the keychain-Secret
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keyNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode keyNode=keyNodeList.Item(0);
|
||||
XmlNode lastChild = keyNode.LastChild;
|
||||
keyNode.InsertBefore(newKeyElement,lastChild);
|
||||
ad.SetSecret(keyNode,storeIDentifier);
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog( exp );
|
||||
return( Common.STATUS_STORE_UPDATEFAILED );
|
||||
}
|
||||
|
||||
ShowDocOnConsole("UPDATE STORE:");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// DUMP THE XML CCF ON CONSOLE
|
||||
|
||||
/// <summary>
|
||||
/// Print Doc to the console for verification
|
||||
/// </summary>
|
||||
public static void ShowDocOnConsole(string str)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("\n#######################################################");
|
||||
Console.WriteLine(" "+str);
|
||||
Console.WriteLine("\n#######################################################");
|
||||
ccfDoc.Save(Console.Out);
|
||||
Console.WriteLine("\n#######################################################");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
///###########################################################################
|
||||
/// END OF FILE
|
||||
///###########################################################################
|
||||
310
c_gui/StorePolicyInterface.cs
Normal file
@@ -0,0 +1,310 @@
|
||||
///#################################################################
|
||||
/// PROJECT : CASA - Common Authentication Services Adapter
|
||||
/// FILE : StorePolicyInterface.cs
|
||||
/// DESCRIPTION : Implementation of Store Policy Interface for CASA.
|
||||
/// AUTHORS : Manohar, CSL.Manojna
|
||||
/// UPDATED ON : 24 Sept, 2005
|
||||
///#################################################################
|
||||
|
||||
|
||||
namespace Novell.CASA.GUI {
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Novell.CASA.CASAPolicy;
|
||||
using Novell.CASA;
|
||||
|
||||
|
||||
public class StorePolicyInterface
|
||||
{
|
||||
|
||||
private static AggregationPol aggPol;
|
||||
|
||||
private static string storeNameFirefox = null;
|
||||
private static string[] storeIdFirefox = new string[Common.MAX_STORES];
|
||||
private static int kFireFoxStoreCounter = 0;
|
||||
|
||||
private static string storeNameMozilla = null;
|
||||
private static string[] storeId_mozilla = new string[Common.MAX_STORES];
|
||||
private static int kMozillaStoreCounter = 0;
|
||||
|
||||
private static string storeNameKwallet = null;
|
||||
private static string[] storeIdKwallet = new string[Common.MAX_STORES];
|
||||
private static int kWalletStoreCounter = 0;
|
||||
|
||||
private static string storeNameGkeyring = null;
|
||||
private static string[] storeIdGkeyring = new string[Common.MAX_STORES];
|
||||
private static int kGkeyringStoreCounter = 0;
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// INIT
|
||||
|
||||
/// <summary>
|
||||
/// Init AggregationPolicy to the respective attributes
|
||||
/// </summary>
|
||||
public static int Init()
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - BEGIN");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL);
|
||||
if( null == aggPol )
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - No Aggregation Policy Found.");
|
||||
return( Common.STATUS_POLICY_POLICYNOTFOUND );
|
||||
}
|
||||
|
||||
ArrayList stores = aggPol.StoreList;
|
||||
IEnumerator enumerator = stores.GetEnumerator();
|
||||
|
||||
while( enumerator.MoveNext() )
|
||||
{
|
||||
if( ((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName.Equals(Common.STORENAME_KDEWALLET) )
|
||||
{
|
||||
Common.IS_KDEWALLET = true;
|
||||
storeNameKwallet = ((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName;
|
||||
storeIdKwallet[kWalletStoreCounter++] = ((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreId;
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - miCASA policy = " + Common.IS_MICASA);
|
||||
}
|
||||
else if(((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName.Equals(Common.STORENAME_GNOMEKEYRING))
|
||||
{
|
||||
Common.IS_GNOMEKEYRING=true;
|
||||
storeNameGkeyring=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName;
|
||||
storeIdGkeyring[kGkeyringStoreCounter++]=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreId;
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - GNOMEKEYRING policy = " + Common.IS_GNOMEKEYRING);
|
||||
}
|
||||
else if(((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName.Equals(Common.STORENAME_FIREFOX))
|
||||
{
|
||||
Common.IS_FIREFOX=true;
|
||||
storeNameFirefox=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName;
|
||||
storeIdFirefox[kFireFoxStoreCounter++]=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreId;
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - FIREFOX policy = " + Common.IS_FIREFOX);
|
||||
}
|
||||
else if(((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName.Equals(Common.STORENAME_MOZILLA))
|
||||
{
|
||||
Common.IS_MOZILLA=true;
|
||||
storeNameMozilla=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreName;
|
||||
storeId_mozilla[kMozillaStoreCounter++]=((Novell.CASA.CASAPolicy.Store)(enumerator.Current)).StoreId;
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - MOZILLA policy = " + Common.IS_MOZILLA);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
return( Common.STATUS_POLICY_POLICYNOTFOUND );
|
||||
}
|
||||
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.Init() - END");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// IS AGGREGATION POLICY ENABLED FOR STORE ?
|
||||
|
||||
/// <summary>
|
||||
/// Reports whether the aggregation policy is set for the store.
|
||||
/// </summary>
|
||||
public static bool IsAggregationPolicyEnabledFor(int storeIDentifier)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.isAggregationPolicyEnabledFor()");
|
||||
|
||||
if( Common.STORE_MICASA == storeIDentifier )
|
||||
return( Common.IS_MICASA );
|
||||
else if( Common.STORE_KDEWALLET == storeIDentifier )
|
||||
return( Common.IS_KDEWALLET );
|
||||
else if( Common.STORE_GNOMEKEYRING == storeIDentifier )
|
||||
return( Common.IS_GNOMEKEYRING );
|
||||
else if( Common.STORE_FIREFOX == storeIDentifier )
|
||||
return( Common.IS_FIREFOX );
|
||||
else if( Common.STORE_MOZILLA == storeIDentifier )
|
||||
return( Common.IS_MOZILLA );
|
||||
else
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.isAggregationPolicyEnabledFor() - STATUS_POLICY_POLICYNOTFOUND");
|
||||
//Common.ShowErrorDialog(Common.STATUS_POLICY_POLICYNOTFOUND);
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// GET LIST OF STORE IDs FOR A STORE
|
||||
|
||||
/// <summary>
|
||||
/// Get Aggregation Policy - storeId
|
||||
/// </summary>
|
||||
public static string[] GetAggregationPolicyStoreIDFor(int storeIDentifier)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.getAggregationPolicyStoreIDFor()");
|
||||
|
||||
if( Common.STORE_KDEWALLET == storeIDentifier )
|
||||
return( storeIdKwallet );
|
||||
else if( Common.STORE_GNOMEKEYRING == storeIDentifier )
|
||||
return( storeIdGkeyring );
|
||||
else if( Common.STORE_FIREFOX == storeIDentifier )
|
||||
return( storeIdFirefox );
|
||||
else if( Common.STORE_MOZILLA == storeIDentifier )
|
||||
return( storeId_mozilla );
|
||||
else
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.getAggregationPolicyStoreIDFor() - STATUS_POLICY_POLICYNOTFOUND");
|
||||
//Common.ShowErrorDialog(Common.STATUS_POLICY_POLICYNOTFOUND);
|
||||
return( null );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// SET AGGREGATION POLICY FOR A STORE
|
||||
|
||||
/// <summary>
|
||||
/// Set Aggregation Policy for a perticular store.
|
||||
/// </summary>
|
||||
public static void SetAggregationPolicy(int storeIDentifier,bool status,string[] storeId,int numberOfStoreIds)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SetAggregationPolicy()");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if( storeIDentifier == Common.STORE_KDEWALLET )
|
||||
{
|
||||
Common.IS_KDEWALLET=status;
|
||||
storeNameKwallet=Common.STORENAME_KDEWALLET;
|
||||
storeIdKwallet=storeId;
|
||||
kWalletStoreCounter=numberOfStoreIds;
|
||||
}
|
||||
else if( storeIDentifier == Common.STORE_GNOMEKEYRING )
|
||||
{
|
||||
Common.IS_GNOMEKEYRING=status;
|
||||
storeNameGkeyring=Common.STORENAME_GNOMEKEYRING;
|
||||
storeIdGkeyring=storeId;
|
||||
kGkeyringStoreCounter=numberOfStoreIds;
|
||||
}
|
||||
else if( storeIDentifier == Common.STORE_MOZILLA )
|
||||
{
|
||||
Common.IS_MOZILLA=status;
|
||||
storeNameMozilla=Common.STORENAME_MOZILLA;
|
||||
storeId_mozilla=storeId;
|
||||
kMozillaStoreCounter=numberOfStoreIds;
|
||||
}
|
||||
else if( storeIDentifier == Common.STORE_FIREFOX )
|
||||
{
|
||||
Common.IS_FIREFOX=status;
|
||||
storeNameFirefox=Common.STORENAME_FIREFOX;
|
||||
storeIdFirefox=storeId;
|
||||
kFireFoxStoreCounter=numberOfStoreIds;
|
||||
}
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SetAggregationPolicy() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// SAVE AGGREGATION POLICY
|
||||
|
||||
/// <summary>
|
||||
/// Save Aggregation Policy
|
||||
/// </summary>
|
||||
public static int SaveAggregationPolicy()
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SaveAggregationPolicy()");
|
||||
|
||||
ArrayList storeList = new ArrayList();
|
||||
Novell.CASA.CASAPolicy.Store store = null;
|
||||
|
||||
if( true == Common.IS_KDEWALLET )
|
||||
{
|
||||
for(int i=0; i < kWalletStoreCounter; i++)
|
||||
{
|
||||
store = new Novell.CASA.CASAPolicy.Store(storeNameKwallet,storeIdKwallet[i]);
|
||||
storeList.Add(store);
|
||||
}
|
||||
}
|
||||
|
||||
if( true == Common.IS_GNOMEKEYRING )
|
||||
{
|
||||
for(int i=0; i < kGkeyringStoreCounter; i++)
|
||||
{
|
||||
store = new Novell.CASA.CASAPolicy.Store(storeNameGkeyring,storeIdGkeyring[i]);
|
||||
storeList.Add(store);
|
||||
}
|
||||
}
|
||||
|
||||
if( true == Common.IS_FIREFOX )
|
||||
{
|
||||
for(int i=0; i < kFireFoxStoreCounter; i++)
|
||||
{
|
||||
store = new Novell.CASA.CASAPolicy.Store(storeNameFirefox,storeIdFirefox[i]);
|
||||
storeList.Add(store);
|
||||
}
|
||||
}
|
||||
|
||||
if( true == Common.IS_MOZILLA )
|
||||
{
|
||||
for(int i=0; i < kMozillaStoreCounter; i++)
|
||||
{
|
||||
store = new Novell.CASA.CASAPolicy.Store(storeNameMozilla,storeId_mozilla[i]);
|
||||
storeList.Add(store);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AggregationPol aggPol = new AggregationPol(storeList);
|
||||
|
||||
if( true == ICASAPol.SetPolicy(aggPol) )
|
||||
return( Common.STATUS_SUCCESS );
|
||||
else
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SaveAggregationPolicy() - STATUS_POLICY_COULDNOTBESAVED");
|
||||
//Common.ShowErrorDialog(Common.STATUS_POLICY_COULDNOTBESAVED);
|
||||
return( Common.STATUS_POLICY_COULDNOTBESAVED );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// SET MASTER PASSWORD
|
||||
|
||||
/// <summary>
|
||||
/// Set Master Password for miCASA persistent store
|
||||
/// </summary>
|
||||
public static void SetMasterPassword(string passWord)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SetMasterPassword()");
|
||||
|
||||
try
|
||||
{
|
||||
Novell.CASA.miCASA.SetMasterPassword(0,passWord);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StorePolicyInterface.SetMasterPassword() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
///###########################################################################
|
||||
/// END OF FILE
|
||||
///###########################################################################
|
||||
BIN
c_gui/images/CASA_16.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
c_gui/images/CASA_32.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
c_gui/images/CASA_48.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
6150
c_gui/images/casa-1.5.glade
Normal file
9
c_gui/images/casa-1.5.gladep
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
|
||||
|
||||
<glade-project>
|
||||
<name>Casa-1.5</name>
|
||||
<program_name>casa-1.5</program_name>
|
||||
<pixmaps_directory></pixmaps_directory>
|
||||
<gnome_support>FALSE</gnome_support>
|
||||
</glade-project>
|
||||
BIN
c_gui/images/casa-logo.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
c_gui/images/firefox-logo.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
c_gui/images/keyring-logo.png
Normal file
|
After Width: | Height: | Size: 875 B |
BIN
c_gui/images/kwallet-logo.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
c_gui/images/micasa-logo.png
Normal file
|
After Width: | Height: | Size: 397 B |
BIN
c_gui/images/mozilla-logo.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
c_gui/images/novell-logo.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
12
c_gui/objs.lux
Normal file
@@ -0,0 +1,12 @@
|
||||
OBJS=\
|
||||
CasaMain \
|
||||
Firefox \
|
||||
GnomeKeyring \
|
||||
KdeWallet \
|
||||
Logger \
|
||||
MiCasa \
|
||||
Mozilla \
|
||||
Store \
|
||||
StoreDataInterface \
|
||||
StorePolicyInterface \
|
||||
Common
|
||||
13
c_gui/src.lux
Normal file
@@ -0,0 +1,13 @@
|
||||
SRC=\
|
||||
CasaMain.cs \
|
||||
Firefox.cs \
|
||||
GnomeKeyring.cs \
|
||||
KdeWallet.cs \
|
||||
Logger.cs \
|
||||
MiCasa.cs \
|
||||
Mozilla.cs \
|
||||
Store.cs \
|
||||
StoreDataInterface.cs \
|
||||
StorePolicyInterface.cs \
|
||||
Common.cs
|
||||
|
||||