- 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 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. Remove will delete a Secret.

View File

@ -74,6 +74,11 @@ namespace Novell.CASA.DataEngines
FireFox.UninitProfile(defaultProfileName); FireFox.UninitProfile(defaultProfileName);
} }
public static String GetDefaultProfileName()
{
return FireFox.GetDefaultProfileName();
}
public XmlNode Aggregate() public XmlNode Aggregate()
{ {
@ -145,7 +150,7 @@ namespace Novell.CASA.DataEngines
}catch(Exception e) }catch(Exception e)
{ {
Console.WriteLine("Unable to Marshal the SecretName" + e.ToString()); Console.WriteLine("Unable to Marshal the SecretName" + e.ToString());
} }
XmlNodeList keylist = secret.SelectNodes("descendant::Key"); XmlNodeList keylist = secret.SelectNodes("descendant::Key");
try try
{ {
@ -165,11 +170,14 @@ namespace Novell.CASA.DataEngines
nh.isPassword = Convert.ToInt32(passwordstatus); nh.isPassword = Convert.ToInt32(passwordstatus);
nh.next = next; nh.next = next;
next = Marshal.AllocHGlobal(Marshal.SizeOf(nh)); next = Marshal.AllocHGlobal(Marshal.SizeOf(nh));
Marshal.StructureToPtr(nh,next,false); Marshal.StructureToPtr(nh,next,false);
} }
newHost.hostElement = next; newHost.hostElement = next;
retVal = FireFox.Modify_Host(ProfileName,newHost,1); if (opnType == ConstStrings.OPERATION_ADD_SECRET)
retVal = FireFox.Add_Host(ProfileName,newHost,1);
else
retVal = FireFox.Modify_Host(ProfileName,newHost,1);
} }
catch(Exception e) catch(Exception e)
{ {
@ -265,10 +273,10 @@ namespace Novell.CASA.DataEngines
XmlElement xmlProfileElement; XmlElement xmlProfileElement;
String hostName; String hostName;
String name; String name;
String value; String value;
int isPassword; int isPassword;
methodStatusCode=1; methodStatusCode=1;
xmlProfileElement = doc.CreateElement(ConstStrings.CCF_FFPROFILE); //<Profile> xmlProfileElement = doc.CreateElement(ConstStrings.CCF_FFPROFILE); //<Profile>
XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID); //<Profile>-ID XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID); //<Profile>-ID
@ -357,7 +365,7 @@ namespace Novell.CASA.DataEngines
}//~Aggregate profileName }//~Aggregate profileName
return methodStatusCode; return methodStatusCode;
} }

View File

