diff --git a/c_adlib/AD_Facade.cs b/c_adlib/AD_Facade.cs index aaaf9b38..4883de5d 100644 --- a/c_adlib/AD_Facade.cs +++ b/c_adlib/AD_Facade.cs @@ -51,46 +51,44 @@ namespace Novell.CASA.DataEngines // Always Aggregate miCASA. micasaengine = new miCASAEngine(); #if LINUX + //FIXME: This should not be done always but should be based on policy as explained + //for firefox below. kwEngine = new KWalletEngine(); gkEngine = new GKEngine(); - ffEngine = new FFEngine(); -#endif -/* - - // Reading Policy to see what else needs to be Aggregated. - aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL); - if (aggPol != null ) - { - ArrayList stores = aggPol.StoreList; - IEnumerator enumerator = stores.GetEnumerator(); - - while(enumerator.MoveNext()) - { - string storeID = (((Store)(enumerator.Current)).StoreName); - - if(storeID.Equals(ConstStrings.KW)) - { - Logger.DbgLog("A-D Lib: KWallet Set up for Aggregation"); - kwEngine = new KWalletEngine(); - } - else if(storeID.Equals(ConstStrings.GK)) - { - Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); - gkEngine = new GKEngine(); - } - // Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId); - } - } - */ - + //ffEngine = new FFEngine(); + //Note: + //The new instantiation of a wallet should not be done here since + //if the policy has a specific wallet disabled, the constructor for the wallet + //also should not be instantiated. + //This is already being done within the Aggreagate\AggregateStore api. + //Also all operations should check for an instance of a wallet and instanciate only + //if not already instantiated as has been done for firefox. +#endif } - public XmlDocument Aggregate() + /******************************************************************************* + Aggregates All Stores. + + public int Aggregate() + + + Parameters : None + + StoreID : XmlNode + All aggregated store's XML document. + + + Returns : None + + *********************************************************************************/ + public XmlDocument Aggregate() { #if LINUX gkEngine = null; kwEngine = null; - ffEngine = null; + //ffEngine = null; + //Note: + //Use the same instance of the wallet rather than re-initializing again #endif //Read the Policy Just before you aggregate @@ -116,8 +114,8 @@ namespace Novell.CASA.DataEngines Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); gkEngine = new GKEngine(); } - else if(storeID.Equals(ConstStrings.FF)) - { + else if(storeID.Equals(ConstStrings.FF) && (ffEngine==null) ) + {//Use the existing instance of firefox Logger.DbgLog("A-D Lib:FireFox Set up for Aggregation"); ffEngine = new FFEngine(); } @@ -193,6 +191,9 @@ namespace Novell.CASA.DataEngines } } + else + Logger.DbgLog("A-D Lib:Could not aggregate Gnome FireFox since FireFoxEngine not instantiated"); + #endif @@ -358,7 +359,29 @@ namespace Novell.CASA.DataEngines return -1; } - public int AggregateStore(XmlDocument outDoc, int StoreID) + /******************************************************************************* + Aggregates a Store specified by the storeID. + + public int AggregateStore(XmlNode secret, int StoreID) + + + Parameters + + secret : outDoc + 1. The aggregated store's XML document. + + + StoreID : int value + Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3; + Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4 + Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_FF + + + Returns + An Error code or 0 if operation is successfull. + + *********************************************************************************/ + public int AggregateStore(XmlDocument outDoc, int StoreID) { // This need not be policy aware. GUI knows what its doing. @@ -438,7 +461,12 @@ namespace Novell.CASA.DataEngines } else if(StoreID == ConstStrings.CASA_STORE_FFOX) { - ffEngine = new FFEngine(); + //Use the existing instance of firefox + if(ffEngine == null) + ffEngine = new FFEngine(); + + if(ffEngine != null) + { secEnum = ffEngine.Aggregate(); if (secEnum != null ) { @@ -457,6 +485,10 @@ namespace Novell.CASA.DataEngines //Console.WriteLine("FireFox some issue"); return ConstStrings.CASA_STORE_NOT_AVAILABLE; } + } + else + Logger.DbgLog("A-D Lib:Aggregatestore:Could not aggregate Gnome FireFox since FireFoxEngine not instantiated"); + } @@ -510,6 +542,71 @@ namespace Novell.CASA.DataEngines return true; } + /*********************************************************************************************** + //isMasterPasswordSet : Checks If a MasterPassword is set for the store + //Parameters: + // int StoreID + // + //Return + // + // @return true master password is set + // false master password not set + //Notes: + // This API is to be invoked on an AD instance and currently is supported only for the FireFox wallet + // For FireFox, The check is profile specific with only the default profile supported currently + // For FireFox, The check assumes that the profile needs to be initialized first. Hence the call to instanciate FFEngine + ***********************************************************************************************/ + public Boolean IsMasterPasswordSet(int StoreID) + { + if (StoreID == ConstStrings.CASA_STORE_FFOX) + { + int methodStatusCode=0; + //Use the existing instance of firefox else instantiate + if(ffEngine == null) + ffEngine = new FFEngine(); + methodStatusCode=ffEngine.isMasterPasswordSet(); + if(methodStatusCode==1) + return true; + else + return false; + + } + + return true; + } + + /*********************************************************************************************** + //VerifyMasterPassword : Verifies\Checks the validity of the MasterPassword for the store + //Parameters: None + // + //Return + // + // @return true the specified master password is correct + // false the specified master password is wrong + //Notes: + // This API is to be invoked on an AD instance and currently is supported only for the FireFox wallet + // For FireFox, The set is profile specific with only the default profile supported currently + // For FireFox, The set assumes that the profile needs to be initialized first. Hence the call to instanciate FFEngine + ***********************************************************************************************/ + public Boolean VerifyMasterPassword(string masterPassword,int StoreID) + { + if (StoreID == ConstStrings.CASA_STORE_FFOX) + { + int methodStatusCode=0; + //Use the existing instance of firefox else instantiate + if(ffEngine == null) + ffEngine = new FFEngine(); + methodStatusCode=ffEngine.verifyMasterPassword(masterPassword); + if(methodStatusCode==1) + return true; + else + return false; + + } + + return true; + } + } }