- Distribution of Firefox Password Manager secrets.

This commit is contained in:
smanojna 2006-09-29 11:41:27 +00:00
parent 66b98cc0d0
commit 1cd3c566a7
18 changed files with 18626 additions and 17439 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Sep 29 17:10:23 IST 2006 - smanojna@novell.com
- Distribution of Firefox Password Manager secrets.
-------------------------------------------------------------------
Wed Sep 27 15:10:47 MDT 2006 - jnorman@novell.com

View File

@ -326,6 +326,15 @@ namespace Novell.CASA.DataEngines
}
public static String GetDefaultProfileName(int StoreID)
{
if (StoreID == ConstStrings.CASA_STORE_FFOX)
return FFEngine.GetDefaultProfileName();
else
return null;
}
/*******************************************************************************
Remove will delete a Secret.

View File

@ -74,6 +74,11 @@ namespace Novell.CASA.DataEngines
FireFox.UninitProfile(defaultProfileName);
}
public static String GetDefaultProfileName()
{
return FireFox.GetDefaultProfileName();
}
public XmlNode Aggregate()
{
@ -169,6 +174,9 @@ namespace Novell.CASA.DataEngines
}
newHost.hostElement = next;
if (opnType == ConstStrings.OPERATION_ADD_SECRET)
retVal = FireFox.Add_Host(ProfileName,newHost,1);
else
retVal = FireFox.Modify_Host(ProfileName,newHost,1);
}
catch(Exception e)

View File

@ -174,6 +174,8 @@ namespace Novell.CASA.DataEngines.FF
//Signon functions
[DllImport(FF_LIB)]
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh);
[DllImport(FF_LIB)]
public static extern int FPM_AddHost(string profileName, Host host, int doUpdate);
[DllImport(FF_LIB)]
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
@ -183,7 +185,6 @@ namespace Novell.CASA.DataEngines.FF
//TBD
//int FPM_WriteSignonData(char *profileName)
//int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
public static int IsStoreAvailable()
{
@ -195,6 +196,11 @@ namespace Novell.CASA.DataEngines.FF
return (FPM_RemoveHost(ProfileName, hostName, 1));
}
public static int Add_Host(string profileName, Host ahost, int doUpdate)
{
return FPM_AddHost(profileName, ahost, 1);
}
public static int Modify_Host(string profileName, Host mhost, int doUpdate)
{
//Console.WriteLine("FireFox.cs : ProfileName : " + profileName);

View File

@ -113,3 +113,29 @@ int IsDirectoryExists( char *path )
}
/**
* Creates a directory in specified path
*
* return MC_TRUE if directory successfully created else MC_FALSE
*
*/
int CreateDirectory( char *path )
{
if( path == NULL )
return 0;
#ifdef WIN32
int result = mkdir(path);
#else
int result = mkdir(path, S_IRWXU);
#endif
if( result != 0 )
{
PrintMessage(MESG_ERROR, "\n CreateDirectory : Can't create Directory : [%s] ", path);
return 0;
}
return 1;
}

View File

@ -36,6 +36,8 @@ void CryptManager::SetupFunctions(void *funList[])
PK11SDREncrypt = (PK11SDR_Encrypt) funList[6];
PLBase64Encode = (PL_Base64Encode) funList[7];
PLBase64Decode = (PL_Base64Decode) funList[8];
PK11NeedUserInit = (PK11_NeedUserInit) funList[9];
PK11InitPin = (PK11_InitPin) funList[10];
}

View File

@ -38,6 +38,8 @@ class CryptManager
PK11_CheckUserPassword PK11CheckUserPassword;
PK11SDR_Decrypt PK11SDRDecrypt;
PK11SDR_Encrypt PK11SDREncrypt;
PK11_NeedUserInit PK11NeedUserInit;
PK11_InitPin PK11InitPin;
PL_Base64Encode PLBase64Encode;
PL_Base64Decode PLBase64Decode;

View File

