Bug 133386 fixes
This commit is contained in:
		| @@ -20,415 +20,446 @@ | |||||||
|  *  |  *  | ||||||
|  ***********************************************************************/ |  ***********************************************************************/ | ||||||
|  |  | ||||||
| using System; | using System; | ||||||
| using System.Collections; | using System.Collections; | ||||||
| using System.Xml; | using System.Xml; | ||||||
| using System.IO; | using System.IO; | ||||||
| using System.Collections.Specialized; | using System.Collections.Specialized; | ||||||
| using Novell.CASA.DataEngines.Common; | using Novell.CASA.DataEngines.Common; | ||||||
| using Novell.CASA.CASAPolicy; | using Novell.CASA.CASAPolicy; | ||||||
| #if LINUX | #if LINUX | ||||||
| using Novell.CASA.GUI; | using Novell.CASA.GUI; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace Novell.CASA.DataEngines  | namespace Novell.CASA.DataEngines  | ||||||
| { | { | ||||||
|  |  | ||||||
|     public class AD  |     public class AD  | ||||||
|     { |     { | ||||||
|  |  | ||||||
|        private miCASAEngine micasaengine; |        private miCASAEngine micasaengine; | ||||||
| #if LINUX | #if LINUX | ||||||
|        private GKEngine gkEngine = null; |        private GKEngine gkEngine = null; | ||||||
|        private KWalletEngine  kwEngine = null;  |        private KWalletEngine  kwEngine = null;  | ||||||
| #endif | #endif | ||||||
|        private AggregationPol aggPol; |        private AggregationPol aggPol; | ||||||
|     |     | ||||||
|  |  | ||||||
|        public AD() |        public AD() | ||||||
|        { |        { | ||||||
|          // Always Aggregate miCASA.  |          // Always Aggregate miCASA.  | ||||||
|           micasaengine =  new miCASAEngine(); |           micasaengine =  new miCASAEngine(); | ||||||
| #if LINUX | #if LINUX | ||||||
|           kwEngine = new KWalletEngine(); |           kwEngine = new KWalletEngine(); | ||||||
|           gkEngine = new GKEngine(); |           gkEngine = new GKEngine(); | ||||||
| #endif | #endif | ||||||
| /* | /* | ||||||
|     |     | ||||||
|          // Reading Policy to see what else needs to be Aggregated. |          // Reading Policy to see what else needs to be Aggregated. | ||||||
|          aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL); |          aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL); | ||||||
|          if (aggPol != null )  |          if (aggPol != null )  | ||||||
|          {  |          {  | ||||||
|         	ArrayList stores = aggPol.StoreList; |         	ArrayList stores = aggPol.StoreList; | ||||||
|         	IEnumerator enumerator = stores.GetEnumerator(); |         	IEnumerator enumerator = stores.GetEnumerator(); | ||||||
|    |    | ||||||
|         	while(enumerator.MoveNext()) |         	while(enumerator.MoveNext()) | ||||||
|          	{ |          	{ | ||||||
|                 	string storeID = (((Store)(enumerator.Current)).StoreName); |                 	string storeID = (((Store)(enumerator.Current)).StoreName); | ||||||
|  |  | ||||||
|                 	if(storeID.Equals(ConstStrings.KW)) |                 	if(storeID.Equals(ConstStrings.KW)) | ||||||
|                 	{  |                 	{  | ||||||
|                         	Logger.DbgLog("A-D Lib: KWallet Set up for Aggregation"); |                         	Logger.DbgLog("A-D Lib: KWallet Set up for Aggregation"); | ||||||
|                      		kwEngine = new KWalletEngine();  |                      		kwEngine = new KWalletEngine();  | ||||||
|                 	}  |                 	}  | ||||||
|                		else if(storeID.Equals(ConstStrings.GK)) |                		else if(storeID.Equals(ConstStrings.GK)) | ||||||
|                 	{ |                 	{ | ||||||
|                      		Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); |                      		Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); | ||||||
|                     		 gkEngine = new GKEngine();  |                     		 gkEngine = new GKEngine();  | ||||||
|                 	}  |                 	}  | ||||||
|          	// Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId); |          	// Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId); | ||||||
|          	} |          	} | ||||||
|         }   |         }   | ||||||
|  */ |  */ | ||||||
|   |   | ||||||
|       } |       } | ||||||
|       |       | ||||||
|        public XmlDocument Aggregate() |        public XmlDocument Aggregate() | ||||||
|        { |        { | ||||||
| #if LINUX | #if LINUX | ||||||
|             gkEngine = null; |             gkEngine = null; | ||||||
|             kwEngine = null; |             kwEngine = null; | ||||||
| #endif | #endif | ||||||
|            //Read the Policy Just before you aggregate |            //Read the Policy Just before you aggregate | ||||||
|             |             | ||||||
|            // Reading Policy to see what else needs to be Aggregated. |            // Reading Policy to see what else needs to be Aggregated. | ||||||
|            aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL); |            aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL); | ||||||
|            if (aggPol != null ) |            if (aggPol != null ) | ||||||
|            { |            { | ||||||
|                 ArrayList stores = aggPol.StoreList; |                 ArrayList stores = aggPol.StoreList; | ||||||
|                 IEnumerator enumerator = stores.GetEnumerator(); |                 IEnumerator enumerator = stores.GetEnumerator(); | ||||||
|  |  | ||||||
|                 while(enumerator.MoveNext()) |                 while(enumerator.MoveNext()) | ||||||
|                 { |                 { | ||||||
|                         string storeID = (((Store)(enumerator.Current)).StoreName); |                         string storeID = (((Store)(enumerator.Current)).StoreName); | ||||||
|  |  | ||||||
| #if LINUX | #if LINUX | ||||||
|                         if(storeID.Equals(ConstStrings.KW)) |                         if(storeID.Equals(ConstStrings.KW)) | ||||||
|                         { |                         { | ||||||
|                                 Logger.DbgLog("A-D Lib: KWallet Set up for Aggregation"); |                                 Logger.DbgLog("A-D Lib: KWallet Set up for Aggregation"); | ||||||
|                                 kwEngine = new KWalletEngine(); |                                 kwEngine = new KWalletEngine(); | ||||||
|                         } |                         } | ||||||
|                         else if(storeID.Equals(ConstStrings.GK)) |                         else if(storeID.Equals(ConstStrings.GK)) | ||||||
|                         { |                         { | ||||||
|                                 Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); |                                 Logger.DbgLog("A-D Lib:Gnome Keyring Set up for Aggregation"); | ||||||
|                                  gkEngine = new GKEngine(); |                                  gkEngine = new GKEngine(); | ||||||
|                         } |                         } | ||||||
| #endif | #endif | ||||||
|                 // Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId); |                 // Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId); | ||||||
|                 } |                 } | ||||||
|           } |           } | ||||||
|    |    | ||||||
|          |          | ||||||
|  |  | ||||||
|            XmlDocument ccf = new XmlDocument();     |            XmlDocument ccf = new XmlDocument();     | ||||||
|            XmlElement elem = ccf.CreateElement("CCF"); |            XmlElement elem = ccf.CreateElement("CCF"); | ||||||
|            ccf.AppendChild(elem); |            ccf.AppendChild(elem); | ||||||
|  |  | ||||||
|            // TBD: Lookup Policy here and maybe send it via constructors |            // TBD: Lookup Policy here and maybe send it via constructors | ||||||
|            XmlNode micasaEnum  =  micasaengine.Aggregate();   |            XmlNode micasaEnum  =  micasaengine.Aggregate();   | ||||||
|            if (micasaEnum != null) //Atleast <miCASA> should come incase of no secrets |            if (micasaEnum != null) //Atleast <miCASA> should come incase of no secrets | ||||||
|            { |            { | ||||||
|            	XmlNode gotit = ccf.ImportNode(micasaEnum,true); |            	XmlNode gotit = ccf.ImportNode(micasaEnum,true); | ||||||
|            	ccf.DocumentElement.AppendChild(gotit); |            	ccf.DocumentElement.AppendChild(gotit); | ||||||
|            } |            } | ||||||
|            else |            else | ||||||
|            { |            { | ||||||
|                 // Null comes only when it failed to talk to miCASA.    |                 // Null comes only when it failed to talk to miCASA.    | ||||||
| #if LINUX | #if LINUX | ||||||
| 				Logger.DbgLog("A-D Lib:Failed to Connect to miCASA"); | 				Logger.DbgLog("A-D Lib:Failed to Connect to miCASA"); | ||||||
| #endif | #endif | ||||||
|            } |            } | ||||||
|  |  | ||||||
| #if LINUX | #if LINUX | ||||||
|            if (gkEngine != null) |            if (gkEngine != null) | ||||||
|            { |            { | ||||||
|           	 XmlNode gkSecrets = gkEngine.Aggregate(); |           	 XmlNode gkSecrets = gkEngine.Aggregate(); | ||||||
| 	         if( null != gkSecrets ) | 	         if( null != gkSecrets ) | ||||||
| 	         { | 	         { | ||||||
|         	     XmlNode gkImportedNode = ccf.ImportNode(gkSecrets,true); |         	     XmlNode gkImportedNode = ccf.ImportNode(gkSecrets,true); | ||||||
| 	             ccf.DocumentElement.AppendChild(gkImportedNode); | 	             ccf.DocumentElement.AppendChild(gkImportedNode); | ||||||
| 	         } | 	         } | ||||||
| 	         else | 	         else | ||||||
|         	 { |         	 { | ||||||
| 		      Logger.DbgLog("A-D Lib:Failed to Connect to Gnome Keyring"); | 		      Logger.DbgLog("A-D Lib:Failed to Connect to Gnome Keyring"); | ||||||
|  |  | ||||||
| 	         } | 	         } | ||||||
|            } |            } | ||||||
|  |  | ||||||
|  |  | ||||||
|            if(kwEngine != null ) |            if(kwEngine != null ) | ||||||
|            { |            { | ||||||
|            	XmlNode KwEnum  =  kwEngine.Aggregate(); |            	XmlNode KwEnum  =  kwEngine.Aggregate(); | ||||||
| 	        if (KwEnum != null) //Atleast <KWallet> should come incase of no secrets | 	        if (KwEnum != null) //Atleast <KWallet> should come incase of no secrets | ||||||
| 	        { | 	        { | ||||||
| 	             XmlNode kwImported = ccf.ImportNode(KwEnum,true); | 	             XmlNode kwImported = ccf.ImportNode(KwEnum,true); | ||||||
| 	             ccf.DocumentElement.AppendChild(kwImported); | 	             ccf.DocumentElement.AppendChild(kwImported); | ||||||
|         	} |         	} | ||||||
| 	        else | 	        else | ||||||
|         	{ |         	{ | ||||||
| 	             // Null comes only when it failed to talk to Kwallet. | 	             // Null comes only when it failed to talk to Kwallet. | ||||||
| 		      Logger.DbgLog("A-D Lib:Failed to Connect to KWallet"); | 		      Logger.DbgLog("A-D Lib:Failed to Connect to KWallet"); | ||||||
| 	        } | 	        } | ||||||
|            } |            } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|            return ccf; |            return ccf; | ||||||
|                      |                      | ||||||
|        } |        } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|        /******************************************************************************** |        /******************************************************************************** | ||||||
|         Modifying a Secret |         Modifying a Secret | ||||||
|  |  | ||||||
| 	SetSecret will modify the Value(s) of a Key(s) for an  existing secret | 	SetSecret will modify the Value(s) of a Key(s) for an  existing secret | ||||||
| 	SetSecret will also add new secrets | 	SetSecret will also add new secrets | ||||||
|  |  | ||||||
| 	public int SetSecret(XmlNode secret, int StoreID) | 	public int SetSecret(XmlNode secret, int StoreID) | ||||||
|  |  | ||||||
| 	Parameters | 	Parameters | ||||||
|  |  | ||||||
| 	secret : Secrets XMLNode | 	secret : Secrets XMLNode | ||||||
|          1. If a  Key node of a secret is missing then that key will be deleted |          1. If a  Key node of a secret is missing then that key will be deleted | ||||||
|          2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as |          2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as | ||||||
|             Gnome Api's do not allow it. |             Gnome Api's do not allow it. | ||||||
|          3. All Time nodes for a Secret need not be passed as they cannot be set. |          3. All Time nodes for a Secret need not be passed as they cannot be set. | ||||||
|          4. Keyring attributes have a fixed datatype of Int and String.  |          4. Keyring attributes have a fixed datatype of Int and String.  | ||||||
|             Currently we support only String types. To support int types CCF needs to be modified accordingly. |             Currently we support only String types. To support int types CCF needs to be modified accordingly. | ||||||
|          5. SetSecret overloaded method, without the opnType parameter, is not supported for GnomeKeyring |          5. SetSecret overloaded method, without the opnType parameter, is not supported for GnomeKeyring | ||||||
|  |  | ||||||
| 	opnType : Operation Type | 	opnType : Operation Type | ||||||
|           ConstStrings.OPERATION_ADD_SECRET |           ConstStrings.OPERATION_ADD_SECRET | ||||||
|           ConstStrings.OPERATION_MODIFY_SECRET |           ConstStrings.OPERATION_MODIFY_SECRET | ||||||
|  |  | ||||||
| 	StoreID : int value | 	StoreID : int value | ||||||
|           Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET  = 3; |           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_GK  = 4 | ||||||
|  |  | ||||||
| 	Returns | 	Returns | ||||||
| 	  An Error code or 0 if operation is successfull. | 	  An Error code or 0 if operation is successfull. | ||||||
|         *********************************************************************************/ |         *********************************************************************************/ | ||||||
|  |  | ||||||
|        public int SetSecret(XmlNode secret, int opnType, int StoreID) |        public int SetSecret(XmlNode secret, int opnType, int StoreID) | ||||||
|        { |        { | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_MICASA) |             if (StoreID == ConstStrings.CASA_STORE_MICASA) | ||||||
|                    return micasaengine.SetSecret(secret, opnType); |                    return micasaengine.SetSecret(secret, opnType); | ||||||
| #if LINUX | #if LINUX | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_KWALLET) |             if (StoreID == ConstStrings.CASA_STORE_KWALLET) | ||||||
|                    return kwEngine.SetSecret(secret, opnType); |                    return kwEngine.SetSecret(secret, opnType); | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_GK) |             if (StoreID == ConstStrings.CASA_STORE_GK) | ||||||
|                    return gkEngine.SetSecret(secret, opnType); |                    return gkEngine.SetSecret(secret, opnType); | ||||||
| #endif | #endif | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
| #if LINUX | #if LINUX | ||||||
|                 Logger.DbgLog("A-D Lib:Failed to Set Secret in to  miCASA"); |                 Logger.DbgLog("A-D Lib:Failed to Set Secret in to  miCASA"); | ||||||
| #endif | #endif | ||||||
|                 return -1; |                 return -1; | ||||||
|  |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|        } |        } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|        /******************************************************************************** |        /******************************************************************************** | ||||||
|         Modifying a Secret |         Modifying a Secret | ||||||
|  |  | ||||||
|         SetSecret will modify the Value(s) of a Key(s) for an  existing secret |         SetSecret will modify the Value(s) of a Key(s) for an  existing secret | ||||||
|         SetSecret will also add new secrets |         SetSecret will also add new secrets | ||||||
|  |  | ||||||
|         public int SetSecret(XmlNode secret, int StoreID) |         public int SetSecret(XmlNode secret, int StoreID) | ||||||
|  |  | ||||||
|         Parameters |         Parameters | ||||||
|  |  | ||||||
|         secret : Secrets XMLNode |         secret : Secrets XMLNode | ||||||
|          1. If a  Key node of a secret is missing then that key will be deleted |          1. If a  Key node of a secret is missing then that key will be deleted | ||||||
|          2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as |          2. For Gnome keyring, Key having Id "GkPassword" cannot be deleted as | ||||||
|             Gnome Api's do not allow it. |             Gnome Api's do not allow it. | ||||||
|          3. All Time nodes for a Secret need not be passed as they cannot be set. |          3. All Time nodes for a Secret need not be passed as they cannot be set. | ||||||
|          4. Keyring attributes have a fixed datatype of Int and String. |          4. Keyring attributes have a fixed datatype of Int and String. | ||||||
|             Currently we support only String types. To support int types CCF needs to be modified accordingly. |             Currently we support only String types. To support int types CCF needs to be modified accordingly. | ||||||
|  |  | ||||||
|         StoreID : int value |         StoreID : int value | ||||||
|           Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET  = 3; |           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_GK  = 4 | ||||||
|  |  | ||||||
|         Returns |         Returns | ||||||
|           An Error code or 0 if operation is successfull. |           An Error code or 0 if operation is successfull. | ||||||
|         *********************************************************************************/ |         *********************************************************************************/ | ||||||
|  |  | ||||||
|        public int SetSecret(XmlNode secret, int StoreID) |        public int SetSecret(XmlNode secret, int StoreID) | ||||||
|        { |        { | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_MICASA) |             if (StoreID == ConstStrings.CASA_STORE_MICASA) | ||||||
|                    return micasaengine.SetSecret(secret); |                    return micasaengine.SetSecret(secret); | ||||||
| #if LINUX | #if LINUX | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_KWALLET) |             if (StoreID == ConstStrings.CASA_STORE_KWALLET) | ||||||
|                    return kwEngine.SetSecret(secret); |                    return kwEngine.SetSecret(secret); | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_GK) |             if (StoreID == ConstStrings.CASA_STORE_GK) | ||||||
|                    return gkEngine.SetSecret(secret); |                    return gkEngine.SetSecret(secret); | ||||||
| #endif | #endif | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
| #if LINUX | #if LINUX | ||||||
|                 Logger.DbgLog("A-D Lib:Failed to Set Secret in to  miCASA"); |                 Logger.DbgLog("A-D Lib:Failed to Set Secret in to  miCASA"); | ||||||
| #endif | #endif | ||||||
|                 return -1; |                 return -1; | ||||||
|  |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|        } |        } | ||||||
|  |  | ||||||
|  |  | ||||||
|        public  int GetSecret(XmlNode secret, int StoreID) |        public  int GetSecret(XmlNode secret, int StoreID) | ||||||
|        { |        { | ||||||
|             |             | ||||||
|            //TBD: Check for Store ID and call the right DataEngine. |            //TBD: Check for Store ID and call the right DataEngine. | ||||||
|            if (StoreID == ConstStrings.CASA_STORE_MICASA) |            if (StoreID == ConstStrings.CASA_STORE_MICASA) | ||||||
| 	           return micasaengine.GetSecret(secret); | 	           return micasaengine.GetSecret(secret); | ||||||
|            else |            else | ||||||
|            {  |            {  | ||||||
| #if LINUX | #if LINUX | ||||||
|               Logger.DbgLog("A-D Lib: Failed to Get Secret in to  miCASA"); |               Logger.DbgLog("A-D Lib: Failed to Get Secret in to  miCASA"); | ||||||
| #endif | #endif | ||||||
|                return -1; |                return -1; | ||||||
|            } |            } | ||||||
|        } |        } | ||||||
|  |  | ||||||
|  |  | ||||||
| 	/******************************************************************************* | 	/******************************************************************************* | ||||||
| 	Remove will delete a Secret. | 	Remove will delete a Secret. | ||||||
|  |  | ||||||
| 	public int Remove(XmlNode secret, int StoreID) | 	public int Remove(XmlNode secret, int StoreID) | ||||||
|  |  | ||||||
|  |  | ||||||
| 	Parameters | 	Parameters | ||||||
|  |  | ||||||
| 	secret : Secrets XmlNode | 	secret : Secrets XmlNode | ||||||
|         	 1. This node will be deleted from its parent. |         	 1. This node will be deleted from its parent. | ||||||
|  |  | ||||||
|  |  | ||||||
| 	StoreID : int value | 	StoreID : int value | ||||||
|         	  Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET  = 3; |         	  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_GK  = 4 | ||||||
|  |  | ||||||
|  |  | ||||||
| 	Returns | 	Returns | ||||||
| 		An Error code or 0 if operation is successfull.  | 		An Error code or 0 if operation is successfull.  | ||||||
|  |  | ||||||
| 	*********************************************************************************/ | 	*********************************************************************************/ | ||||||
|        |        | ||||||
|        public int Remove(XmlNode secret, int StoreID) |        public int Remove(XmlNode secret, int StoreID) | ||||||
|        { |        { | ||||||
|             |             | ||||||
| 	    if (StoreID == ConstStrings.CASA_STORE_MICASA) | 	    if (StoreID == ConstStrings.CASA_STORE_MICASA) | ||||||
|                    return micasaengine.Remove(secret); |                    return micasaengine.Remove(secret); | ||||||
| #if LINUX | #if LINUX | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_KWALLET) |             if (StoreID == ConstStrings.CASA_STORE_KWALLET) | ||||||
|                    return kwEngine.Remove(secret); |                    return kwEngine.Remove(secret); | ||||||
|             if (StoreID == ConstStrings.CASA_STORE_GK) |             if (StoreID == ConstStrings.CASA_STORE_GK) | ||||||
|                    return gkEngine.Remove(secret); |                    return gkEngine.Remove(secret); | ||||||
| #endif | #endif | ||||||
|             return -1; |             return -1; | ||||||
|        }   |        }   | ||||||
|           |           | ||||||
|        public int AggregateStore(XmlDocument outDoc, int StoreID) |        public int AggregateStore(XmlDocument outDoc, int StoreID) | ||||||
|        { |        { | ||||||
|            // This need not be policy aware. GUI knows what its doing. |            // This need not be policy aware. GUI knows what its doing. | ||||||
|  |  | ||||||
|            XmlNode secEnum; |            XmlNode secEnum; | ||||||
|            DataEngine engine;          |            DataEngine engine;          | ||||||
|  |  | ||||||
|            XmlNode toproot =  outDoc.DocumentElement; |            XmlNode toproot =  outDoc.DocumentElement; | ||||||
|            if (toproot == null) |            if (toproot == null) | ||||||
|            { |            { | ||||||
|                 XmlElement elem = outDoc.CreateElement("CCF"); |                 XmlElement elem = outDoc.CreateElement("CCF"); | ||||||
|                 outDoc.AppendChild(elem); |                 outDoc.AppendChild(elem); | ||||||
|            } |            } | ||||||
|  |  | ||||||
|            if ( StoreID  == ConstStrings.CASA_STORE_MICASA )    // If its miCASA |            if ( StoreID  == ConstStrings.CASA_STORE_MICASA )    // If its miCASA | ||||||
|            {  |            {  | ||||||
|                engine =  micasaengine; |                engine =  micasaengine; | ||||||
|                secEnum = engine.Aggregate(); |                secEnum = engine.Aggregate(); | ||||||
|                if (secEnum != null ) |                if (secEnum != null ) | ||||||
|                { |                { | ||||||
|                    XmlNode root = outDoc.DocumentElement; |                    XmlNode root = outDoc.DocumentElement; | ||||||
|                    XmlNodeList miCASANodes = root.SelectNodes("descendant::miCASA"); |                    XmlNodeList miCASANodes = root.SelectNodes("descendant::miCASA"); | ||||||
|                   // Console.WriteLine("ADLIB: Count is " + miCASANodes.Count); |                   // Console.WriteLine("ADLIB: Count is " + miCASANodes.Count); | ||||||
|                    if (miCASANodes.Count !=  0) // If there is something remove it |                    if (miCASANodes.Count !=  0) // If there is something remove it | ||||||
|                    { |                    { | ||||||
|                         root.RemoveChild(miCASANodes[0]); |                         root.RemoveChild(miCASANodes[0]); | ||||||
|                    } |                    } | ||||||
|                    XmlNode gotit = outDoc.ImportNode(secEnum,true); |                    XmlNode gotit = outDoc.ImportNode(secEnum,true); | ||||||
|                    root.AppendChild(gotit); |                    root.AppendChild(gotit); | ||||||
|                    return  ConstStrings.CASA_SUCCESS; |                    return  ConstStrings.CASA_SUCCESS; | ||||||
|                } |                } | ||||||
|                else |                else | ||||||
|                    return  ConstStrings.CASA_STORE_NOT_AVAILABLE; |                    return  ConstStrings.CASA_STORE_NOT_AVAILABLE; | ||||||
|            }  |            }  | ||||||
| #if LINUX | #if LINUX | ||||||
|            else if( StoreID == ConstStrings.CASA_STORE_GK ) |            else if( StoreID == ConstStrings.CASA_STORE_GK ) | ||||||
|            { |            { | ||||||
|                   gkEngine = new GKEngine(); |                   gkEngine = new GKEngine(); | ||||||
|                	  secEnum = gkEngine.Aggregate(); |                	  secEnum = gkEngine.Aggregate(); | ||||||
|               	  if (secEnum != null ) |               	  if (secEnum != null ) | ||||||
|                	  { |                	  { | ||||||
|                      	  XmlNode root = outDoc.DocumentElement; |                      	  XmlNode root = outDoc.DocumentElement; | ||||||
| 	                  XmlNodeList gkNode = root.SelectNodes("descendant::GK"); | 	                  XmlNodeList gkNode = root.SelectNodes("descendant::GK"); | ||||||
|         	          if (gkNode.Count !=  0) // If there is something remove it |         	          if (gkNode.Count !=  0) // If there is something remove it | ||||||
|                 	  { |                 	  { | ||||||
| 	                  	root.RemoveChild(gkNode[0]);  | 	                  	root.RemoveChild(gkNode[0]);  | ||||||
|         	          } |         	          } | ||||||
| 	                  XmlNode gkImportNode = outDoc.ImportNode(secEnum,true); | 	                  XmlNode gkImportNode = outDoc.ImportNode(secEnum,true); | ||||||
|         	          root.AppendChild(gkImportNode); |         	          root.AppendChild(gkImportNode); | ||||||
|                 	  return  ConstStrings.CASA_SUCCESS; |                 	  return  ConstStrings.CASA_SUCCESS; | ||||||
|                  } |                  } | ||||||
|                  else |                  else | ||||||
|                    return  ConstStrings.CASA_STORE_NOT_AVAILABLE; |                    return  ConstStrings.CASA_STORE_NOT_AVAILABLE; | ||||||
|                |                | ||||||
|            } |            } | ||||||
|            else if(StoreID == ConstStrings.CASA_STORE_KWALLET) |            else if(StoreID == ConstStrings.CASA_STORE_KWALLET) | ||||||
|            { |            { | ||||||
|                       kwEngine = new KWalletEngine(); |                       kwEngine = new KWalletEngine(); | ||||||
| 	       	       secEnum = kwEngine.Aggregate(); | 	       	       secEnum = kwEngine.Aggregate(); | ||||||
| 	               if (secEnum != null ) | 	               if (secEnum != null ) | ||||||
|         	       { |         	       { | ||||||
|                    		XmlNode root = outDoc.DocumentElement; |                    		XmlNode root = outDoc.DocumentElement; | ||||||
| 	                	XmlNodeList gkNode = root.SelectNodes("descendant::KWallet"); | 	                	XmlNodeList gkNode = root.SelectNodes("descendant::KWallet"); | ||||||
|                                 if (gkNode.Count !=  0) // If there is something remove it |                                 if (gkNode.Count !=  0) // If there is something remove it | ||||||
|   	                        { |   	                        { | ||||||
|         		        	root.RemoveChild(gkNode[0]); |         		        	root.RemoveChild(gkNode[0]); | ||||||
|                                 }  |                                 }  | ||||||
|  		                XmlNode kwImportNode = outDoc.ImportNode(secEnum,true); |  		                XmlNode kwImportNode = outDoc.ImportNode(secEnum,true); | ||||||
|  		                root.AppendChild(kwImportNode); |  		                root.AppendChild(kwImportNode); | ||||||
|  		                return  ConstStrings.CASA_SUCCESS; |  		                return  ConstStrings.CASA_SUCCESS; | ||||||
|                	       } |                	       } | ||||||
|                        else |                        else | ||||||
|                        { |                        { | ||||||
|                           //Console.WriteLine("KWallet some issue"); |                           //Console.WriteLine("KWallet some issue"); | ||||||
|  	                  return  ConstStrings.CASA_STORE_NOT_AVAILABLE; |  	                  return  ConstStrings.CASA_STORE_NOT_AVAILABLE; | ||||||
|                        } |                        } | ||||||
|  |  | ||||||
|            }  |            }  | ||||||
|  |  | ||||||
|            Logger.DbgLog("A-D Lib: Unknown Operation Requested"); |            Logger.DbgLog("A-D Lib: Unknown Operation Requested"); | ||||||
| #endif            | #endif            | ||||||
|            return ConstStrings.CASA_OPERATION_FAILED; |            return ConstStrings.CASA_OPERATION_FAILED; | ||||||
|        } |        } | ||||||
|  |  | ||||||
|        public int InitAD() |        public int InitAD() | ||||||
|        { |        { | ||||||
|  |  | ||||||
|            return ConstStrings.CASA_SUCCESS; |            return ConstStrings.CASA_SUCCESS; | ||||||
|        } |        } | ||||||
|  |  | ||||||
|  |  | ||||||
|        public int CleanUP_AD() |        public int CleanUP_AD() | ||||||
|        { |        { | ||||||
|  |  | ||||||
|            return ConstStrings.CASA_SUCCESS; |            return ConstStrings.CASA_SUCCESS; | ||||||
|        }		 |        } | ||||||
|     } |          /*********************************************************************************************** | ||||||
| } |          IsStoreAvailable :  Checks If Store Is Available | ||||||
|  |                              It loads the required dlls for a particular store and returns true if | ||||||
|  |                              all required dll/.so are present. | ||||||
|  |  | ||||||
|  |          public static Boolean IsStoreAvailable(int StoreID); | ||||||
|  |  | ||||||
|  |          Parameters | ||||||
|  |  | ||||||
|  |          StoreID : int value | ||||||
|  |                    Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET  = 3; | ||||||
|  |                    Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK  = 4 | ||||||
|  |  | ||||||
|  |         Remarks | ||||||
|  |                  1. This API needs to be called before any other API of the particular store is called. | ||||||
|  |                  2. This API needs to be called before Aggregate() and AD_Facade constructor is called | ||||||
|  |                     as these initializes the Datangines based on the Aggregate Policy set. | ||||||
|  |                  3. The Aggregate Policy needs to be reset appropriately based on the return value of this call. | ||||||
|  |        ***********************************************************************************************/ | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |        public static Boolean IsStoreAvailable(int StoreID) | ||||||
|  |        { | ||||||
|  |             if (StoreID == ConstStrings.CASA_STORE_GK) | ||||||
|  |                    return GKEngine.IsStoreAvailable(); | ||||||
|  |             if (StoreID == ConstStrings.CASA_STORE_KWALLET) | ||||||
|  |                    return KWalletEngine.IsStoreAvailable(); | ||||||
|  |             return true; | ||||||
|  |        } | ||||||
|  | 		 | ||||||
|  |     } | ||||||
|  | } | ||||||
|   | |||||||
| @@ -52,11 +52,11 @@ namespace Novell.CASA.DataEngines | |||||||
|        public GKEngine() |        public GKEngine() | ||||||
|        { |        { | ||||||
|  |  | ||||||
|        } |        } | ||||||
|  |  | ||||||
|        ~GKEngine() |        ~GKEngine() | ||||||
|        { |        { | ||||||
|            GnomeKeyring.ReleaseGnomeKeyringLib(); |            //GnomeKeyring.ReleaseGnomeKeyringLib(); | ||||||
|        } |        } | ||||||
|  |  | ||||||
|        public XmlNode Aggregate() |        public XmlNode Aggregate() | ||||||
| @@ -297,11 +297,11 @@ namespace Novell.CASA.DataEngines | |||||||
|         { |         { | ||||||
|               try |               try | ||||||
|               { |               { | ||||||
| 		        System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(GnomeKeyring)); | 		        System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(GnomeKeyring)); | ||||||
|                 if (GnomeKeyring.IsGnomeKeyringInstalled()) |                 //if (GnomeKeyring.IsGnomeKeyringInstalled()) | ||||||
|                     return true; |                     return true; | ||||||
|                 else |                 //else | ||||||
|                     return false; |                 //    return false; | ||||||
|               } |               } | ||||||
|               catch(DllNotFoundException d) |               catch(DllNotFoundException d) | ||||||
|               { |               { | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -110,23 +110,23 @@ namespace Novell.CASA.DataEngines.GK | |||||||
| 	    [DllImport("libad_gk.so")] | 	    [DllImport("libad_gk.so")] | ||||||
| 	    public static extern int CreateItem(string keyringName, int itemType, string displayName, string password, IntPtr[] arrptr, int attrCount); | 	    public static extern int CreateItem(string keyringName, int itemType, string displayName, string password, IntPtr[] arrptr, int attrCount); | ||||||
| 	    [DllImport("libad_gk.so")] | 	    [DllImport("libad_gk.so")] | ||||||
| 	    public static extern int UnlockRing(string sKeyringName, string sPassword); | 	    public static extern int UnlockRing(string sKeyringName, string sPassword); | ||||||
|         [DllImport("libad_gk.so")] |         [DllImport("libad_gk.so")] | ||||||
|         public static extern int LoadGnomeKeyringLibrary(); |         public static extern int LoadGnomeKeyringLibrary(); | ||||||
|         [DllImport("libad_gk.so")] |         [DllImport("libad_gk.so")] | ||||||
|         public static extern int ReleaseGnomeKeyringLibrary(); |         public static extern int ReleaseGnomeKeyringLibrary(); | ||||||
|  |  | ||||||
|         public static bool IsGnomeKeyringInstalled() |         public static bool IsGnomeKeyringInstalled() | ||||||
|         { |         { | ||||||
|             if (0 == LoadGnomeKeyringLibrary()) |             if (0 == LoadGnomeKeyringLibrary()) | ||||||
|                 return true; |                 return true; | ||||||
|             else |             else | ||||||
|                 return false; |                 return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public static void ReleaseGnomeKeyringLib() |         public static void ReleaseGnomeKeyringLib() | ||||||
|         { |         { | ||||||
|             ReleaseGnomeKeyringLibrary(); |             ReleaseGnomeKeyringLibrary(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| 	public static void AttemptGKUnlock(string sPassword) | 	public static void AttemptGKUnlock(string sPassword) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user