@ -30,10 +30,10 @@ namespace Novell.CASA.DataEngines.FF
{ {
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class Host public class Host
{ {
public IntPtr hostName; public IntPtr hostName;
public IntPtr hostElement; public IntPtr hostElement;
public IntPtr next; public IntPtr next;
/*public Host() /*public Host()
//NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN //NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
@ -52,15 +52,15 @@ namespace Novell.CASA.DataEngines.FF
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for Host:"); Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for Host:");
} }
}*/ }*/
}; };
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class HostElement public class HostElement
{ {
public IntPtr name; public IntPtr name;
public IntPtr value; public IntPtr value;
public int isPassword; public int isPassword;
public IntPtr next; public IntPtr next;
/*public HostElement() /*public HostElement()
{ {
@ -174,6 +174,8 @@ namespace Novell.CASA.DataEngines.FF
//Signon functions //Signon functions
[DllImport(FF_LIB)] [DllImport(FF_LIB)]
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh); 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)] [DllImport(FF_LIB)]
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate); public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
@ -183,7 +185,6 @@ namespace Novell.CASA.DataEngines.FF
//TBD //TBD
//int FPM_WriteSignonData(char *profileName) //int FPM_WriteSignonData(char *profileName)
//int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
public static int IsStoreAvailable() public static int IsStoreAvailable()
{ {
@ -195,6 +196,11 @@ namespace Novell.CASA.DataEngines.FF
return (FPM_RemoveHost(ProfileName, hostName, 1)); 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) public static int Modify_Host(string profileName, Host mhost, int doUpdate)
{ {
//Console.WriteLine("FireFox.cs : ProfileName : " + profileName); //Console.WriteLine("FireFox.cs : ProfileName : " + profileName);
@ -218,20 +224,20 @@ namespace Novell.CASA.DataEngines.FF
int[] profileFlags=null; int[] profileFlags=null;
String profileName=null; String profileName=null;
int profileFlag=0; int profileFlag=0;
int profCount=0; int profCount=0;
String defaultProfileName=null; String defaultProfileName=null;
//Console.WriteLine("FireFox:Invoking FPM_GetProfileList:"); //Console.WriteLine("FireFox:Invoking FPM_GetProfileList:");
profCount=FPM_GetProfileList(out profileListIntPtr,out profileFlagsIntPtr); profCount=FPM_GetProfileList(out profileListIntPtr,out profileFlagsIntPtr);
//Console.WriteLine("FireFox:No of Profiles found= "+profCount); //Console.WriteLine("FireFox:No of Profiles found= "+profCount);
//try //try
///{ ///{
for(int i=0; i< profCount; i++) for(int i=0; i< profCount; i++)
{ {
//Console.WriteLine("Firefox.cs : Inside The for Loop"); //Console.WriteLine("Firefox.cs : Inside The for Loop");
profileName=Marshal.PtrToStringAnsi(profileListIntPtr[i]); profileName=Marshal.PtrToStringAnsi(profileListIntPtr[i]);
profileFlag=(int)profileFlagsIntPtr[i]; profileFlag=(int)profileFlagsIntPtr[i];
//Console.WriteLine("FireFox:Iter="+i+"profileName="+profileName); //Console.WriteLine("FireFox:Iter="+i+"profileName="+profileName);
//Console.WriteLine("FireFox:Iter="+i+"profileFlag="+profileFlag); //Console.WriteLine("FireFox:Iter="+i+"profileFlag="+profileFlag);
if(profileFlag==1) if(profileFlag==1)

View File

@ -20,96 +20,122 @@
* *
***********************************************************************/ ***********************************************************************/
#include "FirefoxPasswordManager.h" #include "FirefoxPasswordManager.h"
#include "Common.h" #include "Common.h"
char lastErrorMesg[10000]; char lastErrorMesg[10000];
void PrintMessage( int level, char *mesg , ...) void PrintMessage( int level, char *mesg , ...)
{ {
va_list vl; va_list vl;
va_start( vl , mesg ); va_start( vl , mesg );
vsprintf( lastErrorMesg , mesg , vl ); vsprintf( lastErrorMesg , mesg , vl );
va_end( vl ); va_end( vl );
// if we are not debugging then print DEBUG level messages // if we are not debugging then print DEBUG level messages
#ifdef DEBUG #ifdef DEBUG
printf("%s", lastErrorMesg ); printf("%s", lastErrorMesg );
#else #else
if( level != MESG_DEBUG ) if( level != MESG_DEBUG )
{ {
//printf("%s", lastErrorMesg ); //printf("%s", lastErrorMesg );
} }
#endif #endif
} }
/** /**
* Converts given string to lower case.... * Converts given string to lower case....
* *
*/ */
void StrLwr(char *str) void StrLwr(char *str)
{ {
int n=strlen(str); int n=strlen(str);
for(int i=0; i<n; i++) for(int i=0; i<n; i++)
{ {
if( str[i] >=65 && str[i]<=90 ) if( str[i] >=65 && str[i]<=90 )
str[i]+=32; str[i]+=32;
} }
} }
/** /**
* Checks if specified directory exists * Checks if specified directory exists
* *
* return MC_TRUE if directory exists else MC_FALSE * return MC_TRUE if directory exists else MC_FALSE
* *
*/ */
int IsDirectoryExists( char *path ) int IsDirectoryExists( char *path )
{ {
if( path == NULL ) if( path == NULL )
return 0; return 0;
#ifdef WIN32 #ifdef WIN32
DWORD attr = GetFileAttributes(path); DWORD attr = GetFileAttributes(path);
if( (attr == -1) || !(attr & FILE_ATTRIBUTE_DIRECTORY ) ) if( (attr == -1) || !(attr & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path); PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path);
return 0; return 0;
} }
return 1; return 1;
#else #else
char *program = (char*) malloc(strlen(path)+20); char *program = (char*) malloc(strlen(path)+20);
if( program == NULL ) if( program == NULL )
return 0; return 0;
strcpy(program, "test -d "); strcpy(program, "test -d ");
strcat(program, path); strcat(program, path);
int result= system(program); int result= system(program);
free(program); free(program);
if( result != 0 ) if( result != 0 )
{ {
PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path); PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path);
return 0; return 0;
} }
return 1; return 1;
#endif #endif
} }
/**
* 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

@ -1,458 +1,460 @@
/*********************************************************************** /***********************************************************************
* *
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1 * License as published by the Free Software Foundation; version 2.1
* of the License. * of the License.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details. * Library Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc. * License along with this library; if not, Novell, Inc.
* *
* To contact Novell about this file by physical or electronic mail, * To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com. * you may find current contact information at www.novell.com.
* *
***********************************************************************/ ***********************************************************************/
#include "CryptManager.h" #include "CryptManager.h"
void CryptManager::SetupFunctions(void *funList[]) void CryptManager::SetupFunctions(void *funList[])
{ {
//PK11SetPasswordFunc = (PK11_SetPasswordFunc) funList[0]; //PK11SetPasswordFunc = (PK11_SetPasswordFunc) funList[0];
PK11GetInternalKeySlot = (PK11_GetInternalKeySlot) funList[1]; PK11GetInternalKeySlot = (PK11_GetInternalKeySlot) funList[1];
PK11FreeSlot = (PK11_FreeSlot) funList[2]; PK11FreeSlot = (PK11_FreeSlot) funList[2];
PK11Authenticate = (PK11_Authenticate) funList[3]; PK11Authenticate = (PK11_Authenticate) funList[3];
PK11CheckUserPassword =(PK11_CheckUserPassword) funList[4]; PK11CheckUserPassword =(PK11_CheckUserPassword) funList[4];
PK11SDRDecrypt = (PK11SDR_Decrypt) funList[5]; PK11SDRDecrypt = (PK11SDR_Decrypt) funList[5];
PK11SDREncrypt = (PK11SDR_Encrypt) funList[6]; PK11SDREncrypt = (PK11SDR_Encrypt) funList[6];
PLBase64Encode = (PL_Base64Encode) funList[7]; PLBase64Encode = (PL_Base64Encode) funList[7];
PLBase64Decode = (PL_Base64Decode) funList[8]; PLBase64Decode = (PL_Base64Decode) funList[8];
PK11NeedUserInit = (PK11_NeedUserInit) funList[9];
} PK11InitPin = (PK11_InitPin) funList[10];
int CryptManager::GetEncryptionPref() }
{
int CryptManager::GetEncryptionPref()
return FPM_TRUE; {
}
return FPM_TRUE;
}
/**
* This function encrypts the clear text data. First it performs TRIPLE DES encryption
* and then performs base64 encoding on the encrypted data. /**
* * This function encrypts the clear text data. First it performs TRIPLE DES encryption
* @param(in) clearData clear text data to be encrypted * and then performs base64 encoding on the encrypted data.
* @param(out) finalData encrypted data ( null terminated) *
* * @param(in) clearData clear text data to be encrypted
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) finalData encrypted data ( null terminated)
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
int CryptManager::EncryptString (char *clearData, char **finalData) *
{ */
int encryptDataLen = 0; int CryptManager::EncryptString (char *clearData, char **finalData)
char *encryptData = NULL; {
char *encodeData = NULL; int encryptDataLen = 0;
int retValue; char *encryptData = NULL;
char *encodeData = NULL;
int retValue;
if( clearData == NULL )
{
PrintMessage(MESG_ERROR, "\n EncryptString : Text Data is NULL"); if( clearData == NULL )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n EncryptString : Text Data is NULL");
return FPM_FALSE;
// Do the encryption if encryption pref is set otherwise just do base64 encoding... }
if ( GetEncryptionPref() )
{ // Do the encryption if encryption pref is set otherwise just do base64 encoding...
PrintMessage(MESG_DEBUG, "\n EncryptString : Performing PK11 Encryption..."); if ( GetEncryptionPref() )
{
retValue = FPM_FALSE; PrintMessage(MESG_DEBUG, "\n EncryptString : Performing PK11 Encryption...");
if( ((retValue = CryptPK11EncryptString(clearData, strlen(clearData), &encryptData, &encryptDataLen)) != FPM_TRUE) || ( encryptData == NULL) )
{ retValue = FPM_FALSE;
PrintMessage(MESG_ERROR, "\n EncryptString : Failed to encrypt the string : %s ", clearData); if( ((retValue = CryptPK11EncryptString(clearData, strlen(clearData), &encryptData, &encryptDataLen)) != FPM_TRUE) || ( encryptData == NULL) )
return retValue; {
} PrintMessage(MESG_ERROR, "\n EncryptString : Failed to encrypt the string : %s ", clearData);
return retValue;
if( (CryptBase64Encode(encryptData, encryptDataLen, finalData) != FPM_TRUE) || (*finalData == NULL) ) }
{
PrintMessage(MESG_ERROR, "\n EncryptString : BASE64 encoding failed"); if( (CryptBase64Encode(encryptData, encryptDataLen, finalData) != FPM_TRUE) || (*finalData == NULL) )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n EncryptString : BASE64 encoding failed");
return FPM_FALSE;
PrintMessage(MESG_DEBUG, "\n EncryptString : Success "); }
// WARNING : If you uncomment , then be ready for side effects , crashes..etc PrintMessage(MESG_DEBUG, "\n EncryptString : Success ");
// Need full analysis of malloc for this data..
// Free the allocated blocks... // WARNING : If you uncomment , then be ready for side effects , crashes..etc
// Need full analysis of malloc for this data..
//if( encryptData ) // Free the allocated blocks...
// free( encryptData);
//if( encryptData )
return FPM_TRUE; // free( encryptData);
}
return FPM_TRUE;
// otherwise do our own obscuring using Base64 encoding }
PrintMessage(MESG_DEBUG, "\n EncryptString : Performing JUST base64 encoding...");
// otherwise do our own obscuring using Base64 encoding
if( (CryptBase64Encode(clearData, strlen(clearData), &encodeData) == FPM_FALSE) || (encodeData == NULL) ) PrintMessage(MESG_DEBUG, "\n EncryptString : Performing JUST base64 encoding...");
{
PrintMessage(MESG_ERROR, "\n EncryptString : BASE64 encoding failed"); if( (CryptBase64Encode(clearData, strlen(clearData), &encodeData) == FPM_FALSE) || (encodeData == NULL) )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n EncryptString : BASE64 encoding failed");
return FPM_FALSE;
// We need to add the CRYPT_PREFIX at the begining of encoded data... }
// This will help during decrption process to identify type of encryption
// We need to add the CRYPT_PREFIX at the begining of encoded data...
int prefixLen = strlen( CRYPT_PREFIX ); // This will help during decrption process to identify type of encryption
int encodeLen = strlen( encodeData );
*finalData = (char *)malloc( prefixLen + encodeLen + 1); int prefixLen = strlen( CRYPT_PREFIX );
int encodeLen = strlen( encodeData );
if( *finalData == NULL ) *finalData = (char *)malloc( prefixLen + encodeLen + 1);
{
PrintMessage(MESG_ERROR, "\n EncryptString : Insufficient memory"); if( *finalData == NULL )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n EncryptString : Insufficient memory");
return FPM_FALSE;
// FinalData = CRYPT_PREFIX + Encoded Data + '\0' }
strcpy(*finalData, CRYPT_PREFIX);
strcat(*finalData, encodeData); // FinalData = CRYPT_PREFIX + Encoded Data + '\0'
*(*finalData + prefixLen + encodeLen) = 0; strcpy(*finalData, CRYPT_PREFIX);
strcat(*finalData, encodeData);
free(encodeData); *(*finalData + prefixLen + encodeLen) = 0;
return FPM_TRUE; free(encodeData);
}
return FPM_TRUE;
}
/**
* This function decrypts the encrypted data. First it performs base64 decoding and
* then performs TRIPLE DES decryption. /**
* * This function decrypts the encrypted data. First it performs base64 decoding and
* @param(in) cryptData encrypted data * then performs TRIPLE DES decryption.
* @param(out) clearData clear text data ( null terminated) *
* * @param(in) cryptData encrypted data
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) clearData clear text data ( null terminated)
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
*
int CryptManager::DecryptString(char *cryptData, char **clearData) */
{
int decodeLen = 0; int CryptManager::DecryptString(char *cryptData, char **clearData)
int finalLen = 0; {
char *decodeData = NULL; int decodeLen = 0;
char *finalData = NULL; int finalLen = 0;
int retValue; char *decodeData = NULL;
char *finalData = NULL;
if( cryptData == NULL ) int retValue;
{
PrintMessage(MESG_ERROR, "\n DecryptString: CryptData is NULL..."); if( cryptData == NULL )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n DecryptString: CryptData is NULL...");
return FPM_FALSE;
// treat zero-length crypt string as a special case }
if(cryptData[0] == '\0')
{ // treat zero-length crypt string as a special case
*clearData = (char*) malloc(1); if(cryptData[0] == '\0')
**clearData = 0; {
return FPM_TRUE; *clearData = (char*) malloc(1);
} **clearData = 0;
return FPM_TRUE;
// use PK11 encryption stuff if crypt doesn't starts with prefix }
if( cryptData[0] != CRYPT_PREFIX[0] )
{ // use PK11 encryption stuff if crypt doesn't starts with prefix
if( cryptData[0] != CRYPT_PREFIX[0] )
PrintMessage(MESG_DEBUG, "\n Performing PK11 Decryption "); {
// First do base64 decoding..... PrintMessage(MESG_DEBUG, "\n Performing PK11 Decryption ");
if( (CryptBase64Decode(cryptData, &decodeData, &decodeLen) != FPM_TRUE) || (decodeData == NULL) )
{ // First do base64 decoding.....
PrintMessage(MESG_ERROR, "\n DecryptString : Base64 decoding of crypt data failed "); if( (CryptBase64Decode(cryptData, &decodeData, &decodeLen) != FPM_TRUE) || (decodeData == NULL) )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n DecryptString : Base64 decoding of crypt data failed ");
return FPM_FALSE;
PrintMessage(MESG_DEBUG, "\n DecryptString : base64data (%d) = %s ", decodeLen, decodeData); }
// Now do actual PK11 decryption PrintMessage(MESG_DEBUG, "\n DecryptString : base64data (%d) = %s ", decodeLen, decodeData);
retValue = FPM_FALSE;
retValue = CryptPK11DecryptString(decodeData, decodeLen, &finalData, &finalLen); // Now do actual PK11 decryption
retValue = FPM_FALSE;
if( retValue != FPM_TRUE ) retValue = CryptPK11DecryptString(decodeData, decodeLen, &finalData, &finalLen);
{
PrintMessage(MESG_ERROR, "\n DecryptString : Failed to decrypt the string "); if( retValue != FPM_TRUE )
return retValue; {
} PrintMessage(MESG_ERROR, "\n DecryptString : Failed to decrypt the string ");
return retValue;
}
// WARNING : Decrypted string is not NULL terminated
// So we will create new NULL terminated string here...
// WARNING : Decrypted string is not NULL terminated
*clearData = (char*) malloc( finalLen + 1 ); // So we will create new NULL terminated string here...
if( *clearData == NULL ) *clearData = (char*) malloc( finalLen + 1 );
{
PrintMessage(MESG_ERROR, "\n DecryptString :Insufficient memory... "); if( *clearData == NULL )
return FPM_INSUFFICIENT_MEMORY; {
} PrintMessage(MESG_ERROR, "\n DecryptString :Insufficient memory... ");
else return FPM_INSUFFICIENT_MEMORY;
{ }
PrintMessage(MESG_DEBUG, "\n DecryptString : Copying new data ...."); else
memcpy(*clearData, finalData, finalLen); {
*(*clearData + finalLen) = 0; // Null terminate the string.... PrintMessage(MESG_DEBUG, "\n DecryptString : Copying new data ....");
} memcpy(*clearData, finalData, finalLen);
*(*clearData + finalLen) = 0; // Null terminate the string....
/* }
// Free the allocated memory
// This is causing the problems currently...Later point we have to reanalyze the cause for this /*
// Free the allocated memory
if( decodeData ) // This is causing the problems currently...Later point we have to reanalyze the cause for this
free(decodeData);
if( decodeData )
if( finalData ) free(decodeData);
free(finalData);
*/ if( finalData )
free(finalData);
PrintMessage(MESG_DEBUG, "\n decryptString : finalLen = %d ", finalLen); */
return FPM_TRUE; PrintMessage(MESG_DEBUG, "\n decryptString : finalLen = %d ", finalLen);
}
return FPM_TRUE;
}
// otherwise do our own de-obscuring
PrintMessage(MESG_DEBUG, "\n DecryptString : Performing simple Base64 Decoding ");
// otherwise do our own de-obscuring
unsigned int PREFIX_Len = strlen(CRYPT_PREFIX); PrintMessage(MESG_DEBUG, "\n DecryptString : Performing simple Base64 Decoding ");
if( strlen(cryptData) == PREFIX_Len )
{ unsigned int PREFIX_Len = strlen(CRYPT_PREFIX);
*clearData = (char *)malloc(1); if( strlen(cryptData) == PREFIX_Len )
**clearData = '\0'; {
return FPM_TRUE; *clearData = (char *)malloc(1);
} **clearData = '\0';
return FPM_TRUE;
if( CryptBase64Decode(&cryptData[PREFIX_Len], clearData, &decodeLen) == FPM_FALSE ) }
{
PrintMessage(MESG_ERROR, "\n DecryptString : Base64 decoding of crypt data failed "); if( CryptBase64Decode(&cryptData[PREFIX_Len], clearData, &decodeLen) == FPM_FALSE )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n DecryptString : Base64 decoding of crypt data failed ");
return FPM_FALSE;
return FPM_TRUE; }
}
return FPM_TRUE;
}
/**
* Performs base64 encoding of the encrypted data..
* /**
* @param(in) cryptData encrypted data * Performs base64 encoding of the encrypted data..
* @param(in) cryptDataLen length of encrypted data *
* @param(out) encodeData base64 encoded data * @param(in) cryptData encrypted data
* * @param(in) cryptDataLen length of encrypted data
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) encodeData base64 encoded data
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
*
int CryptManager::CryptBase64Encode(char *cryptData, int cryptDataLen, char **encodeData) */
{
int CryptManager::CryptBase64Encode(char *cryptData, int cryptDataLen, char **encodeData)
*encodeData = (*PLBase64Encode)((const char *)cryptData, cryptDataLen, NULL); {
if ( *encodeData == NULL ) *encodeData = (*PLBase64Encode)((const char *)cryptData, cryptDataLen, NULL);
{
PrintMessage(MESG_ERROR, "\n Base64 encoding failed ..."); if ( *encodeData == NULL )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n Base64 encoding failed ...");
return FPM_FALSE;
return FPM_TRUE; }
}
return FPM_TRUE;
}
/**
* Performs base64 decoding of the encrypted data..
* /**
* @param(in) cryptData encrypted data * Performs base64 decoding of the encrypted data..
* @param(out) decodeData base64 decoded data *
* @param(out) decodeLen length of base64 decoded data * @param(in) cryptData encrypted data
* * @param(out) decodeData base64 decoded data
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) decodeLen length of base64 decoded data
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
int CryptManager::CryptBase64Decode(char *cryptData, char **decodeData, int *decodeLen) *
{ */
int len = strlen( cryptData ); int CryptManager::CryptBase64Decode(char *cryptData, char **decodeData, int *decodeLen)
int adjust = 0; {
int len = strlen( cryptData );
PrintMessage(MESG_DEBUG, "\n CryptBase64Decode : Length of crypt data = %d", len); int adjust = 0;
// Compute length adjustment PrintMessage(MESG_DEBUG, "\n CryptBase64Decode : Length of crypt data = %d", len);
if (cryptData[len-1] == '=')
{ // Compute length adjustment
adjust++; if (cryptData[len-1] == '=')
if (cryptData[len-2] == '=') {
adjust++; adjust++;
} if (cryptData[len-2] == '=')
adjust++;
*decodeData = ( char *)(*PLBase64Decode)(cryptData, len, NULL); }
if( *decodeData == NULL ) *decodeData = ( char *)(*PLBase64Decode)(cryptData, len, NULL);
{
PrintMessage(MESG_ERROR, "\n Base64 decoding failed ..."); if( *decodeData == NULL )
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n Base64 decoding failed ...");
return FPM_FALSE;
*decodeLen = (len*3)/4 - adjust; }
PrintMessage(MESG_DEBUG, "\n CryptBase64Decode : Length of decoded data = %d", *decodeLen); *decodeLen = (len*3)/4 - adjust;
return FPM_TRUE; PrintMessage(MESG_DEBUG, "\n CryptBase64Decode : Length of decoded data = %d", *decodeLen);
}
return FPM_TRUE;
}
/**
* Performs TRIPLE DES encryption of clear text data
* /**
* @param(in) clearData clear text data to be encrypted * Performs TRIPLE DES encryption of clear text data
* @param(in) clearDataLen length of clear text data *
* @param(out) cryptData TRIPLE DES encrypted data * @param(in) clearData clear text data to be encrypted
* @param(out) cryptDataLen length of encrypted data * @param(in) clearDataLen length of clear text data
* * @param(out) cryptData TRIPLE DES encrypted data
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) cryptDataLen length of encrypted data
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
int CryptManager::CryptPK11EncryptString(char *clearData, int clearDataLen, char **cryptData, int *cryptDataLen) *
{ */
PK11SlotInfo *slot = 0; int CryptManager::CryptPK11EncryptString(char *clearData, int clearDataLen, char **cryptData, int *cryptDataLen)
SECItem keyid; {
SECItem request; PK11SlotInfo *slot = 0;
SECItem reply; SECItem keyid;
SECStatus status; SECItem request;
SECItem reply;
slot = (*PK11GetInternalKeySlot)(); SECStatus status;
if (!slot) slot = (*PK11GetInternalKeySlot)();
{
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_GetInternalKeySlot failed ..."); if (!slot)
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_GetInternalKeySlot failed ...");
return FPM_FALSE;
// PK11 authentication }
if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
{ // PK11 authentication
// since we have specified password callback function , we won't come here... if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_Authenticate failed, possibly master password is wrong"); {
(*PK11FreeSlot) (slot); // since we have specified password callback function , we won't come here...
return FPM_MASTERPASSWORD_WRONG; PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_Authenticate failed, possibly master password is wrong");
} (*PK11FreeSlot) (slot);
return FPM_MASTERPASSWORD_WRONG;
}
// Use default key id
keyid.data = 0;
keyid.len = 0; // Use default key id
request.data = (unsigned char *)clearData; keyid.data = 0;
request.len = clearDataLen; keyid.len = 0;
reply.data = 0; request.data = (unsigned char *)clearData;
reply.len = 0; request.len = clearDataLen;
reply.data = 0;
status = (*PK11SDREncrypt)(&keyid, &request, &reply, NULL); reply.len = 0;
if (status != SECSuccess) status = (*PK11SDREncrypt)(&keyid, &request, &reply, NULL);
{
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11SDR_Encrypt failed ..."); if (status != SECSuccess)
(*PK11FreeSlot) (slot); {
return FPM_FALSE; PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11SDR_Encrypt failed ...");
} (*PK11FreeSlot) (slot);
return FPM_FALSE;
}
*cryptData = (char*)reply.data;
*cryptDataLen = reply.len;
*cryptData = (char*)reply.data;
(*PK11FreeSlot) (slot); *cryptDataLen = reply.len;
return FPM_TRUE;
} (*PK11FreeSlot) (slot);
return FPM_TRUE;
}
/**
* Performs TRIPLE DES decryption of base64 decoded data
* /**
* @param(in) decodeData base64 decoded data * Performs TRIPLE DES decryption of base64 decoded data
* @param(in) decodeLen length of base64 decoded data *
* @param(out) clearData decrypted data * @param(in) decodeData base64 decoded data
* @param(out) finalLen length of decrypted data * @param(in) decodeLen length of base64 decoded data
* * @param(out) clearData decrypted data
* @return FPM_TRUE on success and FPM_FALSE on error. * @param(out) finalLen length of decrypted data
* *
*/ * @return FPM_TRUE on success and FPM_FALSE on error.
int CryptManager::CryptPK11DecryptString(char *decodeData, int decodeLen, char **clearData, int *finalLen) *
{ */
PK11SlotInfo *slot = 0; int CryptManager::CryptPK11DecryptString(char *decodeData, int decodeLen, char **clearData, int *finalLen)
SECStatus status; {
SECItem request; PK11SlotInfo *slot = 0;
SECItem reply; SECStatus status;
SECItem request;
PrintMessage(MESG_DEBUG, "\n CryptPK11DecryptString entered ..."); SECItem reply;
// Find token with SDR key PrintMessage(MESG_DEBUG, "\n CryptPK11DecryptString entered ...");
slot = (*PK11GetInternalKeySlot)();
// Find token with SDR key
if (!slot) slot = (*PK11GetInternalKeySlot)();
{
PrintMessage(MESG_ERROR, "\n PK11_GetInternalKeySlot failed ..."); if (!slot)
return FPM_FALSE; {
} PrintMessage(MESG_ERROR, "\n PK11_GetInternalKeySlot failed ...");
return FPM_FALSE;
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ..."); }
// Force authentication PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
{ // Force authentication
// since we have specified password callback function , we won't come here... if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
PrintMessage(MESG_ERROR, "\n PK11_Authenticate failed, Probably master password is wrong"); {
(*PK11FreeSlot) (slot); // since we have specified password callback function , we won't come here...
return FPM_MASTERPASSWORD_WRONG; PrintMessage(MESG_ERROR, "\n PK11_Authenticate failed, Probably master password is wrong");
} (*PK11FreeSlot) (slot);
return FPM_MASTERPASSWORD_WRONG;
PrintMessage(MESG_DEBUG, "\n PK11_Authenticate SUCCESS ..."); }
// Decrypt the string PrintMessage(MESG_DEBUG, "\n PK11_Authenticate SUCCESS ...");
request.data = (unsigned char *)decodeData;
request.len = decodeLen; // Decrypt the string
reply.data = 0; request.data = (unsigned char *)decodeData;
reply.len = 0; request.len = decodeLen;
reply.data = 0;
PrintMessage(MESG_DEBUG, "\n calling PK11SDR_Decrypt ..."); reply.len = 0;
status = (*PK11SDRDecrypt)(&request, &reply, NULL); PrintMessage(MESG_DEBUG, "\n calling PK11SDR_Decrypt ...");
if (status != SECSuccess) status = (*PK11SDRDecrypt)(&request, &reply, NULL);
{
PrintMessage(MESG_ERROR, "\n PK11SDR_Decrypt failed ..."); if (status != SECSuccess)
(*PK11FreeSlot) (slot); {
return FPM_FALSE; PrintMessage(MESG_ERROR, "\n PK11SDR_Decrypt failed ...");
} (*PK11FreeSlot) (slot);
return FPM_FALSE;
PrintMessage(MESG_DEBUG, "\n PK11SDR_Decrypt SUCCESS "); }
// WARNING : This string is not NULL terminated.. PrintMessage(MESG_DEBUG, "\n PK11SDR_Decrypt SUCCESS ");
*clearData = (char*)reply.data;
*finalLen = reply.len; // WARNING : This string is not NULL terminated..
*clearData = (char*)reply.data;
// Free the slot *finalLen = reply.len;
(*PK11FreeSlot) (slot);
// Free the slot
return FPM_TRUE; (*PK11FreeSlot) (slot);
}
return FPM_TRUE;
}

View File

@ -1,62 +1,64 @@
/*********************************************************************** /***********************************************************************
* *
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1 * License as published by the Free Software Foundation; version 2.1
* of the License. * of the License.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details. * Library Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc. * License along with this library; if not, Novell, Inc.
* *
* To contact Novell about this file by physical or electronic mail, * To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com. * you may find current contact information at www.novell.com.
* *
***********************************************************************/ ***********************************************************************/
#ifndef __FPM_CRYPT_MANAGER_H__ #ifndef __FPM_CRYPT_MANAGER_H__
#define __FPM_CRYPT_MANAGER_H__ #define __FPM_CRYPT_MANAGER_H__
#include "FirefoxPasswordManager.h" #include "FirefoxPasswordManager.h"
#include "Common.h" #include "Common.h"
class CryptManager class CryptManager
{ {
//PK11_SetPasswordFunc PK11SetPasswordFunc; //PK11_SetPasswordFunc PK11SetPasswordFunc;
PK11_GetInternalKeySlot PK11GetInternalKeySlot; PK11_GetInternalKeySlot PK11GetInternalKeySlot;
PK11_FreeSlot PK11FreeSlot; PK11_FreeSlot PK11FreeSlot;
PK11_Authenticate PK11Authenticate; PK11_Authenticate PK11Authenticate;
PK11_CheckUserPassword PK11CheckUserPassword; PK11_CheckUserPassword PK11CheckUserPassword;
PK11SDR_Decrypt PK11SDRDecrypt; PK11SDR_Decrypt PK11SDRDecrypt;
PK11SDR_Encrypt PK11SDREncrypt; PK11SDR_Encrypt PK11SDREncrypt;
PK11_NeedUserInit PK11NeedUserInit;
PL_Base64Encode PLBase64Encode; PK11_InitPin PK11InitPin;
PL_Base64Decode PLBase64Decode;
PL_Base64Encode PLBase64Encode;
public: PL_Base64Decode PLBase64Decode;
int DecryptString(char *cryptData, char **clearData); public:
int EncryptString (char *clearData, char **finalData) ;
int CryptBase64Decode(char *cryptData, char **decodeData, int *decodeLen); int DecryptString(char *cryptData, char **clearData);
int CryptBase64Encode(char *cryptData, int cryptDataLen, char **encodeData); int EncryptString (char *clearData, char **finalData) ;
int CryptPK11DecryptString(char *decodeData, int decodeLen, char **clearData, int *finalLen); int CryptBase64Decode(char *cryptData, char **decodeData, int *decodeLen);
int CryptPK11EncryptString(char *clearData, int clearDataLen, char **cryptData, int *cryptDataLen); int CryptBase64Encode(char *cryptData, int cryptDataLen, char **encodeData);
int CryptPK11DecryptString(char *decodeData, int decodeLen, char **clearData, int *finalLen);
void SetupFunctions(void *funList[]); int CryptPK11EncryptString(char *clearData, int clearDataLen, char **cryptData, int *cryptDataLen);
int GetEncryptionPref();
void SetupFunctions(void *funList[]);
}; int GetEncryptionPref();
};
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,186 +1,193 @@
/*********************************************************************** /***********************************************************************
* *
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1 * License as published by the Free Software Foundation; version 2.1
* of the License. * of the License.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details. * Library Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc. * License along with this library; if not, Novell, Inc.
* *
* To contact Novell about this file by physical or electronic mail, * To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com. * you may find current contact information at www.novell.com.
* *
***********************************************************************/ ***********************************************************************/
#ifndef __FPM_Firefox_Password_MANAGER_H__ #ifndef __FPM_Firefox_Password_MANAGER_H__
#define __FPM_Firefox_Password_MANAGER_H__ #define __FPM_Firefox_Password_MANAGER_H__
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
#include <sys/stat.h>
#ifdef WIN32 #include <sys/types.h>
#include <windows.h>
#include <userenv.h> #ifdef WIN32
#pragma comment(lib,"userenv.lib") #include <windows.h>
#include <userenv.h>
#define STRCMPI strcmpi #include <direct.h>
#define APIEXPORT __declspec(dllexport) #pragma comment(lib,"userenv.lib")
#define NSS_LIBRARY_NAME "nss3.dll" #define STRCMPI strcmpi
#define PLC_LIBRARY_NAME "plc4.dll" #define APIEXPORT __declspec(dllexport)
#define NSPR_LIBRARY_NAME "nspr4.dll"
#define PLDS_LIBRARY_NAME "plds4.dll" #define NSS_LIBRARY_NAME "nss3.dll"
#define SOFTN_LIBRARY_NAME "softokn3.dll" #define PLC_LIBRARY_NAME "plc4.dll"
#define NSPR_LIBRARY_NAME "nspr4.dll"
#define LOADLIBRARY(x) LoadLibrary(x) #define PLDS_LIBRARY_NAME "plds4.dll"
#define GETPROCADDRESS GetProcAddress #define SOFTN_LIBRARY_NAME "softokn3.dll"
#define FREELIBRARY FreeLibrary
#define LOADLIBRARY(x) LoadLibrary(x)
#else #define GETPROCADDRESS GetProcAddress
#include <dlfcn.h> #define FREELIBRARY FreeLibrary
#define STRCMPI strcasecmp
#define APIEXPORT #else
#include <dlfcn.h>
#define NSS_LIBRARY_NAME "libnss3.so" #define STRCMPI strcasecmp
#define PLC_LIBRARY_NAME "libplc4.so" #define APIEXPORT
#define NSPR_LIBRARY_NAME "libnspr4.so"
#define PLDS_LIBRARY_NAME "libplds4.so" #define NSS_LIBRARY_NAME "libnss3.so"
#define SOFTN_LIBRARY_NAME "libsoftokn3.so" #define PLC_LIBRARY_NAME "libplc4.so"
#define NSPR_LIBRARY_NAME "libnspr4.so"
#define LOADLIBRARY(x) dlopen(x, RTLD_LAZY) // alternative : RTLD_NOW #define PLDS_LIBRARY_NAME "libplds4.so"
#define GETPROCADDRESS dlsym #define SOFTN_LIBRARY_NAME "libsoftokn3.so"
#define FREELIBRARY dlclose
#define LOADLIBRARY(x) dlopen(x, RTLD_LAZY) // alternative : RTLD_NOW
#define HMODULE void * #define GETPROCADDRESS dlsym
#define FREELIBRARY dlclose
#endif
#define HMODULE void *
#endif
#define FPM_TRUE 1
#define FPM_FALSE 0
#define MESG_DEBUG 0 #define FPM_TRUE 1
#define MESG_PRINT 1 #define FPM_FALSE 0
#define MESG_ERROR 2
#define MESG_DEBUG 0
#define MAX_PROFILE_COUNT 5 #define MESG_PRINT 1
#define MESG_ERROR 2
//#define DEBUG 11
#define MAX_PROFILE_COUNT 5
#define Unichar unsigned int
//#define DEBUG 11
#define HEADER_VERSION "#2c"
#define CRYPT_PREFIX "~" #define Unichar unsigned int
#define SIGNON_FILE_NAME "signons.txt" #define HEADER_VERSION "#2c"
#define CRYPT_PREFIX "~"
// Internal structure declaration taken from firefox.....
typedef enum SECItemType #define SIGNON_FILE_NAME "signons.txt"
{
siBuffer = 0, // Internal structure declaration taken from firefox.....
siClearDataBuffer = 1, typedef enum SECItemType
siCipherDataBuffer = 2, {
siDERCertBuffer = 3, siBuffer = 0,
siEncodedCertBuffer = 4, siClearDataBuffer = 1,
siDERNameBuffer = 5, siCipherDataBuffer = 2,
siEncodedNameBuffer = 6, siDERCertBuffer = 3,
siAsciiNameString = 7, siEncodedCertBuffer = 4,
siAsciiString = 8, siDERNameBuffer = 5,
siDEROID = 9, siEncodedNameBuffer = 6,
siUnsignedInteger = 10, siAsciiNameString = 7,
siUTCTime = 11, siAsciiString = 8,
siGeneralizedTime = 12 siDEROID = 9,
}; siUnsignedInteger = 10,
siUTCTime = 11,
//typedef struct SECItemStr SECItem; siGeneralizedTime = 12
};
struct SECItem
{ //typedef struct SECItemStr SECItem;
SECItemType type;
unsigned char *data; struct SECItem
unsigned int len; {
}; SECItemType type;
unsigned char *data;
unsigned int len;
typedef enum SECStatus };
{
SECWouldBlock = -2,
SECFailure = -1, typedef enum SECStatus
SECSuccess = 0 {
}; SECWouldBlock = -2,
SECFailure = -1,
// For some PR type varialbes...just to remove gecko-sdk dependency SECSuccess = 0
// following is added here. };
#define PRBool int
#define PRUint32 unsigned int // For some PR type varialbes...just to remove gecko-sdk dependency
#define PR_TRUE 1 // following is added here.
#define PR_FALSE 0 #define PRBool int
#define PRUint32 unsigned int
#define PR_TRUE 1
#define PR_FALSE 0
// End
// End
typedef struct PK11SlotInfoStr PK11SlotInfo;
// NSS Library functions
//typedef char *(PR_CALLBACK *PK11PasswordFunc)(PK11SlotInfo *slot, PRBool retry, void *arg); typedef struct PK11SlotInfoStr PK11SlotInfo;
typedef SECStatus (*NSS_Init) (const char *configdir);
typedef SECStatus (*NSS_Shutdown) (void); // NSS Library functions
//typedef void (*PK11_SetPasswordFunc) (PK11PasswordFunc func); //typedef char *(PR_CALLBACK *PK11PasswordFunc)(PK11SlotInfo *slot, PRBool retry, void *arg);
typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void); typedef SECStatus (*NSS_Init) (const char *configdir);
typedef void (*PK11_FreeSlot) (PK11SlotInfo *slot); typedef SECStatus (*NSS_Shutdown) (void);
typedef SECStatus (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCerts, void *wincx); //typedef void (*PK11_SetPasswordFunc) (PK11PasswordFunc func);
typedef SECStatus (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw); typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void);
typedef SECStatus (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx); typedef void (*PK11_FreeSlot) (PK11SlotInfo *slot);
typedef SECStatus (*PK11SDR_Encrypt) (SECItem *keyid, SECItem *data, SECItem *result, void *cx); typedef SECStatus (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
typedef SECStatus (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw);
// PLC Library functions typedef SECStatus (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx);
typedef char * (*PL_Base64Encode)( const char *src, PRUint32 srclen, char *dest); typedef SECStatus (*PK11SDR_Encrypt) (SECItem *keyid, SECItem *data, SECItem *result, void *cx);
typedef char * (*PL_Base64Decode)( const char *src, PRUint32 srclen, char *dest); typedef PRBool (*PK11_NeedUserInit) (PK11SlotInfo *slot);
typedef SECStatus (*PK11_InitPin) (PK11SlotInfo *slot,char *ssopw, char *pk11_userpwd);
void PrintMessage( int level, char *mesg , ...); typedef SECStatus (*NSS_InitReadWrite) (const char *configdir);
int IsDirectoryExists( char *path );
void StrLwr(char *str); // PLC Library functions
typedef char * (*PL_Base64Encode)( const char *src, PRUint32 srclen, char *dest);
typedef char * (*PL_Base64Decode)( const char *src, PRUint32 srclen, char *dest);
// Profile initiliazation functions void PrintMessage( int level, char *mesg , ...);
extern "C" APIEXPORT int FPM_IsStoreAvailable(); int IsDirectoryExists( char *path );
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int **profileFlag); void StrLwr(char *str);
extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName); int CreateDirectory( char *path );
extern "C" APIEXPORT int FPM_FirefoxProfileExit(char *profileName);
// Master password functions
extern "C" APIEXPORT int FPM_IsMasterPasswordSet(char *profileName); // Profile initiliazation functions
extern "C" APIEXPORT int FPM_CheckMasterPassword(char *profileName, char *masterPassword); extern "C" APIEXPORT int FPM_IsStoreAvailable();
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int **profileFlag);
// Signon data update functions extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName);
extern "C" APIEXPORT int FPM_GetSignonData(char *profileName,struct Host **host, int doRefresh); extern "C" APIEXPORT int FPM_FirefoxProfileExit(char *profileName);
extern "C" APIEXPORT int FPM_WriteSignonData(char *profileName);
extern "C" APIEXPORT int FPM_AddHost(char *profileName, struct Host *host, int doUpdate); // Master password functions
extern "C" APIEXPORT int FPM_ModifyHost(char *profileName, struct Host *host, int doUpdate); extern "C" APIEXPORT int FPM_IsMasterPasswordSet(char *profileName);
extern "C" APIEXPORT int FPM_RemoveHost(char *profileName, char *hostname, int doUpdate); extern "C" APIEXPORT int FPM_CheckMasterPassword(char *profileName, char *masterPassword);
// Signon data update functions
#endif extern "C" APIEXPORT int FPM_GetSignonData(char *profileName,struct Host **host, int doRefresh);
extern "C" APIEXPORT int FPM_WriteSignonData(char *profileName);
extern "C" APIEXPORT int FPM_AddHost(char *profileName, struct Host *host, int doUpdate);
extern "C" APIEXPORT int FPM_ModifyHost(char *profileName, struct Host *host, int doUpdate);
extern "C" APIEXPORT int FPM_RemoveHost(char *profileName, char *hostname, int doUpdate);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +1,96 @@
/*********************************************************************** /***********************************************************************
* *
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1 * License as published by the Free Software Foundation; version 2.1
* of the License. * of the License.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details. * Library Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc. * License along with this library; if not, Novell, Inc.
* *
* To contact Novell about this file by physical or electronic mail, * To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com. * you may find current contact information at www.novell.com.
* *
***********************************************************************/ ***********************************************************************/
#ifndef __FPM_PROFILE_MANAGER_H__ #ifndef __FPM_PROFILE_MANAGER_H__
#define __FPM_PROFILE_MANAGER_H__ #define __FPM_PROFILE_MANAGER_H__
#include "FirefoxPasswordManager.h" #include "FirefoxPasswordManager.h"
#include "Common.h" #include "Common.h"
#include "SignonManager.h" #include "SignonManager.h"
class ProfileManager class ProfileManager
{ {
SignonManager signonManager; SignonManager signonManager;
char *profilePath; char *profilePath;
char *libraryPath; char *libraryPath;
char *masterPassword; char *masterPassword;
HMODULE libnss; HMODULE libnss;
HMODULE libplc; HMODULE libplc;
// NSS Library function pointers // NSS Library function pointers
NSS_Init NSSInit; NSS_Init NSSInit;
NSS_Shutdown NSSShutdown; NSS_Shutdown NSSShutdown;
//PK11_SetPasswordFunc PK11SetPasswordFunc; //PK11_SetPasswordFunc PK11SetPasswordFunc;
PK11_GetInternalKeySlot PK11GetInternalKeySlot; PK11_GetInternalKeySlot PK11GetInternalKeySlot;
PK11_FreeSlot PK11FreeSlot; PK11_FreeSlot PK11FreeSlot;
PK11_Authenticate PK11Authenticate; PK11_Authenticate PK11Authenticate;
PK11_CheckUserPassword PK11CheckUserPassword; PK11_CheckUserPassword PK11CheckUserPassword;
PK11SDR_Decrypt PK11SDRDecrypt; PK11SDR_Decrypt PK11SDRDecrypt;
PK11SDR_Encrypt PK11SDREncrypt; PK11SDR_Encrypt PK11SDREncrypt;
PK11_NeedUserInit PK11NeedUserInit;
PL_Base64Encode PLBase64Encode; PK11_InitPin PK11InitPin;
PL_Base64Decode PLBase64Decode; NSS_InitReadWrite NSSInitReadWrite;
public : PL_Base64Encode PLBase64Encode;
PL_Base64Decode PLBase64Decode;
char *profileName;
int isInitialized; public :
private : char *profileName;
int isInitialized;
char *GetFirefoxProfilePath(char *profileName);
char *GetFirefoxLibPath(); private :
HMODULE PMLoadLibrary(char *firefoxDir, char *libName);
int RefreshSignonData(); char *GetFirefoxProfilePath(char *profileName);
char *GetFirefoxLibPath();
HMODULE PMLoadLibrary(char *firefoxDir, char *libName);
int RefreshSignonData();
public:
ProfileManager();
public:
int IsStoreAvailable();
int ProfileInit(char *profileName); ProfileManager();
void ProfileExit();
int IsStoreAvailable();
int IsMasterPasswordSet(); int ProfileInit(char *profileName);
int CheckMasterPassword(char *masterPassword, int doSave); void ProfileExit();
int GetSignonData( struct Host **host, int doRefresh); int IsMasterPasswordSet();
int WriteSignonData(); int CheckMasterPassword(char *masterPassword, int doSave);
int AddHost(struct Host *host, int doUpdate); int GetSignonData( struct Host **host, int doRefresh);
int ModifyHost(struct Host *host, int doUpdat); int WriteSignonData();
int RemoveHost(char *hostname, int doUpdate);
int AddHost(struct Host *host, int doUpdate);
}; int ModifyHost(struct Host *host, int doUpdat);
int RemoveHost(char *hostname, int doUpdate);
#endif };
#endif

View File

@ -78,9 +78,25 @@ char *signonFilePath = NULL;
if( signonFile == 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);
free(signonFilePath); PrintMessage(MESG_DEBUG, "\n SignonManager : Creating new signon file %s", signonFilePath);
return FPM_SIGNON_FILE_NOT_PRESENT;
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 // cleanup
@ -238,7 +254,7 @@ int SignonManager::WriteCharUTF8(Unichar c)
int SignonManager::WriteLine(char *line) 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 ) if( WriteCharUTF8(line[i]) != FPM_TRUE )
return FPM_SIGNON_FILE_WRITE_ERROR; return FPM_SIGNON_FILE_WRITE_ERROR;
@ -269,6 +285,7 @@ char name[1024];
int bufferLength = 4095; int bufferLength = 4095;
int retValue; int retValue;
char *clearData = NULL; char *clearData = NULL;
char *newHostName, *uname;
int count = 0; int count = 0;
@ -349,6 +366,7 @@ int count = 0;
PrintMessage(MESG_DEBUG, "\n\n Host : %s ", hostName); PrintMessage(MESG_DEBUG, "\n\n Host : %s ", hostName);
// prepare to read the name/value pairs // prepare to read the name/value pairs
count = 0;
while( ReadLine(buffer, bufferLength) == FPM_TRUE ) while( ReadLine(buffer, bufferLength) == FPM_TRUE )
{ {
// line starting with . terminates the pairs for this URL entry // line starting with . terminates the pairs for this URL entry
@ -370,7 +388,8 @@ int count = 0;
isPassword = 0; isPassword = 0;
strcpy(name, buffer); strcpy(name, buffer);
retValue = ReadLine(buffer, bufferLength); retValue = ReadLine(buffer, bufferLength);
} }
count++;
PrintMessage(MESG_DEBUG, "\n\n name = %s and value = %s ", name, buffer); PrintMessage(MESG_DEBUG, "\n\n name = %s and value = %s ", name, buffer);
@ -390,8 +409,28 @@ int count = 0;
if( ((retValue = cryptManager.DecryptString(buffer, &clearData)) == FPM_TRUE) && (clearData != NULL) ) if( ((retValue = cryptManager.DecryptString(buffer, &clearData)) == FPM_TRUE) && (clearData != NULL) )
{ {
// Add the name/value pair to the existing store.... // Add the name/value pair to the existing store....
retValue = dataManager.AddHostElement(hostName, name, clearData, isPassword); 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 ) if( retValue != FPM_TRUE )
{ {
CloseSignonFile(); CloseSignonFile();
@ -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 // Now close the signon file
CloseSignonFile(); CloseSignonFile();
// Print data for cross checking // Print data for cross checking
#ifdef DEBUG #ifdef DEBUG
dataManager.PrintAllRejectHosts(); dataManager.PrintAllRejectHosts();
@ -434,9 +480,11 @@ char *signonFilePath = NULL;
char *tempFilePath = NULL; char *tempFilePath = NULL;
char fileName[256]; char fileName[256];
Host *t; Host *writeList, *newHost;
HostElement *h; HostElement *h, *temp;
RejectHost *r; RejectHost *r;
char *hn2;
int len;
// TODO : If signon data has not changed since last write then return... // TODO : If signon data has not changed since last write then return...
/* // There may be requirement to write empty data... /* // There may be requirement to write empty data...
@ -499,9 +547,55 @@ RejectHost *r;
* if type is password, name is preceded by an asterisk (*) * 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 // 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); 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: case Common.STORE_FIREFOX:
if( 0 != objFirefox.tvSecretIDFirefox.Selection.CountSelectedRows() ) if( 0 != objFirefox.tvSecretIDFirefox.Selection.CountSelectedRows() )
{ {
mmiNew.Sensitive = mmiNewKey.Sensitive = false; mmiNew.Sensitive = true;
mmiNewKey.Sensitive = true;
} }
else else
{ {
mmiNew.Sensitive = mmiNewKey.Sensitive = false; mmiNewKey.Sensitive = false;
} }
break; break;
@ -1194,6 +1195,7 @@ namespace Novell.CASA.GUI
break; break;
case Common.STORE_FIREFOX: case Common.STORE_FIREFOX:
objFirefox.OnNewSecretActivated(obj, args);
break; break;
case Common.STORE_MOZILLA: case Common.STORE_MOZILLA:
@ -1232,6 +1234,7 @@ namespace Novell.CASA.GUI
break; break;
case Common.STORE_FIREFOX: case Common.STORE_FIREFOX:
objFirefox.OnNewKeyActivated(obj, args);
break; break;
case Common.STORE_MOZILLA: case Common.STORE_MOZILLA:
@ -2305,7 +2308,7 @@ namespace Novell.CASA.GUI
{ {
DbgFileChooser dbf = new DbgFileChooser(); DbgFileChooser dbf = new DbgFileChooser();
dbf.Run(); dbf.Run();
} }
} }
} }

View File

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

View File

@ -38,12 +38,18 @@ public class Firefox : Store
tsKeyValue; tsKeyValue;
CellRendererText cellEditable; CellRendererText cellEditable;
CellRendererToggle cellToggle;
ArrayList arrDeletedKeys = null;
bool isPasswordToggled;
public bool IS_STORE_AGGREGATED = false; public bool IS_STORE_AGGREGATED = false;
private int m_iRememberSeconds = 5; private int m_iRememberSeconds = 5;
private String m_sRememberFor = "5"; private String m_sRememberFor = "5";
private Config m_config = null; private Config m_config = null;
static Char[] SpecialCharacters = new Char[]{ '*', '\'', '\\', '&', '=', '<', '>' };
#region Glade Widgets #region Glade Widgets
[Glade.Widget] [Glade.Widget]
@ -60,6 +66,7 @@ public class Firefox : Store
dialogManageSecret, dialogManageSecret,
dialogLogin, dialogLogin,
dialogConfirmDelete, dialogConfirmDelete,
dialogInvalidSecret,
dialogSpecialCharacter; dialogSpecialCharacter;
[Glade.Widget] [Glade.Widget]
@ -112,7 +119,7 @@ public class Firefox : Store
m_config = config; m_config = config;
/// SecretID TreeStore /// SecretID TreeStore
tvSecretIDFirefox = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDFirefox"); 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.AppendColumn("Secret ID",new CellRendererText(),"text",0);
tvSecretIDFirefox.Model = tsSecretIDFirefox; tvSecretIDFirefox.Model = tsSecretIDFirefox;
tvSecretIDFirefox.RowActivated += new RowActivatedHandler(OntvSecretIDFirefoxRowActivated); tvSecretIDFirefox.RowActivated += new RowActivatedHandler(OntvSecretIDFirefoxRowActivated);
@ -213,9 +220,15 @@ public class Firefox : Store
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime); menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() ) if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() )
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = false; {
else cmiNewSecret.Sensitive = cmiNewKey.Sensitive = true;
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiDelete.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiView.Sensitive = false; cmiLink.Sensitive = cmiCopy.Sensitive = false;
}
else
{
cmiNewSecret.Sensitive = true;
cmiNewKey.Sensitive = cmiDelete.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiView.Sensitive = false;
}
} }
catch(Exception exp) catch(Exception exp)
{ {
@ -240,14 +253,22 @@ public class Firefox : Store
string selected= null; string selected= null;
string[] keys = null, string[] keys = null,
values = null; values = null;
bool[] ispassword = null;
isPasswordToggled = false;
try try
{ {
if( null == arrDeletedKeys )
arrDeletedKeys = new ArrayList();
else
arrDeletedKeys.Clear();
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) ) if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
{ {
selected = (string) model.GetValue(iter, 0); selected = (string) model.GetValue(iter, 0);
keys = (string[]) model.GetValue(iter, 1); keys = (string[]) model.GetValue(iter, 1);
values = (string[]) model.GetValue(iter, 2); values = (string[]) model.GetValue(iter, 2);
ispassword = (bool[]) model.GetValue(iter, 6);
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null); Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null);
gxmlTemp.Autoconnect (this); gxmlTemp.Autoconnect (this);
@ -256,24 +277,27 @@ public class Firefox : Store
cellEditable = new CellRendererText(); cellEditable = new CellRendererText();
cellEditable.Editable = true; cellEditable.Editable = true;
cellEditable.Edited += new EditedHandler(OnKeyValueEdited); cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
//cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 cellToggle = new CellRendererToggle();
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string)); 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("Key",new CellRendererText(),"text",0);
tvKeyValue.AppendColumn("Value",cellEditable,"text",2); tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Password", cellToggle, "active", 5);
tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4); tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4);
entrySecretID.MaxLength=1028;
entrySecretID.Text=selected; entrySecretID.Text=selected;
for( int i=0; i< keys.Length; i++ ) for( int i=0; i< keys.Length; i++ )
{ {
if( (null != keys[i]) && (null != values[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; tvKeyValue.Model = tsKeyValue;
//entryKey.HasFocus = true;
entryKey.Sensitive = entryValue.Sensitive = buttonNewAdd.Sensitive = buttonNewRemove.Sensitive = false;
} }
} }
catch(Exception exp) catch(Exception exp)
@ -284,6 +308,46 @@ public class Firefox : Store
Logger.DbgLog("GUI:Firefox.ViewKeyValues() - END"); 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> /// <summary>
/// EDIT KEY-VALUE /// EDIT KEY-VALUE
/// </summary> /// </summary>
@ -296,6 +360,7 @@ public class Firefox : Store
object val; object val;
string KeyName = null, string KeyName = null,
KeyValue = null; KeyValue = null;
bool KeyIsPassword;
string[] Keys = null, string[] Keys = null,
Values = null; Values = null;
@ -309,6 +374,7 @@ public class Firefox : Store
else else
val = tsKeyValue.GetValue(iter,2); val = tsKeyValue.GetValue(iter,2);
KeyValue = val.ToString(); KeyValue = val.ToString();
KeyIsPassword = (bool)tsKeyValue.GetValue(iter,5);
tvSecretIDFirefox.Selection.GetSelected (out model, out iter); 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) ) 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) ) 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"); Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - StoreDataInterface.UpdateStore() succeeded");
@ -362,25 +443,282 @@ public class Firefox : Store
/// </summary> /// </summary>
public void on_buttonNewAdd_clicked(object obj, EventArgs args) 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) public void on_buttonSCClose_clicked(object obj, EventArgs args)
{ {
dialogSpecialCharacter.Destroy(); dialogSpecialCharacter.Destroy();
} }
public void on_buttonISClose_clicked(object obj, EventArgs args)
{
dialogInvalidSecret.Destroy();
}
/// <summary> /// <summary>
/// REMOVE BUTTON CLICKED /// REMOVE BUTTON CLICKED
/// </summary> /// </summary>
public void on_buttonNewRemove_clicked(object obj, EventArgs args) 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> /// <summary>
/// MANAGE SECRET ID DIALOG OK-BUTTON CLICKED /// MANAGE SECRET ID DIALOG OK-BUTTON CLICKED
/// </summary> /// </summary>
public void on_buttonManageOk_clicked(object obj, EventArgs args) 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(); tsKeyValue.Dispose();
dialogManageSecret.Destroy(); dialogManageSecret.Destroy();
} }
@ -584,11 +922,155 @@ public class Firefox : Store
ViewKeyValues(); 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) public void on_buttonNewCancel_clicked(object obj, EventArgs args)
{ {
dialogNewSecret.Destroy(); dialogNewSecret.Destroy();
} }
public void on_helpbuttonNewSecret_clicked(object obj, EventArgs args)
{
Common.ShowHelpUrl("AddNewSecrets.htm");
}
///####################################################################### ///#######################################################################
/// ADD NEW SECRET /// ADD NEW SECRET
/// <summary> /// <summary>
@ -596,6 +1078,33 @@ public class Firefox : Store
/// </summary> /// </summary>
public void OnNewSecretActivated(object obj, EventArgs args) 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");
} }
///####################################################################### ///#######################################################################
@ -604,7 +1113,12 @@ public class Firefox : Store
/// ///
/// </summary> /// </summary>
public void OnNewKeyActivated(object obj, EventArgs args) 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(); tvSecretIDFirefox.ColumnsAutosize();
tsNativeInfoFirefox.Clear(); tsNativeInfoFirefox.Clear();
dialogConfirmDelete.Destroy(); dialogConfirmDelete.Destroy();
AggregateStore();
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - DELETE_SECRET_SUCCEEDED"); Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - DELETE_SECRET_SUCCEEDED");
} }
@ -691,7 +1206,20 @@ 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_ZONE = "Zone",
CCFXML_ELEMENT_TIME_CREATION = "Creation", CCFXML_ELEMENT_TIME_CREATION = "Creation",
CCFXML_ELEMENT_TIME_MODIFIED = "Modified", CCFXML_ELEMENT_TIME_MODIFIED = "Modified",
CCFXML_ATTRIBUTE_PASSWDSTATUS = "PasswordStatus",
CCFXML_ATTRIBUTE_FFOX_TYPE = "Signon",
CCFXML_ELEMENT_TIME_ACCESSED = "Accessed", CCFXML_ELEMENT_TIME_ACCESSED = "Accessed",
CCFXML_ATTRIBUTE_ID = "ID", CCFXML_ATTRIBUTE_ID = "ID",
CCFXML_ATTRIBUTE_MICASA_SYNCH = "Synch", CCFXML_ATTRIBUTE_MICASA_SYNCH = "Synch",
@ -171,6 +173,7 @@ namespace Novell.CASA.GUI {
string secretID = null; string secretID = null;
string[] strKeyArray = null; string[] strKeyArray = null;
string[] strValueArray = null; string[] strValueArray = null;
bool[] boolIsPassArray = null;
string storeID = null; string storeID = null;
string[] strNativeKeyArray = new string[Common.MAX_NATIVE_ELEMENTS]; string[] strNativeKeyArray = new string[Common.MAX_NATIVE_ELEMENTS];
string[] strNativeValueArray = 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 //Reinit arrays to the no of keys for this secret
strKeyArray = new string[noOfKeys]; strKeyArray = new string[noOfKeys];
strValueArray = new string[noOfKeys]; strValueArray = new string[noOfKeys];
boolIsPassArray = new bool[noOfKeys];
//Get Last Modified Time for the secret //Get Last Modified Time for the secret
ccfExtPath = CCFXML_ELEMENT_TIME + "/" + CCFXML_ELEMENT_TIME_MODIFIED; ccfExtPath = CCFXML_ELEMENT_TIME + "/" + CCFXML_ELEMENT_TIME_MODIFIED;
@ -334,6 +338,14 @@ namespace Novell.CASA.GUI {
bKey = true; bKey = true;
strKeyArray[noOfKeysFound] = iterSecret.Current.Value; //KeyName 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() ); }while( iterSecret.Current.MoveToNextAttribute() );
iterSecret.Current.MoveToParent(); iterSecret.Current.MoveToParent();
@ -391,8 +403,10 @@ namespace Novell.CASA.GUI {
strNativeValueArray[Common.INDEX_NATIVEINFO_SYNCTYPE] = synchType; strNativeValueArray[Common.INDEX_NATIVEINFO_SYNCTYPE] = synchType;
strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = modifiedTime; strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = modifiedTime;
//Console.WriteLine("folderName="+folderName+"\n"+"typeID="+typeID+"\n"+"synch="+synch+"\n"+"synchType="+synchType+"\n"+"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); ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray,boolIsPassArray);
else
ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray);
//Re-Initialize for next iteration //Re-Initialize for next iteration
secretID = ""; secretID = "";
@ -415,7 +429,106 @@ namespace Novell.CASA.GUI {
return( Common.STATUS_SUCCESS ); 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 /// UPDATE STORE: ADD NEW secret/keyvalue, MODIFY keyvalue, DELETE secret
@ -433,6 +546,7 @@ namespace Novell.CASA.GUI {
string keyChainID = null; string keyChainID = null;
string[] strKeyArray = new string[Common.MAX_ARRAY_ELEMENTS]; string[] strKeyArray = new string[Common.MAX_ARRAY_ELEMENTS];
string[] strValueArray = 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]; string[] strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
//XPATH query strings //XPATH query strings
@ -452,6 +566,8 @@ namespace Novell.CASA.GUI {
strValueArray = (string[]) model.GetValue (iter, 2); strValueArray = (string[]) model.GetValue (iter, 2);
keyChainID = (string) model.GetValue (iter, 3); keyChainID = (string) model.GetValue (iter, 3);
strNativeValueArray = (string[]) model.GetValue (iter, 5); strNativeValueArray = (string[]) model.GetValue (iter, 5);
if (storeIDentifier == Common.STORE_FIREFOX)
boolIsPassArray = (bool[]) model.GetValue (iter, 6);
try 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:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfSecretPath:"+ccfSecretPath);//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 else
return( Common.STATUS_STORE_UNSUPPORTEDOPERATION ); return( Common.STATUS_STORE_UNSUPPORTEDOPERATION );
@ -670,7 +823,7 @@ namespace Novell.CASA.GUI {
XmlNodeList keylist = root.SelectNodes(ccfSecretPath); XmlNodeList keylist = root.SelectNodes(ccfSecretPath);
foreach ( XmlNode key in keylist ) foreach ( XmlNode key in keylist )
{ {
key.ChildNodes[0].InnerText=valueToBeModfied ; key.ChildNodes[0].InnerText=valueToBeModfied ;
//Console.WriteLine("EXECUTING OPERATION_MODIFY_KEY:Modifying"+ccfSecretPath);//FIXME:Remove this line //Console.WriteLine("EXECUTING OPERATION_MODIFY_KEY:Modifying"+ccfSecretPath);//FIXME:Remove this line
ad.SetSecret(key.ParentNode,operation,storeIDentifier); ad.SetSecret(key.ParentNode,operation,storeIDentifier);
} }
@ -710,7 +863,7 @@ namespace Novell.CASA.GUI {
{ {
//ShowDocOnConsole("BEFORE CALL TO SETSECRET");//FIXME:Remove this //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 //Add a new secret to the keychain
XmlNode root = ccfDoc.DocumentElement; XmlNode root = ccfDoc.DocumentElement;

File diff suppressed because it is too large Load Diff