@ -222,6 +222,9 @@ int DataManager::AddHost(Host *host)
{
Host *t;
char *temp = (char *) malloc(sizeof(char)*(strlen(host->hostName)+3));
strcpy (temp, host->hostName);
strncat (temp, " (", 2);
if( host == NULL )
{
@ -232,10 +235,32 @@ Host *t;
for(t=hostList; t ; t=t->next)
{
if( STRCMPI(host->hostName, t->hostName) == 0 )
{
if( STRCMPI(host->child->value, t->child->value) == 0)
{
PrintMessage(MESG_ERROR, "\n AddHost : Specified hostname %s is already present..", host->hostName);
return FPM_FALSE;
}
else
{
strncat (t->hostName, " (", 2);
strncat (t->hostName, t->child->value, strlen(t->child->value));
strncat (t->hostName, ")", 1);
strncat (host->hostName, " (", 2);
strncat (host->hostName, host->child->value, strlen(host->child->value));
strncat (host->hostName, ")", 1);
break;
}
}
if( strncmp(t->hostName, temp, strlen(host->hostName)+2) == 0)
{
strncat (host->hostName, " (", 2);
strncat (host->hostName, host->child->value, strlen(host->child->value));
strncat (host->hostName, ")", 1);
break;
}
}
Host *newHost = DuplicateHost(host);

View File

@ -65,7 +65,78 @@ extern "C" APIEXPORT int FPM_IsStoreAvailable()
* returned and negative values is returned if there is an error.
*
*/
int WriteCharUTF8(Unichar c, FILE *profile)
{
if (c <= 0x7F)
{
if( fputc((char)c, profile) == EOF )
return FPM_FALSE;
}
else if (c <= 0x7FF)
{
if( fputc( ((Unichar)0xC0) | ((c>>6) & 0x1F), profile) == EOF )
return FPM_FALSE;
if( fputc( ((Unichar)0x80) | (c & 0x3F), profile ) == EOF )
return FPM_FALSE;
}
else
{
if( fputc( ((Unichar)0xE0) | ((c>>12) & 0xF), profile) == EOF )
return FPM_FALSE;
if( fputc( ((Unichar)0x80) | ((c>>6) & 0x3F), profile) == EOF)
return FPM_FALSE;
if( fputc( ((Unichar)0x80) | (c & 0x3F), profile) == EOF)
return FPM_FALSE;
}
return FPM_TRUE;
}
int WriteLine(char *line, FILE *profile)
{
for(unsigned int i=0; i < strlen(line); i++)
{
if( WriteCharUTF8(line[i], profile) != FPM_TRUE )
return FPM_FALSE;
}
if( WriteCharUTF8('\n', profile) != FPM_TRUE )
return FPM_FALSE;
return FPM_TRUE;
}
int CreateNewProfile(char *profilePath, char *profileDir)
{
FILE *profile = fopen(profilePath, "a");
if(profile == NULL)
return FPM_FALSE;
WriteLine("[General]", profile);
WriteLine("StartWithLastProfile=1", profile);
WriteLine("", profile);
WriteLine("[Profile0]", profile);
WriteLine("Name=default", profile);
WriteLine("IsRelative=1", profile);
char *path = (char *)malloc(sizeof(char)*(strlen(profileDir)+10));
if(path ==NULL)
return FPM_FALSE;
strcpy(path,"Path=");
strncat(path,profileDir,strlen(profileDir));
WriteLine(path, profile);
free(path);
WriteLine("Default=1", profile);
WriteLine("", profile);
fclose(profile);
return FPM_TRUE;
}
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFlag[])
{
@ -73,6 +144,7 @@ extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFl
char profileDir[MAX_PATH] = "";
char partialPath[] = "Application Data\\Mozilla\\Firefox";
char firefoxDir[MAX_PATH] = "";
char profilePath[MAX_PATH];
char line[1024];
@ -102,6 +174,7 @@ extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFl
strcpy(profilePath, profileDir);
strcat(profilePath,"\\");
strcat(profilePath,partialPath);
strcpy(firefoxDir, profilePath);
strcat(profilePath,"\\profiles.ini");
PrintMessage(MESG_DEBUG, "\n GetProfileList : Firefox profile dir path = %s ", profilePath);
@ -147,6 +220,53 @@ extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFl
if( profile == NULL )
{
PrintMessage(MESG_ERROR, "\n GetProfileList : Unable to find firefox profile file : %s ", profilePath);
//create new profile.ini and the profile directory
#ifdef WIN32
#else
char *firefoxDir = (char *) malloc(sizeof(char) * (strlen(profileDir)+strlen(homeDir)+10));
strcpy(firefoxDir, homeDir);
strncat(firefoxDir, "/", 1);
strncat(firefoxDir, profileDir, strlen(profileDir));
#endif
if (!IsDirectoryExists(firefoxDir))
{
PrintMessage(MESG_DEBUG, "\n Directory does not exist");
if ( CreateDirectory(firefoxDir) !=1)
{
PrintMessage(MESG_DEBUG, "\n Can't create Dir");
return FPM_FALSE;
}
PrintMessage(MESG_DEBUG, "\n Directory successfully created");
}
char *randdir = (char *) malloc(sizeof(char) * 20);
srand(time(0));
for( int i=0; i<8; i++)
{
if( rand()%2==1)
randdir[i] = 48 + (rand()%10);
else
randdir[i] = 97 + (rand()%26);
}
randdir[8]='\0';
strncat(randdir, ".default",8);
if (CreateNewProfile(profilePath, randdir) == FPM_TRUE)
{
profile = fopen(profilePath, "r");
char *dir = (char *) malloc(strlen(firefoxDir)+20);
strcpy(dir, firefoxDir);
#ifdef WIN32
strncat(dir, "\\", 2);
#else
strncat(dir, "/",1);
#endif
strncat(dir, randdir,strlen(randdir));
if( CreateDirectory(dir) != 1)
return FPM_FALSE;
}
else
return FPM_FALSE;
}

View File

@ -31,10 +31,13 @@
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef WIN32
#include <windows.h>
#include <userenv.h>
#include <direct.h>
#pragma comment(lib,"userenv.lib")
#define STRCMPI strcmpi
@ -150,6 +153,9 @@ typedef SECStatus (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCert
typedef SECStatus (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw);
typedef SECStatus (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx);
typedef SECStatus (*PK11SDR_Encrypt) (SECItem *keyid, SECItem *data, SECItem *result, void *cx);
typedef PRBool (*PK11_NeedUserInit) (PK11SlotInfo *slot);
typedef SECStatus (*PK11_InitPin) (PK11SlotInfo *slot,char *ssopw, char *pk11_userpwd);
typedef SECStatus (*NSS_InitReadWrite) (const char *configdir);
// PLC Library functions
typedef char * (*PL_Base64Encode)( const char *src, PRUint32 srclen, char *dest);
@ -158,6 +164,7 @@ typedef char * (*PL_Base64Decode)( const char *src, PRUint32 srclen, cha
void PrintMessage( int level, char *mesg , ...);
int IsDirectoryExists( char *path );
void StrLwr(char *str);
int CreateDirectory( char *path );

View File

@ -606,8 +606,11 @@ int ProfileManager::ProfileInit(char *profileName)
PK11SDRDecrypt = (PK11SDR_Decrypt) GETPROCADDRESS(libnss, "PK11SDR_Decrypt");
PK11SDREncrypt = (PK11SDR_Encrypt) GETPROCADDRESS(libnss, "PK11SDR_Encrypt");
PK11CheckUserPassword = (PK11_CheckUserPassword) GETPROCADDRESS(libnss, "PK11_CheckUserPassword");
PK11NeedUserInit = (PK11_NeedUserInit) GETPROCADDRESS(libnss, "PK11_NeedUserInit");
PK11InitPin = (PK11_InitPin) GETPROCADDRESS(libnss, "PK11_InitPin");
NSSInitReadWrite = (NSS_InitReadWrite) GETPROCADDRESS(libnss, "NSS_InitReadWrite");
if( !NSSInit || !NSSShutdown || !PK11GetInternalKeySlot || !PK11Authenticate || !PK11SDRDecrypt || !PK11SDREncrypt || !PK11FreeSlot || !PK11CheckUserPassword)
if( !NSSInit || !NSSShutdown || !PK11GetInternalKeySlot || !PK11Authenticate || !PK11SDRDecrypt || !PK11SDREncrypt || !PK11FreeSlot || !PK11CheckUserPassword || !PK11NeedUserInit || !PK11InitPin || !NSSInitReadWrite )
{
PrintMessage(MESG_ERROR, "\n\n ProfileInit : Failed to get function address for library %s ", NSS_LIBRARY_NAME);
ProfileExit();
@ -625,17 +628,45 @@ int ProfileManager::ProfileInit(char *profileName)
return FPM_LIBRARY_LOAD_FAILED;
}
// Initialize the NSS library
if( (*NSSInit) (profilePath) != SECSuccess )
if( (*NSSInitReadWrite) (profilePath) != SECSuccess )
{
PrintMessage(MESG_ERROR, "\n ProfileInit : Initialization failed , Make sure key3.db and cert8.db");
PrintMessage(MESG_ERROR, "\n files are present in the specified directory\n");
PrintMessage(MESG_ERROR, "\n ProfileInit : Initialization failed ");
ProfileExit();
return FPM_LIBRARY_INIT_FAILED;
}
else
{
PrintMessage(MESG_DEBUG, "\n ProfileInit : Initialization Success ");
PK11SlotInfo *slot = 0;
slot = (*PK11GetInternalKeySlot)();
if (!slot)
{
PrintMessage(MESG_ERROR, "\n ProfileInit PK11_GetInternalKeySlot failed ...");
return FPM_FALSE;
}
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
if (PK11NeedUserInit(slot) == true)
{
PrintMessage(MESG_DEBUG, "\n ProfileInit : Initialization required");
if(PK11InitPin(slot, "", "") != SECSuccess)
{
PrintMessage(MESG_DEBUG, "\n ProfileInit : InitPin Failed ");
(*PK11FreeSlot) (slot);
return FPM_FALSE;
}
PrintMessage(MESG_DEBUG, "\n ProfileInit : InitPin Succeeded ");
}
else
PrintMessage(MESG_DEBUG, "\n ProfileInit : Initialization not required");
(*PK11FreeSlot) (slot);
}
PrintMessage(MESG_DEBUG, "\n ProfileInit : NSS_Init success..");
@ -656,7 +687,7 @@ int ProfileManager::ProfileInit(char *profileName)
isInitialized = FPM_TRUE;
// Setup the function pointers...
void *funList[9];
void *funList[11];
funList[0] = (void*)NULL ; //PK11SetPasswordFunc;
funList[1] = (void*)PK11GetInternalKeySlot;
@ -667,6 +698,8 @@ int ProfileManager::ProfileInit(char *profileName)
funList[6] = (void*)PK11SDREncrypt;
funList[7] = (void*)PLBase64Encode;
funList[8] = (void*)PLBase64Decode;
funList[9] = (void*)PK11NeedUserInit;
funList[10] = (void*)PK11InitPin;
signonManager.SetupFunctions(funList);

View File

@ -50,6 +50,9 @@ class ProfileManager
PK11_CheckUserPassword PK11CheckUserPassword;
PK11SDR_Decrypt PK11SDRDecrypt;
PK11SDR_Encrypt PK11SDREncrypt;
PK11_NeedUserInit PK11NeedUserInit;
PK11_InitPin PK11InitPin;
NSS_InitReadWrite NSSInitReadWrite;
PL_Base64Encode PLBase64Encode;
PL_Base64Decode PLBase64Decode;

View File

@ -78,10 +78,26 @@ char *signonFilePath = NULL;
if( signonFile == NULL )
{
PrintMessage(MESG_ERROR, "\n SignonManager : Error opening signon file %s", signonFilePath);
PrintMessage(MESG_DEBUG, "\n SignonManager : Error opening signon file %s", signonFilePath);
PrintMessage(MESG_DEBUG, "\n SignonManager : Creating new signon file %s", signonFilePath);
if((signonFile = fopen(signonFilePath, "a")) == NULL)
{
PrintMessage(MESG_ERROR, "\n SignonManager : Error creating signon file %s", signonFilePath);
free(signonFilePath);
return FPM_SIGNON_FILE_NOT_PRESENT;
}
if( WriteLine(HEADER_VERSION) != FPM_TRUE)
{
PrintMessage(MESG_ERROR, "\n SignonManager : Error writing header to new signon file %s", signonFilePath);
free(signonFilePath);
fclose(signonFile);
return FPM_SIGNON_FILE_NOT_PRESENT;
}
fclose(signonFile);
signonFile = fopen(signonFilePath, accessType);
}
// cleanup
free(signonFilePath);
@ -238,7 +254,7 @@ int SignonManager::WriteCharUTF8(Unichar c)
int SignonManager::WriteLine(char *line)
{
for(int i=0; i < strlen(line); i++)
for(unsigned int i=0; i < strlen(line); i++)
{
if( WriteCharUTF8(line[i]) != FPM_TRUE )
return FPM_SIGNON_FILE_WRITE_ERROR;
@ -269,6 +285,7 @@ char name[1024];
int bufferLength = 4095;
int retValue;
char *clearData = NULL;
char *newHostName, *uname;
int count = 0;
@ -349,6 +366,7 @@ int count = 0;
PrintMessage(MESG_DEBUG, "\n\n Host : %s ", hostName);
// prepare to read the name/value pairs
count = 0;
while( ReadLine(buffer, bufferLength) == FPM_TRUE )
{
// line starting with . terminates the pairs for this URL entry
@ -371,6 +389,7 @@ int count = 0;
strcpy(name, buffer);
retValue = ReadLine(buffer, bufferLength);
}
count++;
PrintMessage(MESG_DEBUG, "\n\n name = %s and value = %s ", name, buffer);
@ -390,6 +409,26 @@ int count = 0;
if( ((retValue = cryptManager.DecryptString(buffer, &clearData)) == FPM_TRUE) && (clearData != NULL) )
{
// Add the name/value pair to the existing store....
if (count == 1)
{
uname = (char *) malloc(strlen(clearData)*sizeof(char));
strcpy(uname, clearData);
}
if (count>2)
{
if(count%2==1)
{
newHostName = (char *)malloc((strlen(hostName)+strlen(clearData)+4)*sizeof(char));
strcpy(newHostName,hostName);
strncat(newHostName, " (", 2);
strncat(newHostName,clearData, strlen(clearData));
strncat(newHostName, ")", 1);
dataManager.AddHost(newHostName);
}
retValue = dataManager.AddHostElement(newHostName, name, clearData, isPassword);
}
else
retValue = dataManager.AddHostElement(hostName, name, clearData, isPassword);
if( retValue != FPM_TRUE )
@ -409,13 +448,20 @@ int count = 0;
}
}
if (count >2)
{
newHostName = (char *)malloc((strlen(hostName)+strlen(uname)+4)*sizeof(char));
strcpy(newHostName,hostName);
strncat(newHostName, " (", 2);
strncat(newHostName, uname, strlen(uname));
strncat(newHostName, ")", 1);
dataManager.ModifyHost(hostName, newHostName);
}
}
// Now close the signon file
CloseSignonFile();
// Print data for cross checking
#ifdef DEBUG
dataManager.PrintAllRejectHosts();
@ -434,9 +480,11 @@ char *signonFilePath = NULL;
char *tempFilePath = NULL;
char fileName[256];
Host *t;
HostElement *h;
Host *writeList, *newHost;
HostElement *h, *temp;
RejectHost *r;
char *hn2;
int len;
// TODO : If signon data has not changed since last write then return...
/* // There may be requirement to write empty data...
@ -499,9 +547,55 @@ RejectHost *r;
* if type is password, name is preceded by an asterisk (*)
*/
//copy list
writeList = NULL;
temp = NULL;
newHost = NULL;
for(Host *host=dataManager.hostList;host;host=host->next)
{
if(writeList == NULL)
{
writeList = dataManager.DuplicateHost(host);
newHost = writeList;
newHost->next = NULL;
}
else
{
newHost->next = dataManager.DuplicateHost(host);
newHost = newHost->next;
newHost->next = NULL;
}
}
// create list to write
hn2 = (char *) malloc(sizeof(char)*100);
Host *t1;
Host *pre;
for(Host *t=writeList; t; t=t->next)
{
if((hn2=strstr(t->hostName," ("))!=NULL)
{
len = strlen(t->hostName);
t->hostName[len-strlen(hn2)]='\0';
pre = t;
for(t1=t->next; t1; t1=t1->next)
{
if(strncmp(t->hostName, t1->hostName, strlen(t->hostName))==0)
{
for(temp=t->child; temp->next!=NULL; temp=temp->next);
temp->next = t1->child;
pre->next = t1->next;
t1 = pre;
}
pre=t1;
}
}
}
// write out each URL node
for(t=dataManager.hostList; t ; t=t->next)
for(Host *t=writeList; t ; t=t->next)
{
PrintMessage(MESG_DEBUG, "\n\nWriteSignonData : Adding name/value pairs for host %s", t->hostName);

View File

@ -916,11 +916,12 @@ namespace Novell.CASA.GUI
case Common.STORE_FIREFOX:
if( 0 != objFirefox.tvSecretIDFirefox.Selection.CountSelectedRows() )
{
mmiNew.Sensitive = mmiNewKey.Sensitive = false;
mmiNew.Sensitive = true;
mmiNewKey.Sensitive = true;
}
else
{
mmiNew.Sensitive = mmiNewKey.Sensitive = false;
mmiNewKey.Sensitive = false;
}
break;
@ -1194,6 +1195,7 @@ namespace Novell.CASA.GUI
break;
case Common.STORE_FIREFOX:
objFirefox.OnNewSecretActivated(obj, args);
break;
case Common.STORE_MOZILLA:
@ -1232,6 +1234,7 @@ namespace Novell.CASA.GUI
break;
case Common.STORE_FIREFOX:
objFirefox.OnNewKeyActivated(obj, args);
break;
case Common.STORE_MOZILLA:

View File

@ -100,7 +100,8 @@ public class Common
OPERATION_ADD_KEY = 1,
OPERATION_MODIFY_KEY = 2,
OPERATION_DELETE_SECRET = 3,
OPERATION_DELETE_KEY = 4;
OPERATION_DELETE_KEY = 4,
OPERATION_MODIFY_SECRET = 5;
//Limits
public static int MAX_ARRAY_ELEMENTS = 10;

View File

@ -38,12 +38,18 @@ public class Firefox : Store
tsKeyValue;
CellRendererText cellEditable;
CellRendererToggle cellToggle;
ArrayList arrDeletedKeys = null;
bool isPasswordToggled;
public bool IS_STORE_AGGREGATED = false;
private int m_iRememberSeconds = 5;
private String m_sRememberFor = "5";
private Config m_config = null;
static Char[] SpecialCharacters = new Char[]{ '*', '\'', '\\', '&', '=', '<', '>' };
#region Glade Widgets
[Glade.Widget]
@ -60,6 +66,7 @@ public class Firefox : Store
dialogManageSecret,
dialogLogin,
dialogConfirmDelete,
dialogInvalidSecret,
dialogSpecialCharacter;
[Glade.Widget]
@ -112,7 +119,7 @@ public class Firefox : Store
m_config = config;
/// SecretID TreeStore
tvSecretIDFirefox = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDFirefox");
tsSecretIDFirefox = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
tsSecretIDFirefox = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]), typeof(bool[]));
tvSecretIDFirefox.AppendColumn("Secret ID",new CellRendererText(),"text",0);
tvSecretIDFirefox.Model = tsSecretIDFirefox;
tvSecretIDFirefox.RowActivated += new RowActivatedHandler(OntvSecretIDFirefoxRowActivated);
@ -213,9 +220,15 @@ public class Firefox : Store
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() )
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = false;
{
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = true;
cmiLink.Sensitive = cmiCopy.Sensitive = false;
}
else
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiDelete.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiView.Sensitive = false;
{
cmiNewSecret.Sensitive = true;
cmiNewKey.Sensitive = cmiDelete.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiView.Sensitive = false;
}
}
catch(Exception exp)
{
@ -240,14 +253,22 @@ public class Firefox : Store
string selected= null;
string[] keys = null,
values = null;
bool[] ispassword = null;
isPasswordToggled = false;
try
{
if( null == arrDeletedKeys )
arrDeletedKeys = new ArrayList();
else
arrDeletedKeys.Clear();
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
{
selected = (string) model.GetValue(iter, 0);
keys = (string[]) model.GetValue(iter, 1);
values = (string[]) model.GetValue(iter, 2);
ispassword = (bool[]) model.GetValue(iter, 6);
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null);
gxmlTemp.Autoconnect (this);
@ -257,23 +278,26 @@ public class Firefox : Store
cellEditable = new CellRendererText();
cellEditable.Editable = true;
cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
//cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string));
cellToggle = new CellRendererToggle();
cellToggle.Activatable = true;
cellToggle.Toggled += OnIsPasswordToggled;
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 ISPASSWORD:5
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string),typeof(bool));
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Password", cellToggle, "active", 5);
tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4);
entrySecretID.MaxLength=1028;
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, "No");
tsKeyValue.AppendValues(keys[i], values[i], "********", false, "No", ispassword[i]);
}
tvKeyValue.Model = tsKeyValue;
//entryKey.HasFocus = true;
entryKey.Sensitive = entryValue.Sensitive = buttonNewAdd.Sensitive = buttonNewRemove.Sensitive = false;
}
}
catch(Exception exp)
@ -284,6 +308,46 @@ public class Firefox : Store
Logger.DbgLog("GUI:Firefox.ViewKeyValues() - END");
}
/// <summary>
/// TOGGLE ISPASSWORD
///</summary>
public void OnIsPasswordToggled(object obj, ToggledArgs args)
{
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - BEGIN");
TreeIter iter;
bool old;
string keyID;
try
{
if (tsKeyValue.GetIter (out iter, new TreePath(args.Path)))
{
isPasswordToggled = true;
old = (bool)tsKeyValue.GetValue(iter,5);
keyID = tsKeyValue.GetValue(iter,0).ToString();
tsKeyValue.SetValue(iter, 5, !old);
if (tsKeyValue.IterNChildren()==2)
{
tsKeyValue.GetIterFirst(out iter);
do
{
if(!(tsKeyValue.GetValue(iter,0).ToString().Equals(keyID)))
tsKeyValue.SetValue(iter, 5, old);
}while (tsKeyValue.IterNext(ref iter));
}
}
}
catch(Exception exp)
{
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - EXCEPTION:" + exp.ToString());
}
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - END");
}
/// <summary>
/// EDIT KEY-VALUE
/// </summary>
@ -296,6 +360,7 @@ public class Firefox : Store
object val;
string KeyName = null,
KeyValue = null;
bool KeyIsPassword;
string[] Keys = null,
Values = null;
@ -309,6 +374,7 @@ public class Firefox : Store
else
val = tsKeyValue.GetValue(iter,2);
KeyValue = val.ToString();
KeyIsPassword = (bool)tsKeyValue.GetValue(iter,5);
tvSecretIDFirefox.Selection.GetSelected (out model, out iter);
@ -316,6 +382,21 @@ public class Firefox : Store
{
if( ("" != args.NewText) && (Common.MAX_LEN >= args.NewText.Length) && (KeyValue != args.NewText) )
{
//check for duplicate secret name
if (KeyIsPassword == false && entrySecretID.Text.EndsWith(")") == true)
{
string sname = entrySecretID.Text;
sname = sname.Remove ((sname.LastIndexOf(" (") + 2),sname.Length - (sname.LastIndexOf(" (") +2));
sname = String.Concat ( sname, args.NewText, ")");
if (sname != entrySecretID.Text && checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
}
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_MODIFY_KEY, KeyName, args.NewText, ref model, ref iter) )
{
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - StoreDataInterface.UpdateStore() succeeded");
@ -362,6 +443,67 @@ public class Firefox : Store
/// </summary>
public void on_buttonNewAdd_clicked(object obj, EventArgs args)
{
Logger.DbgLog("GUI:Firefox.on_buttonNewAdd_clicked() - BEGIN");
if( ("" != entryKey.Text) && ("" != entryValue.Text) )
{
TreeIter iterKey;
ArrayList arrKeys = null,
arrValues = null,
arrIsPassword = null;
object val = null;
arrKeys = new ArrayList();
arrValues = new ArrayList();
arrIsPassword = new ArrayList();
bool ispass = false;
if (tvKeyValue.Model.IterNChildren() == 2)
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
if(tsKeyValue.GetIterFirst(out iterKey))
{
do
{
val = tsKeyValue.GetValue(iterKey,0);
arrKeys.Add(val.ToString());
val = tsKeyValue.GetValue(iterKey,1);
arrValues.Add(val.ToString());
ispass = (bool)tsKeyValue.GetValue(iterKey,5);
if (ispass)
{
ispass = false;
arrIsPassword.Add(true);
}
else
{
ispass = true;
arrIsPassword.Add(false);
}
}
while( tsKeyValue.IterNext(ref iterKey) );
}
if( -1 == arrKeys.IndexOf(entryKey.Text) )
if( true == Common.ValidateString(entryKey.Text) )
{
iterKey = tsKeyValue.AppendValues(entryKey.Text, entryValue.Text, "********", true, "No",ispass);
entryKey.Text = entryValue.Text = "";
}
else
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogSpecialCharacter", null);
gxmlTemp.Autoconnect (this);
//dialogSpecialCharacter.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("dialogNewSecret");
}
//tvKeyValue.Selection.SelectIter(iterKey);
entryKey.HasFocus = true;
}
Logger.DbgLog("GUI:Firefox.on_buttonNewAdd_clicked() - END");
}
public void on_buttonSCClose_clicked(object obj, EventArgs args)
@ -369,11 +511,93 @@ public class Firefox : Store
dialogSpecialCharacter.Destroy();
}
public void on_buttonISClose_clicked(object obj, EventArgs args)
{
dialogInvalidSecret.Destroy();
}
/// <summary>
/// REMOVE BUTTON CLICKED
/// </summary>
public void on_buttonNewRemove_clicked(object obj, EventArgs args)
{
Logger.DbgLog("GUI:Firefox.on_buttonNewRemove_clicked() - BEGIN");
TreeModel modelKey;
TreeIter iterKey;
if(tvKeyValue.Selection.GetSelected (out modelKey, out iterKey)){
if( false == (bool)tsKeyValue.GetValue(iterKey,3) )
arrDeletedKeys.Add(tsKeyValue.GetValue(iterKey,0));
}
if( 0 != tvKeyValue.Selection.CountSelectedRows() )
{
TreeModel model;
TreeIter iter;
tvKeyValue.Selection.GetSelected (out model, out iter);
tsKeyValue.Remove(ref iter);
tvKeyValue.ColumnsAutosize();
}
Logger.DbgLog("GUI:Firefox.on_buttonNewRemove_clicked() - END");
}
public bool checkDuplicateSecretName(String secretID, String uname, ref TreeStore model, int method)
{
TreeIter iter;
switch(method)
{
case 1:
if(model.GetIterFirst(out iter))
{
do
{
if(String.Compare((string)model.GetValue(iter,0),secretID,true) == 0)
return true;
}while(model.IterNext(ref iter));
}
return false;
case 2:
if(model.GetIterFirst(out iter))
{
secretID = String.Concat(secretID, " (");
do
{
if(((string)model.GetValue(iter,0)).StartsWith(secretID))
return true;
}while(model.IterNext(ref iter));
}
return false;
case 3:
bool[] ispassarr;
string[] valarr;
if(model.GetIterFirst(out iter))
{
do
{
if(String.Compare((string)model.GetValue(iter,0),secretID,true) == 0)
{
ispassarr = (bool[])model.GetValue(iter, 6);
valarr = (string[])model.GetValue(iter, 2);
for(int i=0;i<ispassarr.Length;i++)
{
if(!ispassarr[i])
{
if(String.Compare(valarr[i],uname,true) == 0)
return true;
else
return false;
}
}
}
}while(model.IterNext(ref iter));
}
return false;
default:
return false;
}
}
/// <summary>
@ -381,6 +605,120 @@ public class Firefox : Store
/// </summary>
public void on_buttonManageOk_clicked(object obj, EventArgs args)
{
TreeModel modelSecret;
TreeIter iterSecret,
iterKey;
string NewKey = null,
NewValue = null;
bool NewIsPassword;
string[] strDeletedKeys = null;
bool dirtyBit = false;
bool doCheck = false;
//ArrayList arrKeys = null,
// arrValues = null;
String sname = null;
try
{
if (tvKeyValue.Model.IterNChildren() == 1)
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
if( (0 == tvKeyValue.Model.IterNChildren()) && tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret) )
{
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_DELETE_SECRET, "", "", ref modelSecret, ref iterSecret) )
{
tsSecretIDFirefox.Remove(ref iterSecret);
tvSecretIDFirefox.ColumnsAutosize();
tsNativeInfoFirefox.Clear();
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_SECRET_SUCCEEDED");
}
else
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_SECRET_FAILED");
AggregateStore();
}
else
{
//check for duplicate secret names before updating the store
tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret);
sname = (string)modelSecret.GetValue(iterSecret, 0);
doCheck = sname.EndsWith(")");
if( tsKeyValue.GetIterFirst(out iterKey) && doCheck == true)
{
do
{
NewValue = (string) tsKeyValue.GetValue(iterKey,1);
NewIsPassword = (bool) tsKeyValue.GetValue(iterKey,5);
dirtyBit = (bool) tsKeyValue.GetValue(iterKey,3);
if((true == dirtyBit && false == NewIsPassword) || ( false == NewIsPassword && true == isPasswordToggled))
{
sname = sname.Remove ((sname.LastIndexOf(" (") + 2),sname.Length - (sname.LastIndexOf(" (") +2));
sname = String.Concat ( sname, NewValue, ")");
if (sname != entrySecretID.Text && checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
break;
}
}while(tsKeyValue.IterNext(ref iterKey));
}
if( (null != arrDeletedKeys) && (arrDeletedKeys.Count > 0) )
{
tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret);
strDeletedKeys = (string[])arrDeletedKeys.ToArray(typeof(string));
for( int i=0; i < strDeletedKeys.Length; i++)
{
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_DELETE_KEY, strDeletedKeys[i], null, ref modelSecret, ref iterSecret) )
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_KEY_SUCCEEDED.");
else
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_KEY_FAILED.");
}
arrDeletedKeys.Clear();
}
if( tsKeyValue.GetIterFirst(out iterKey) && tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret) )
{
do
{
NewKey = (string) tsKeyValue.GetValue(iterKey,0);
NewValue = (string) tsKeyValue.GetValue(iterKey,1);
NewIsPassword = (bool) tsKeyValue.GetValue(iterKey,5);
dirtyBit = (bool) tsKeyValue.GetValue(iterKey,3);
if( true == dirtyBit )
{
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_ADD_KEY, NewKey, NewValue, NewIsPassword, ref modelSecret, ref iterSecret) )
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - ADD_KEY_VALUE_SUCCEEDED.");
else
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - ADD_KEY_VALUE_FAILED.");
}
else if(true == isPasswordToggled)
{
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_MODIFY_KEY, NewKey, NewValue, NewIsPassword, ref modelSecret, ref iterSecret))
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - SET_PASSWORD_STATE_SUCCEEDED.");
else
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - SET_PASSWORD_STATE_FAILED.");
}
}
while( tsKeyValue.IterNext(ref iterKey) );
}
AggregateStore();
}
}
catch(Exception exp)
{
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - EXCEPTION:" + exp.ToString());
}
tsKeyValue.Dispose();
dialogManageSecret.Destroy();
}
@ -584,11 +922,155 @@ public class Firefox : Store
ViewKeyValues();
}
public void on_buttonNewOk_clicked(object obj, EventArgs args)
{
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - BEGIN");
TreeModel modelSecret;
TreeIter iterSecret,
iterKey;
string NewKey = null,
NewValue = null;
bool NewIsPassword;
string[] Keys = null,
Values = null,
NativeKeys = null,
NativeValues = null;
bool[] IsPassword =null;
object val = null;
string sname = null;
ArrayList arrKeys = null,
arrValues = null,
arrIsPassword = null;
if (tvKeyValue.Model.IterNChildren() == 1)
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
if ( true == entrySecretID.Editable && false == ValidateString(entrySecretID.Text) )
{
/*// prompt user
MessageDialog md=new MessageDialog(this.windowMain,Gtk.DialogFlags.Modal,
Gtk.MessageType.Warning,
Gtk.ButtonsType.Ok,
"Secret ID may not contain \"*\"");
md.Response += new ResponseHandler(md_Response);
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
md.Modal = true;
md.Show();*/
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogSpecialCharacter", null);
gxmlTemp.Autoconnect (this);
entrySecretID.HasFocus = true;
return;
}
if( (true == entrySecretID.Editable) && ("" != entrySecretID.Text) && (tvKeyValue.Model.IterNChildren() > 0) )
{
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - Adding New Secrets and KeyValues.");
arrKeys = new ArrayList();
arrValues = new ArrayList();
arrIsPassword = new ArrayList();
try
{
if(tsKeyValue.GetIterFirst(out iterKey))
{
do
{
val = tsKeyValue.GetValue(iterKey,0);
NewKey = val.ToString();
val = tsKeyValue.GetValue(iterKey,1);
NewValue = val.ToString();
NewIsPassword = (bool)tsKeyValue.GetValue(iterKey,5);
if( -1 == (arrKeys.IndexOf(NewKey)) )
{
arrKeys.Add(NewKey);
arrValues.Add(NewValue);
arrIsPassword.Add(NewIsPassword);
}
if(NewIsPassword == false)
{
sname = entrySecretID.Text;
if (checkDuplicateSecretName(entrySecretID.Text, null, ref tsSecretIDFirefox, 1))
{
if (checkDuplicateSecretName(entrySecretID.Text, NewValue, ref tsSecretIDFirefox, 3))
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
}
else if(checkDuplicateSecretName(entrySecretID.Text, null, ref tsSecretIDFirefox, 2))
{
sname = String.Concat ( sname, " (", NewValue, ")");
if (checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogInvalidSecret", null);
gxmlTemp.Autoconnect (this);
dialogInvalidSecret.Show();
return;
}
}
}
}
while( tsKeyValue.IterNext(ref iterKey) );
Keys = (string[])arrKeys.ToArray(typeof(string));
Values = (string[])arrValues.ToArray(typeof(string));
IsPassword = (bool[])arrIsPassword.ToArray(typeof(bool));
NativeKeys = new string[Common.MAX_NATIVE_ELEMENTS];
NativeValues = new string[Common.MAX_NATIVE_ELEMENTS];
NativeKeys[Common.INDEX_NATIVEINFO_FOLDERNAME] = Common.NATIVEINFO_FOLDERNAME;
NativeKeys[Common.INDEX_NATIVEINFO_TYPEID] = Common.NATIVEINFO_TYPEID;
NativeKeys[Common.INDEX_NATIVEINFO_SYNC] = Common.NATIVEINFO_SYNC;
NativeKeys[Common.INDEX_NATIVEINFO_SYNCTYPE] = Common.NATIVEINFO_SYNCTYPE;
NativeKeys[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = Common.NATIVEINFO_MODIFIEDTIME;
NativeValues[Common.INDEX_NATIVEINFO_FOLDERNAME] = null;
NativeValues[Common.INDEX_NATIVEINFO_TYPEID] = "Signon";
NativeValues[Common.INDEX_NATIVEINFO_SYNC] = null;
NativeValues[Common.INDEX_NATIVEINFO_SYNCTYPE] = null;
NativeValues[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = null;
iterSecret = tsSecretIDFirefox.AppendValues(sname, Keys, Values, DataEngines.AD.GetDefaultProfileName(Common.STORE_FIREFOX), NativeKeys, NativeValues, IsPassword);
modelSecret = tvSecretIDFirefox.Model;
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_ADD_SECRET, "", "", ref modelSecret, ref iterSecret) )
{
AggregateStore();
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - ADD_NEW_SECRET_SUCCEEDED.");
}
else
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - ERROR: ADD_NEW_SECRET_FAILED");
}
}
catch(Exception exp)
{
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - EXCEPTION:" + exp.ToString());
}
tsKeyValue.Dispose();
dialogNewSecret.Destroy();
}
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - END");
}
public void on_buttonNewCancel_clicked(object obj, EventArgs args)
{
dialogNewSecret.Destroy();
}
public void on_helpbuttonNewSecret_clicked(object obj, EventArgs args)
{
Common.ShowHelpUrl("AddNewSecrets.htm");
}
///#######################################################################
/// ADD NEW SECRET
/// <summary>
@ -596,6 +1078,33 @@ public class Firefox : Store
/// </summary>
public void OnNewSecretActivated(object obj, EventArgs args)
{
Logger.DbgLog("GUI:Firefox.OnNewSecretActivated() - BEGIN");
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogNewSecret", null);
gxmlTemp.Autoconnect (this);
dialogNewSecret.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");
dialogNewSecret.Title = "Firefox - New Secret";
cellEditable = new CellRendererText();
cellEditable.Editable = true;
cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
cellToggle = new CellRendererToggle();
cellToggle.Activatable = true;
cellToggle.Toggled += OnIsPasswordToggled;
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 ISPASSWORD:5
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string),typeof(bool));
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Password", cellToggle,"active",5);
tvKeyValue.AppendColumn("Linked",new CellRendererText(),"text",4);
tvKeyValue.Model = tsKeyValue;
tsKeyValue.Clear();
entrySecretID.HasFocus = true;
entrySecretID.Text = "";
Logger.DbgLog("GUI:Firefox.OnNewSecretActivated() - END");
}
///#######################################################################
@ -605,6 +1114,11 @@ public class Firefox : Store
/// </summary>
public void OnNewKeyActivated(object obj, EventArgs args)
{
Logger.DbgLog("GUI:Firefox.OnNewKeyActivated() - BEGIN");
ViewKeyValues();
Logger.DbgLog("GUI:Firefox.OnNewKeyActivated() - END");
}
///#######################################################################
@ -652,6 +1166,7 @@ public class Firefox : Store
tvSecretIDFirefox.ColumnsAutosize();
tsNativeInfoFirefox.Clear();
dialogConfirmDelete.Destroy();
AggregateStore();
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - DELETE_SECRET_SUCCEEDED");
}
@ -691,6 +1206,19 @@ public class Firefox : Store
{
}
///#######################################################################
/// VALIDATE STRINGS FOR SPECIAL CHARACTERS
/// <summary>
/// Validate strings for special characters
/// </summary>
public static bool ValidateString(string sString)
{
if( -1 == sString.IndexOfAny(SpecialCharacters) )
return true;
else
return false;
}
}
}

View File

@ -53,6 +53,8 @@ namespace Novell.CASA.GUI {
CCFXML_ELEMENT_TIME_ZONE = "Zone",
CCFXML_ELEMENT_TIME_CREATION = "Creation",
CCFXML_ELEMENT_TIME_MODIFIED = "Modified",
CCFXML_ATTRIBUTE_PASSWDSTATUS = "PasswordStatus",
CCFXML_ATTRIBUTE_FFOX_TYPE = "Signon",
CCFXML_ELEMENT_TIME_ACCESSED = "Accessed",
CCFXML_ATTRIBUTE_ID = "ID",
CCFXML_ATTRIBUTE_MICASA_SYNCH = "Synch",
@ -171,6 +173,7 @@ namespace Novell.CASA.GUI {
string secretID = null;
string[] strKeyArray = null;
string[] strValueArray = null;
bool[] boolIsPassArray = null;
string storeID = null;
string[] strNativeKeyArray = new string[Common.MAX_NATIVE_ELEMENTS];
string[] strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
@ -303,6 +306,7 @@ namespace Novell.CASA.GUI {
//Reinit arrays to the no of keys for this secret
strKeyArray = new string[noOfKeys];
strValueArray = new string[noOfKeys];
boolIsPassArray = new bool[noOfKeys];
//Get Last Modified Time for the secret
ccfExtPath = CCFXML_ELEMENT_TIME + "/" + CCFXML_ELEMENT_TIME_MODIFIED;
@ -334,6 +338,14 @@ namespace Novell.CASA.GUI {
bKey = true;
strKeyArray[noOfKeysFound] = iterSecret.Current.Value; //KeyName
}
if( (iterSecret.Current.LocalName.Equals(CCFXML_ATTRIBUTE_PASSWDSTATUS )) && (noOfKeysFound<=noOfKeys) )
{
if(iterSecret.Current.Value.Equals("1"))
boolIsPassArray[noOfKeysFound] = true; //KeyName
else
boolIsPassArray[noOfKeysFound] = false; //KeyName
}
}while( iterSecret.Current.MoveToNextAttribute() );
iterSecret.Current.MoveToParent();
@ -391,7 +403,9 @@ namespace Novell.CASA.GUI {
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);
if ( storeIDentifier == Common.STORE_FIREFOX)
ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray,boolIsPassArray);
else
ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray);
//Re-Initialize for next iteration
@ -415,7 +429,106 @@ namespace Novell.CASA.GUI {
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,bool isPassword,ref TreeModel model,ref TreeIter iter)
{
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore()");
//TreeStore row elements
string SecretID = null;
string keyChainID = null;
//XPATH query strings
string ccfKeyChainPath = null;
string ccfSecretPath = null;
string ccfKeyPath = null;
//Reading and Initialzing from the passed iter object
SecretID = (string) model.GetValue (iter, 0);
keyChainID = (string) model.GetValue (iter, 3);
if (storeIDentifier != Common.STORE_FIREFOX && (operation != Common.OPERATION_ADD_KEY || operation!=Common.OPERATION_MODIFY_KEY || operation!=Common.OPERATION_MODIFY_SECRET))
return Common.STATUS_FAILURE;
try
{
if( Common.OPERATION_ADD_KEY == operation )
{
ccfKeyChainPath = "//CCF/FireFox/Profile[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
ccfSecretPath = "";
//Create the Key element
XmlElement newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
if(isPassword)
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"1");
else
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"0");
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
newValue.InnerText = valueToBeModfied;
newKeyElement.AppendChild(newValue);
XmlNode root = ccfDoc.DocumentElement;
XmlNodeList keyNodeList = root.SelectNodes(ccfKeyChainPath);
XmlNode keyNode=keyNodeList.Item(0);
XmlNode lastChild = keyNode.LastChild;
if(isPassword)
keyNode.InsertAfter(newKeyElement,lastChild);
else
keyNode.InsertBefore(newKeyElement,lastChild);
ad.SetSecret(keyNode,Common.OPERATION_MODIFY_KEY,storeIDentifier);
}
else if(Common.OPERATION_MODIFY_KEY == operation)
{
ccfKeyPath = "//CCF/FireFox/Profile[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
ccfSecretPath = "//CCF/FireFox/Profile[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
XmlElement newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
if(isPassword)
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"1");
else
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"0");
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
newValue.InnerText = valueToBeModfied;
newKeyElement.AppendChild(newValue);
XmlNode root = ccfDoc.DocumentElement;
XmlNode secretNode = root.SelectSingleNode(ccfSecretPath);
XmlNode keyNode = root.SelectSingleNode(ccfKeyPath);
if(keyNode!=null)
secretNode.RemoveChild(keyNode);
if (isPassword)
secretNode.InsertAfter(newKeyElement,secretNode.LastChild);
else
secretNode.InsertBefore(newKeyElement,secretNode.LastChild);
ad.SetSecret(secretNode,Common.OPERATION_MODIFY_KEY,storeIDentifier);
}
}
catch(Exception exp)
{
//Console.WriteLine("Exception"+exp.ToString());//FIXME:Remove this line
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore() - EXCEPTION" + exp.ToString());
return( Common.STATUS_STORE_UPDATEFAILED );
}
return( Common.STATUS_SUCCESS );
}
///#######################################################################
/// UPDATE STORE: ADD NEW secret/keyvalue, MODIFY keyvalue, DELETE secret
@ -433,6 +546,7 @@ namespace Novell.CASA.GUI {
string keyChainID = null;
string[] strKeyArray = new string[Common.MAX_ARRAY_ELEMENTS];
string[] strValueArray = new string[Common.MAX_ARRAY_ELEMENTS];
bool[] boolIsPassArray = new bool[Common.MAX_ARRAY_ELEMENTS];
string[] strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
//XPATH query strings
@ -452,6 +566,8 @@ namespace Novell.CASA.GUI {
strValueArray = (string[]) model.GetValue (iter, 2);
keyChainID = (string) model.GetValue (iter, 3);
strNativeValueArray = (string[]) model.GetValue (iter, 5);
if (storeIDentifier == Common.STORE_FIREFOX)
boolIsPassArray = (bool[]) model.GetValue (iter, 6);
try
@ -656,6 +772,43 @@ namespace Novell.CASA.GUI {
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
}
else if( Common.OPERATION_ADD_SECRET == operation )
{
XmlElement newUser, newPass;
//keyChainID = ad.GetDefaultProfileName(Common.STORE_FIREFOX);
ccfKeyChainPath = "//CCF/FireFox/Profile[@ID='" + keyChainID + "']";
ccfSecretPath = "//CCF/FireFox/Profile[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_ID,SecretID);
newSecretElement.SetAttribute(CCFXML_ELEMENT_TYPE,CCFXML_ATTRIBUTE_FFOX_TYPE);
newUser = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
newPass = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
for( int i=0; i< strKeyArray.Length; i++)
{
if(boolIsPassArray[i])
{
newPass.SetAttribute(CCFXML_ATTRIBUTE_ID,strKeyArray[i]);
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
newValue.InnerText = strValueArray[i];
newPass.AppendChild(newValue);
newPass.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"1");
}
else
{
newUser.SetAttribute(CCFXML_ATTRIBUTE_ID,strKeyArray[i]);
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
newValue.InnerText = strValueArray[i];
newUser.AppendChild(newValue);
newUser.SetAttribute(CCFXML_ATTRIBUTE_PASSWDSTATUS,"0");
}
}
newSecretElement.AppendChild(newUser);
newSecretElement.AppendChild(newPass);
newKeychainElement = ccfDoc.CreateElement(storeChainKey);
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
newKeychainElement.AppendChild(newSecretElement);
}
}
else
return( Common.STATUS_STORE_UNSUPPORTEDOPERATION );
@ -710,7 +863,7 @@ namespace Novell.CASA.GUI {
{
//ShowDocOnConsole("BEFORE CALL TO SETSECRET");//FIXME:Remove this
if(( Common.STORE_MICASA == storeIDentifier )||( Common.STORE_GNOMEKEYRING == storeIDentifier ))
if(( Common.STORE_MICASA == storeIDentifier )||( Common.STORE_GNOMEKEYRING == storeIDentifier ) || (Common.STORE_FIREFOX == storeIDentifier ))
{
//Add a new secret to the keychain
XmlNode root = ccfDoc.DocumentElement;

View File

@ -823,6 +823,7 @@
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">True</property>
<property name="enable_popup">False</property>
<signal name="switch_page" handler="on_notebookStores_switch_page" last_modification_time="Fri, 29 Sep 2006 10:45:55 GMT"/>
<child>
<widget class="GtkVBox" id="vboxMiCasa">
@ -14168,4 +14169,165 @@ to encrypt this file</property>
</child>
</widget>
<widget class="GtkDialog" id="dialogInvalidSecret">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Warning</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="icon">CASAicons.ico</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox167">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="hbuttonbox26">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button69">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
<signal name="clicked" handler="on_buttonISClose_clicked" last_modification_time="Fri, 29 Sep 2006 10:49:22 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox98">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox168">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image4265">
<property name="visible">True</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">4</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox169">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="labelWarning1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;A Firefox Password Manager secret should have two key-value pairs.&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label283">
<property name="visible">True</property>
<property name="label" translatable="yes">Add two key-value pairs with one of them flagged as password by enabling the corresponding checkbox.</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">4</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>