major source structure and module name changes
This commit is contained in:
616
adlib/AD_Facade.cs
Normal file
616
adlib/AD_Facade.cs
Normal file
@@ -0,0 +1,616 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Collections.Specialized;
|
||||
using Novell.CASA.DataEngines.Common;
|
||||
using Novell.CASA.CASAPolicy;
|
||||
#if LINUX
|
||||
using Novell.CASA.GUI;
|
||||
#endif
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
public class AD
|
||||
{
|
||||
|
||||
private miCASAEngine micasaengine;
|
||||
#if LINUX
|
||||
private GKEngine gkEngine = null;
|
||||
private KWalletEngine kwEngine = null;
|
||||
#endif
|
||||
private FFEngine ffEngine = null;
|
||||
private AggregationPol aggPol;
|
||||
|
||||
|
||||
public AD()
|
||||
{
|
||||
// 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();
|
||||
//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
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
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;
|
||||
//Note:
|
||||
//Use the same instance of the wallet rather than re-initializing again
|
||||
#endif
|
||||
//Read the Policy Just before you aggregate
|
||||
|
||||
// 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.FF) && (ffEngine==null) )
|
||||
{ //Use the existing instance of firefox
|
||||
//Logger.DbgLog("A-D Lib:FireFox Set up for Aggregation");
|
||||
ffEngine = new FFEngine();
|
||||
}
|
||||
#if LINUX
|
||||
else 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();
|
||||
}
|
||||
|
||||
#endif
|
||||
// Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + "StoreId = " + ((Store)(enumerator.Current)).StoreId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
XmlDocument ccf = new XmlDocument();
|
||||
XmlElement elem = ccf.CreateElement("CCF");
|
||||
ccf.AppendChild(elem);
|
||||
|
||||
// TBD: Lookup Policy here and maybe send it via constructors
|
||||
XmlNode micasaEnum = micasaengine.Aggregate();
|
||||
if (micasaEnum != null) //Atleast <miCASA> should come incase of no secrets
|
||||
{
|
||||
XmlNode gotit = ccf.ImportNode(micasaEnum,true);
|
||||
ccf.DocumentElement.AppendChild(gotit);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Null comes only when it failed to talk to miCASA.
|
||||
#if LINUX
|
||||
Logger.DbgLog("A-D Lib:Failed to Connect to miCASA");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LINUX
|
||||
if (gkEngine != null)
|
||||
{
|
||||
XmlNode gkSecrets = gkEngine.Aggregate();
|
||||
if( null != gkSecrets )
|
||||
{
|
||||
XmlNode gkImportedNode = ccf.ImportNode(gkSecrets,true);
|
||||
ccf.DocumentElement.AppendChild(gkImportedNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.DbgLog("A-D Lib:Failed to Connect to Gnome Keyring");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(kwEngine != null )
|
||||
{
|
||||
XmlNode KwEnum = kwEngine.Aggregate();
|
||||
if (KwEnum != null) //Atleast <KWallet> should come incase of no secrets
|
||||
{
|
||||
XmlNode kwImported = ccf.ImportNode(KwEnum,true);
|
||||
ccf.DocumentElement.AppendChild(kwImported);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Null comes only when it failed to talk to Kwallet.
|
||||
Logger.DbgLog("A-D Lib:Failed to Connect to KWallet");
|
||||
}
|
||||
}
|
||||
|
||||
if (ffEngine != null)
|
||||
{
|
||||
XmlNode ffSecrets = ffEngine.Aggregate();
|
||||
if( null != ffSecrets )
|
||||
{
|
||||
XmlNode ffImportedNode = ccf.ImportNode(ffSecrets,true);
|
||||
ccf.DocumentElement.AppendChild(ffImportedNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.DbgLog("A-D Lib:Failed to Connect to Gnome FireFox");
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
Logger.DbgLog("A-D Lib:Could not aggregate Gnome FireFox since FireFoxEngine not instantiated");
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return ccf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
Modifying a Secret
|
||||
|
||||
SetSecret will modify the Value(s) of a Key(s) for an existing secret
|
||||
SetSecret will also add new secrets
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XMLNode
|
||||
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
|
||||
Gnome Api's do not allow it.
|
||||
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.
|
||||
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
|
||||
|
||||
opnType : Operation Type
|
||||
ConstStrings.OPERATION_ADD_SECRET
|
||||
ConstStrings.OPERATION_MODIFY_SECRET
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
*********************************************************************************/
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType, int StoreID)
|
||||
{
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
return micasaengine.SetSecret(secret, opnType);
|
||||
#if LINUX
|
||||
if (StoreID == ConstStrings.CASA_STORE_KWALLET)
|
||||
return kwEngine.SetSecret(secret, opnType);
|
||||
if (StoreID == ConstStrings.CASA_STORE_GK)
|
||||
return gkEngine.SetSecret(secret, opnType);
|
||||
if (StoreID == ConstStrings.CASA_STORE_FFOX)
|
||||
return ffEngine.SetSecret(secret, opnType);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
#if LINUX
|
||||
Logger.DbgLog("A-D Lib:Failed to Set Secret in to miCASA");
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
Modifying a Secret
|
||||
|
||||
SetSecret will modify the Value(s) of a Key(s) for an existing secret
|
||||
SetSecret will also add new secrets
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XMLNode
|
||||
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
|
||||
Gnome Api's do not allow it.
|
||||
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.
|
||||
Currently we support only String types. To support int types CCF needs to be modified accordingly.
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
*********************************************************************************/
|
||||
|
||||
public int SetSecret(XmlNode secret, int StoreID)
|
||||
{
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
return micasaengine.SetSecret(secret);
|
||||
#if LINUX
|
||||
if (StoreID == ConstStrings.CASA_STORE_KWALLET)
|
||||
return kwEngine.SetSecret(secret);
|
||||
if (StoreID == ConstStrings.CASA_STORE_GK)
|
||||
return gkEngine.SetSecret(secret);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
#if LINUX
|
||||
Logger.DbgLog("A-D Lib:Failed to Set Secret in to miCASA");
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int GetSecret(XmlNode secret, int StoreID)
|
||||
{
|
||||
|
||||
//TBD: Check for Store ID and call the right DataEngine.
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
return micasaengine.GetSecret(secret);
|
||||
else
|
||||
{
|
||||
#if LINUX
|
||||
Logger.DbgLog("A-D Lib: Failed to Get Secret in to miCASA");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
Remove will delete a Secret.
|
||||
|
||||
public int Remove(XmlNode secret, int StoreID)
|
||||
|
||||
|
||||
Parameters
|
||||
|
||||
secret : Secrets XmlNode
|
||||
1. This node will be deleted from its parent.
|
||||
|
||||
|
||||
StoreID : int value
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_KWALLET = 3;
|
||||
Novell.CASA.DataEngines.Common.ConstStrings.CASA_STORE_GK = 4
|
||||
|
||||
|
||||
Returns
|
||||
An Error code or 0 if operation is successfull.
|
||||
|
||||
*********************************************************************************/
|
||||
|
||||
public int Remove(XmlNode secret, int StoreID)
|
||||
{
|
||||
|
||||
if (StoreID == ConstStrings.CASA_STORE_MICASA)
|
||||
return micasaengine.Remove(secret);
|
||||
#if LINUX
|
||||
if (StoreID == ConstStrings.CASA_STORE_KWALLET)
|
||||
return kwEngine.Remove(secret);
|
||||
if (StoreID == ConstStrings.CASA_STORE_GK)
|
||||
return gkEngine.Remove(secret);
|
||||
if (StoreID == ConstStrings.CASA_STORE_FFOX)
|
||||
return ffEngine.Remove(secret);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
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.
|
||||
|
||||
XmlNode secEnum;
|
||||
DataEngine engine;
|
||||
|
||||
XmlNode toproot = outDoc.DocumentElement;
|
||||
if (toproot == null)
|
||||
{
|
||||
XmlElement elem = outDoc.CreateElement("CCF");
|
||||
outDoc.AppendChild(elem);
|
||||
}
|
||||
|
||||
if ( StoreID == ConstStrings.CASA_STORE_MICASA ) // If its miCASA
|
||||
{
|
||||
engine = micasaengine;
|
||||
secEnum = engine.Aggregate();
|
||||
if (secEnum != null )
|
||||
{
|
||||
XmlNode root = outDoc.DocumentElement;
|
||||
XmlNodeList miCASANodes = root.SelectNodes("descendant::miCASA");
|
||||
// Console.WriteLine("ADLIB: Count is " + miCASANodes.Count);
|
||||
if (miCASANodes.Count != 0) // If there is something remove it
|
||||
{
|
||||
root.RemoveChild(miCASANodes[0]);
|
||||
}
|
||||
XmlNode gotit = outDoc.ImportNode(secEnum,true);
|
||||
root.AppendChild(gotit);
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
else
|
||||
return ConstStrings.CASA_STORE_NOT_AVAILABLE;
|
||||
}
|
||||
else if(StoreID == ConstStrings.CASA_STORE_FFOX)
|
||||
{
|
||||
//Use the existing instance of firefox
|
||||
if(ffEngine == null)
|
||||
ffEngine = new FFEngine();
|
||||
|
||||
if(ffEngine != null)
|
||||
{
|
||||
secEnum = ffEngine.Aggregate();
|
||||
if (secEnum != null )
|
||||
{
|
||||
XmlNode root = outDoc.DocumentElement;
|
||||
XmlNodeList ffNode = root.SelectNodes("descendant::FireFox");
|
||||
if (ffNode.Count != 0) // If there is something remove it
|
||||
{
|
||||
root.RemoveChild(ffNode[0]);
|
||||
}
|
||||
XmlNode ffImportNode = outDoc.ImportNode(secEnum,true);
|
||||
root.AppendChild(ffImportNode);
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//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");
|
||||
}
|
||||
}
|
||||
#if LINUX
|
||||
else if( StoreID == ConstStrings.CASA_STORE_GK )
|
||||
{
|
||||
gkEngine = new GKEngine();
|
||||
secEnum = gkEngine.Aggregate();
|
||||
if (secEnum != null )
|
||||
{
|
||||
XmlNode root = outDoc.DocumentElement;
|
||||
XmlNodeList gkNode = root.SelectNodes("descendant::GK");
|
||||
if (gkNode.Count != 0) // If there is something remove it
|
||||
{
|
||||
root.RemoveChild(gkNode[0]);
|
||||
}
|
||||
XmlNode gkImportNode = outDoc.ImportNode(secEnum,true);
|
||||
root.AppendChild(gkImportNode);
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
else
|
||||
return ConstStrings.CASA_STORE_NOT_AVAILABLE;
|
||||
|
||||
}
|
||||
else if(StoreID == ConstStrings.CASA_STORE_KWALLET)
|
||||
{
|
||||
kwEngine = new KWalletEngine();
|
||||
secEnum = kwEngine.Aggregate();
|
||||
if (secEnum != null )
|
||||
{
|
||||
XmlNode root = outDoc.DocumentElement;
|
||||
XmlNodeList gkNode = root.SelectNodes("descendant::KWallet");
|
||||
if (gkNode.Count != 0) // If there is something remove it
|
||||
{
|
||||
root.RemoveChild(gkNode[0]);
|
||||
}
|
||||
XmlNode kwImportNode = outDoc.ImportNode(secEnum,true);
|
||||
root.AppendChild(kwImportNode);
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("KWallet some issue");
|
||||
return ConstStrings.CASA_STORE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
}
|
||||
Logger.DbgLog("A-D Lib: Unknown Operation Requested");
|
||||
#endif
|
||||
return ConstStrings.CASA_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
public int InitAD()
|
||||
{
|
||||
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public int CleanUP_AD()
|
||||
{
|
||||
|
||||
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();
|
||||
if (StoreID == ConstStrings.CASA_STORE_FFOX)
|
||||
return FFEngine.IsStoreAvailable();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
80
adlib/AssemblyInfo.cs
Normal file
80
adlib/AssemblyInfo.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Novell.CASA.A-D.dll")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Novell, Inc")]
|
||||
[assembly: AssemblyProduct("CASA")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
94
adlib/Common.cs
Normal file
94
adlib/Common.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines.Common
|
||||
{
|
||||
|
||||
public class ConstStrings
|
||||
{
|
||||
|
||||
// Error codes
|
||||
public static int CASA_SUCCESS = 0;
|
||||
public static int CASA_OPERATION_FAILED = 1;
|
||||
public static int CASA_STORE_NOT_AVAILABLE = 3;
|
||||
public static int CASA_DATA_UNAVAILABLE = 4;
|
||||
|
||||
// Store IDs
|
||||
public static string miCASA = "miCASA";
|
||||
public static string KW = "KDE KWallet";
|
||||
public static string GK = "GNOME Keyring";
|
||||
public static string PM = "Password Manager";
|
||||
public static string FF = "Firefox";
|
||||
|
||||
//Store Types
|
||||
public static int CASA_STORE_MICASA = 0;
|
||||
public static int CASA_STORE_FFOX = 1;
|
||||
public static int CASA_STORE_KWALLET =3;
|
||||
public static int CASA_STORE_MOZILLA = 2;
|
||||
public static int CASA_STORE_GK = 4;
|
||||
|
||||
|
||||
//CCF Tag Names
|
||||
|
||||
public static string CCF_ID = "ID";
|
||||
public static string CCF_GKTAG = "GK";
|
||||
public static string CCF_KW = "KWallet";
|
||||
public static string CCF_GKKEYRING = "Keyring";
|
||||
public static string CCF_SECRET = "Secret";
|
||||
public static string CCF_TYPE = "Type";
|
||||
public static string CCF_KEY = "Key";
|
||||
public static string CCF_VALUE = "Value";
|
||||
public static string CCF_TIME = "Time";
|
||||
public static string CCF_CRTIME = "Creation";
|
||||
public static string CCF_MDTIME = "Modified";
|
||||
public static string CCF_ACTIME = "Accessed";
|
||||
public static string CCF_LOCK = "Lock";
|
||||
public static string CCF_LOCKSTATUS = "LockStatus";
|
||||
public static string CCF_LOCKHAND = "LockOnIdle";
|
||||
public static string CCF_LOCKTIME = "LockTimeout";
|
||||
public static string CCF_WALLET = "Wallet";
|
||||
public static string CCF_FOLDER = "Folder";
|
||||
public static string CCF_KEYCHAIN = "Keychain";
|
||||
public static string CCF_KEYCHAINNAME = "Default";
|
||||
public static string CCF_ZONE = "Zone";
|
||||
public static string CCF_SYNCH = "Synch";
|
||||
public static string CCF_NAME = "Name";
|
||||
public static string CCF_FFTAG = "FireFox";
|
||||
public static string CCF_FFPROFILE = "Profile";
|
||||
public static string CCF_PASSWDSTATUS = "PasswordStatus";
|
||||
|
||||
//Add Operation Types on CCF
|
||||
public static int OPERATION_ADD_SECRET = 0;
|
||||
public static int OPERATION_DELETE_SECRET = 1;
|
||||
public static int OPERATION_MODIFY_SECRET = 2;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
479
adlib/FFEngine.cs
Normal file
479
adlib/FFEngine.cs
Normal file
@@ -0,0 +1,479 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
using Novell.CASA.DataEngines.Common;
|
||||
using Novell.CASA.DataEngines.FF;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
/*
|
||||
* This class is implementation of Data engine for FireFox.
|
||||
*/
|
||||
|
||||
class FFEngine : DataEngine
|
||||
{
|
||||
private static string XML_FIRFOXSECRET_TYPE_SIGNON = "Signon";
|
||||
|
||||
private String defaultProfileName=null;
|
||||
private int initProfileStatus=-1;
|
||||
|
||||
enum FireFoxResultExtended {
|
||||
FIREFOX_RESULT_SUCESS = 1,
|
||||
FIREFOX_RESULT_ERROR_UNKNOWN = 128
|
||||
};
|
||||
|
||||
public FFEngine()
|
||||
{
|
||||
//Get Profile Names
|
||||
//Console.WriteLine("FFEngine Aggregate:Invoking GetDefaultProfileName:");
|
||||
defaultProfileName=FireFox.GetDefaultProfileName();
|
||||
//This can be extended to get all profiles : Use FireFox.GetAllProfileNames()
|
||||
//Currently we support only the default profile.
|
||||
|
||||
if(defaultProfileName!=null)
|
||||
{
|
||||
//Console.WriteLine("FFEngine Constructor:Initializing the Profile "+defaultProfileName);
|
||||
initProfileStatus=FireFox.InitProfile(defaultProfileName);
|
||||
//Console.WriteLine("FFEngine Constructor:InitProfile returned "+initProfileStatus);
|
||||
}
|
||||
}
|
||||
|
||||
~FFEngine()
|
||||
{
|
||||
//Uninitialize the profile if initialized earlier
|
||||
//FIXME:- CURRENTLY NOT IVOKED SINCE THERES IS A BUG WHICH NEEDS TO BE FIXED IN FF NATIVE
|
||||
//Console.WriteLine("FFEngine Destructor:UnInitializing the Profile "+defaultProfileName);
|
||||
if(defaultProfileName!=null)
|
||||
FireFox.UninitProfile(defaultProfileName);
|
||||
}
|
||||
|
||||
public XmlNode Aggregate()
|
||||
{
|
||||
|
||||
//Init XML Document
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlNode rootElem = doc.CreateElement(ConstStrings.CCF_FFTAG);
|
||||
doc.AppendChild(rootElem);
|
||||
|
||||
//Initialize & Aggregate DefaultProfile from Firefox
|
||||
if(defaultProfileName == null)
|
||||
{
|
||||
defaultProfileName=FireFox.GetDefaultProfileName();
|
||||
initProfileStatus=FireFox.InitProfile(defaultProfileName);
|
||||
if(initProfileStatus!=1)
|
||||
return rootElem;
|
||||
}
|
||||
|
||||
/*Console.WriteLine("FFEngine.cs : Printing Doc to Console-BEFORE\n");
|
||||
doc.Save(Console.Out);
|
||||
int temp = readProfileToCCF(doc,rootElem,defaultProfileName);
|
||||
Console.WriteLine("FFEngine.cs : Printing Doc to Console-AFTER\n");
|
||||
doc.Save(Console.Out);*/
|
||||
|
||||
int temp = readProfileToCCF(doc,rootElem,defaultProfileName);
|
||||
|
||||
if(temp!=1)
|
||||
{
|
||||
//Console.WriteLine("FFEngine : Host List is null even when secrets are present");
|
||||
FireFox.UninitProfile(defaultProfileName);
|
||||
defaultProfileName = FireFox.GetDefaultProfileName();
|
||||
//Console.WriteLine("FFEngine : Default Profile Name : " + defaultProfileName);
|
||||
if(defaultProfileName==null)
|
||||
return rootElem;
|
||||
initProfileStatus = FireFox.InitProfile(defaultProfileName);
|
||||
if(initProfileStatus!=1)
|
||||
return rootElem;
|
||||
readProfileToCCF(doc,rootElem,defaultProfileName);
|
||||
}
|
||||
|
||||
//Initialize & Aggregate any other profiles here if required....
|
||||
|
||||
//Console.WriteLine("FFEngine:Returning Aggregated Node for FireFox:");
|
||||
return rootElem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
return (int)FireFoxResultExtended.FIREFOX_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
string ProfileName=null,secretName=null;
|
||||
int retVal=0;
|
||||
ProfileName = ExtractProfileName(secret);
|
||||
//Console.WriteLine("FfEngine.cs : ProfileName : " + ProfileName);
|
||||
secretName = ExtractSecretName(secret, opnType);
|
||||
|
||||
Host newHost = new Host();
|
||||
HostElement nh1 = null;
|
||||
try
|
||||
{
|
||||
newHost.hostName = Marshal.StringToHGlobalAnsi(secretName);
|
||||
//Console.WriteLine("FFEngine.cs : SecretName " + secretName);
|
||||
}catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Unable to Marshal the SecretName" + e.ToString());
|
||||
}
|
||||
XmlNodeList keylist = secret.SelectNodes("descendant::Key");
|
||||
try
|
||||
{
|
||||
IntPtr next = IntPtr.Zero;
|
||||
|
||||
for (int i=keylist.Count-1;i>=0;i--)
|
||||
{
|
||||
//Get the Key
|
||||
HostElement nh = new HostElement();
|
||||
XmlAttributeCollection at = keylist.Item(i).Attributes;
|
||||
String keyname = (at["ID"]).InnerText;
|
||||
String passwordstatus = (at["PasswordStatus"]).InnerText;
|
||||
//Console.WriteLine("FFEngine.cs : Keyname : " + keyname);
|
||||
//Console.WriteLine("FFEngine.cs : Value : " + keylist.Item(i).ChildNodes[0].InnerText );
|
||||
nh.name = Marshal.StringToHGlobalAnsi(keyname);
|
||||
nh.value = Marshal.StringToHGlobalAnsi(keylist.Item(i).ChildNodes[0].InnerText);
|
||||
nh.isPassword = Convert.ToInt32(passwordstatus);
|
||||
nh.next = next;
|
||||
next = Marshal.AllocHGlobal(Marshal.SizeOf(nh));
|
||||
Marshal.StructureToPtr(nh,next,false);
|
||||
}
|
||||
newHost.hostElement = next;
|
||||
|
||||
retVal = FireFox.Modify_Host(ProfileName,newHost,1);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Unable to Marshal the Key/Value Pairs" + e.ToString());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public int GetSecret(XmlNode secret)
|
||||
{
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
string ProfileName = ExtractProfileName(secret);
|
||||
string secretName = ExtractSecretName(secret, ConstStrings.OPERATION_DELETE_SECRET);
|
||||
int retVal = FireFox.Remove_Host(ProfileName,secretName);
|
||||
//return (int)FireFoxResultExtended.FIREFOX_RESULT_ERROR_UNKNOWN;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//isMasterPasswordSet
|
||||
//Is MasterPassword Set For the specified (Currently-Default) profile
|
||||
//@param
|
||||
// None ; For supporting multiple profiles,
|
||||
// this needs to be extended to pass profile names
|
||||
//
|
||||
// @return 1 if master password is set
|
||||
// 0 if master password not set
|
||||
//--------------------------------------------------------------
|
||||
public int isMasterPasswordSet()
|
||||
{
|
||||
return (int)FireFox.isMasterPasswordSetFor(defaultProfileName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//verifyMasterPassword
|
||||
//Check if the specified master password is correct or not for the (Currently-Default) profile.
|
||||
//If it is correct then password is stored to the internal store for later use.
|
||||
//If it is wrong then nothing is stored and 0 will be returned.
|
||||
//
|
||||
//@param
|
||||
// masterPassword (string)
|
||||
// ; For supporting multiple profiles, this needs to be extended to pass profile names
|
||||
//
|
||||
// @return 1 if the specified master password is correct
|
||||
// 0 if the master password is wrong.
|
||||
//--------------------------------------------------------------
|
||||
public int verifyMasterPassword(string masterPassword)
|
||||
{
|
||||
return (int)FireFox.checkMasterPassword(defaultProfileName,masterPassword);
|
||||
}
|
||||
|
||||
|
||||
//=================Local Methods====================================
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//readProfileToCCF
|
||||
//@param
|
||||
// doc (XmlDocument) XML CCF Document for Firefox
|
||||
// profileName (string) name of the profile to be read
|
||||
//@return 1 on success
|
||||
// <=0 on error
|
||||
// <FireFox>
|
||||
// <Profile ID="Default">
|
||||
// <Secret ID="hostname url" Type="Signon">
|
||||
// <Key ID="UserName">
|
||||
// <value>user1</value>
|
||||
// </Key>
|
||||
// <Key ID="Password">
|
||||
// <value>password value</value>
|
||||
// </Key>
|
||||
// </Secret>
|
||||
// </Profile>
|
||||
// </FireFox>
|
||||
//--------------------------------------------------------------
|
||||
public int readProfileToCCF(XmlDocument doc,XmlNode rootElement,string profileName)
|
||||
{
|
||||
int methodStatusCode=-1;
|
||||
|
||||
if((profileName!=null) && (initProfileStatus==(int)FireFoxResultExtended.FIREFOX_RESULT_SUCESS))
|
||||
{
|
||||
Host hostList = null;
|
||||
|
||||
//Console.WriteLine("FireFox:Getting Data for profile "+profileName);
|
||||
hostList = FireFox.GetProfileData(profileName);
|
||||
|
||||
if(hostList!=null)
|
||||
{// Something to Aggregate
|
||||
//Console.WriteLine("\nFFEngine.cs : HostList is not null");
|
||||
XmlElement xmlProfileElement;
|
||||
|
||||
String hostName;
|
||||
String name;
|
||||
String value;
|
||||
int isPassword;
|
||||
|
||||
methodStatusCode=1;
|
||||
xmlProfileElement = doc.CreateElement(ConstStrings.CCF_FFPROFILE); //<Profile>
|
||||
XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID); //<Profile>-ID
|
||||
idAttr.Value = profileName;
|
||||
xmlProfileElement.SetAttributeNode(idAttr);
|
||||
|
||||
while (hostList != null)
|
||||
{
|
||||
HostElement hostElementList;
|
||||
|
||||
|
||||
XmlElement xmlSecretElement = doc.CreateElement(ConstStrings.CCF_SECRET); //<Secret>
|
||||
|
||||
|
||||
hostName = (String)Marshal.PtrToStringAnsi(hostList.hostName);
|
||||
//Console.WriteLine("--------------------------------------------");
|
||||
//Console.WriteLine("FFEngine::hostName="+hostName);
|
||||
XmlAttribute secIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID); //<Secret>-ID
|
||||
secIdAttr.Value = hostName;
|
||||
xmlSecretElement.SetAttributeNode(secIdAttr);
|
||||
|
||||
XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE); //<Secret>-Type
|
||||
typeAttr.Value = XML_FIRFOXSECRET_TYPE_SIGNON;
|
||||
xmlSecretElement.SetAttributeNode(typeAttr);
|
||||
|
||||
|
||||
//hostElementList = new HostElement();
|
||||
hostElementList = (HostElement)Marshal.PtrToStructure(hostList.hostElement, typeof(HostElement));
|
||||
while (hostElementList != null)
|
||||
{
|
||||
|
||||
XmlElement xmlKeyElement = null;
|
||||
XmlAttribute keyIdAttr = null;
|
||||
XmlAttribute keyPasswdStatusAttr = null;
|
||||
XmlElement xmlValueElement = null;
|
||||
|
||||
name = (String)Marshal.PtrToStringAnsi(hostElementList.name);
|
||||
//Console.WriteLine("FFEngine::name="+name);
|
||||
value = (String)Marshal.PtrToStringAnsi(hostElementList.value);
|
||||
//Console.WriteLine("FFEngine::value="+value);
|
||||
isPassword = hostElementList.isPassword;
|
||||
//Console.WriteLine("FFEngine::isPassword="+isPassword);
|
||||
|
||||
xmlKeyElement = doc.CreateElement(ConstStrings.CCF_KEY); //<Key
|
||||
keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID); //<Key>-ID
|
||||
keyIdAttr.Value = name;
|
||||
xmlKeyElement.SetAttributeNode(keyIdAttr);
|
||||
|
||||
keyPasswdStatusAttr = doc.CreateAttribute(ConstStrings.CCF_PASSWDSTATUS); //<Key>-ID
|
||||
if(isPassword == 1)
|
||||
keyPasswdStatusAttr.Value = "1";
|
||||
else
|
||||
keyPasswdStatusAttr.Value = "0";
|
||||
xmlKeyElement.SetAttributeNode(keyPasswdStatusAttr);
|
||||
|
||||
xmlValueElement = doc.CreateElement(ConstStrings.CCF_VALUE); //<value>
|
||||
xmlValueElement.InnerText = value;
|
||||
xmlKeyElement.AppendChild(xmlValueElement); //</value>
|
||||
xmlSecretElement.AppendChild(xmlKeyElement); //</Key
|
||||
|
||||
//INNERLOOP-Loop for hostElementList
|
||||
if (hostElementList.next == IntPtr.Zero)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hostElementList = (HostElement)Marshal.PtrToStructure(hostElementList.next, typeof(HostElement));
|
||||
}
|
||||
|
||||
xmlProfileElement.AppendChild(xmlSecretElement); //</Secret>
|
||||
|
||||
//OUTERLOOP-Loop for hostList
|
||||
if (hostList.next == IntPtr.Zero)
|
||||
{
|
||||
//Console.WriteLine("FFEngine::End of all Data Items##");
|
||||
break;
|
||||
}
|
||||
|
||||
hostList = (Host)Marshal.PtrToStructure(hostList.next, typeof(Host));
|
||||
}
|
||||
|
||||
rootElement.AppendChild(xmlProfileElement); //</Profile>
|
||||
|
||||
|
||||
}
|
||||
|
||||
}//~Aggregate profileName
|
||||
|
||||
return methodStatusCode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Boolean IsStoreAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(FireFox.IsStoreAvailable() == 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch(DllNotFoundException d)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception = " + d.ToString());
|
||||
return false;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception = " + e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string ExtractSecretName(XmlNode secret, int opnType)
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
//Console.WriteLine("FFEngine.cs: SecretId : " + secretid);
|
||||
|
||||
if (opnType == ConstStrings.OPERATION_ADD_SECRET)
|
||||
{
|
||||
return secretid; //Not expecting an item Id
|
||||
|
||||
}
|
||||
|
||||
return secretid;
|
||||
//int itemIdx = secretid.LastIndexOf("]");
|
||||
//Return substring without itemId
|
||||
//return(secretid.Substring(0,itemIdx));
|
||||
}
|
||||
|
||||
string ExtractProfileName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode;
|
||||
atcol = parentNode.Attributes;
|
||||
String profilename = atcol["ID"].InnerXml;
|
||||
return profilename;
|
||||
}
|
||||
|
||||
//#if TEST
|
||||
public static void Main()
|
||||
{
|
||||
|
||||
|
||||
FFEngine ff = new FFEngine();
|
||||
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("********** Menu ***********");
|
||||
Console.WriteLine("* 5. Refresh *");
|
||||
Console.WriteLine("* 6. Is Store Avail *");
|
||||
Console.WriteLine("* 7. Quit *");
|
||||
Console.WriteLine("***************************");
|
||||
Console.WriteLine("For all options the input is the file /root/fftest.xml");
|
||||
|
||||
Console.WriteLine("Select option and Press enter");
|
||||
String line = Console.ReadLine();
|
||||
int res = 0;
|
||||
|
||||
if (line.Length > 0)
|
||||
{
|
||||
char[] c = line.Substring(0, 1).ToCharArray();
|
||||
if (c.Length > 0)
|
||||
{
|
||||
if (c[0].Equals('7'))
|
||||
return;
|
||||
if (c[0].Equals('6'))
|
||||
{
|
||||
Console.WriteLine("Store Available is = " + FFEngine.IsStoreAvailable());
|
||||
return;
|
||||
}
|
||||
if (c[0].Equals('5'))
|
||||
{
|
||||
Console.WriteLine("FFEngine:Main:Aggregating:");
|
||||
XmlNode node = ff.Aggregate ();
|
||||
XmlDocument doc = node.OwnerDocument;
|
||||
XmlTextWriter writer = new XmlTextWriter("/root/fftest.xml",null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
writer.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
XmlTextReader tr = new XmlTextReader("/root/fftest.xml");
|
||||
tr.Read();
|
||||
xmlDoc.Load(tr);
|
||||
XmlNode root = xmlDoc.LastChild;
|
||||
if (root == null)
|
||||
{
|
||||
Console.WriteLine("Root is null");
|
||||
}
|
||||
|
||||
XmlNode secret = root.ChildNodes[0].ChildNodes[0];
|
||||
Console.WriteLine("secret Name \n" + secret.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Result of Operation = " + res);
|
||||
|
||||
}
|
||||
//#endif
|
||||
|
||||
}
|
||||
}
|
||||
458
adlib/GKEngine.cs
Normal file
458
adlib/GKEngine.cs
Normal file
@@ -0,0 +1,458 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
using Novell.CASA.DataEngines.Common;
|
||||
using Novell.CASA.DataEngines.GK;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
/*
|
||||
* This class is implementation of Data engine for Gnome-Keyring.
|
||||
*/
|
||||
|
||||
class GKEngine : DataEngine
|
||||
{
|
||||
|
||||
enum KeyringResultExtended {
|
||||
GNOME_KEYRING_RESULT_NO_SUCH_ITEM = 128,
|
||||
GNOME_KEYRING_RESULT_CANNOT_DELETE_SECRET_VALUE,
|
||||
GNOME_KEYRING_RESULT_MALFORMED_XML,
|
||||
GNOME_KEYRING_RESULT_CANNOT_CREATE_KEYRING,
|
||||
GNOME_KEYRING_RESULT_ERROR_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
public GKEngine()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~GKEngine()
|
||||
{
|
||||
GnomeKeyring.ReleaseGnomeKeyringLib();
|
||||
}
|
||||
|
||||
public XmlNode Aggregate()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlNode rootElem = doc.CreateElement(ConstStrings.CCF_GKTAG);
|
||||
doc.AppendChild(rootElem);
|
||||
XmlElement keyringElem;
|
||||
|
||||
ArrayList itemList;
|
||||
ArrayList attrList;
|
||||
ItemInfo itemInfo;
|
||||
KeyringInfo keyringInfo;
|
||||
int itemId;
|
||||
ArrayList keyringList = GnomeKeyring.GKGetKeyrings();
|
||||
IEnumerator kEtor = keyringList.GetEnumerator();
|
||||
IEnumerator iEtor;
|
||||
|
||||
while(kEtor.MoveNext())
|
||||
{
|
||||
string keyring = (string)(kEtor.Current);
|
||||
|
||||
keyringElem = doc.CreateElement(ConstStrings.CCF_GKKEYRING);
|
||||
XmlAttribute idAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
idAttr.Value = keyring;
|
||||
keyringElem.SetAttributeNode(idAttr);
|
||||
|
||||
keyringInfo = GnomeKeyring.GKGetKeyringInfo(keyring);
|
||||
|
||||
itemList = GnomeKeyring.GKGetItems(keyring);
|
||||
iEtor = itemList.GetEnumerator();
|
||||
while(iEtor.MoveNext())
|
||||
{
|
||||
itemId = (int)iEtor.Current;
|
||||
itemInfo = GnomeKeyring.GKGetItemInfo(keyring,itemId);
|
||||
attrList = GnomeKeyring.GKGetAttributeList(keyring,itemId);
|
||||
if(itemInfo.displayName==null)
|
||||
continue;
|
||||
|
||||
XmlElement secretElem = doc.CreateElement(ConstStrings.CCF_SECRET);
|
||||
XmlAttribute secIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
secIdAttr.Value = itemInfo.displayName + ":" + itemId;
|
||||
|
||||
secretElem.SetAttributeNode(secIdAttr);
|
||||
|
||||
XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
|
||||
typeAttr.Value = itemInfo.itemType.ToString();
|
||||
secretElem.SetAttributeNode(typeAttr);
|
||||
|
||||
XmlElement keyElem = null;
|
||||
XmlAttribute keyIdAttr = null;
|
||||
XmlElement valueElem = null;
|
||||
|
||||
if ((itemInfo.secret != null) && (itemInfo.secret.Length != 0))
|
||||
{
|
||||
keyElem = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
keyIdAttr.Value = "password";
|
||||
keyElem.SetAttributeNode(keyIdAttr);
|
||||
|
||||
valueElem = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
valueElem.InnerText = itemInfo.secret;
|
||||
keyElem.AppendChild(valueElem);
|
||||
secretElem.AppendChild(keyElem);
|
||||
}
|
||||
|
||||
IEnumerator attrEtor = (IEnumerator)(attrList.GetEnumerator());
|
||||
while(attrEtor.MoveNext())
|
||||
{
|
||||
Novell.CASA.DataEngines.GK.Attribute attr = (Novell.CASA.DataEngines.GK.Attribute)(attrEtor.Current);
|
||||
keyElem = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
keyIdAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
keyIdAttr.Value = attr.key;
|
||||
keyElem.SetAttributeNode(keyIdAttr);
|
||||
|
||||
valueElem = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
valueElem.InnerText = attr.value;
|
||||
keyElem.AppendChild(valueElem);
|
||||
secretElem.AppendChild(keyElem);
|
||||
}
|
||||
|
||||
keyringElem.AppendChild(secretElem);
|
||||
XmlElement timeElem = doc.CreateElement(ConstStrings.CCF_TIME);
|
||||
|
||||
XmlElement itemCreatedTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME);
|
||||
itemCreatedTimeElem.InnerText = itemInfo.mTime.ToString();
|
||||
timeElem.AppendChild(itemCreatedTimeElem);
|
||||
|
||||
XmlElement itemModifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME);
|
||||
itemModifiedTimeElem.InnerText = itemInfo.cTime.ToString();
|
||||
timeElem.AppendChild(itemModifiedTimeElem);
|
||||
|
||||
secretElem.AppendChild(timeElem);
|
||||
}
|
||||
XmlElement keyringTimeElem = doc.CreateElement(ConstStrings.CCF_TIME);
|
||||
|
||||
XmlElement createdTimeElem = doc.CreateElement(ConstStrings.CCF_CRTIME);
|
||||
createdTimeElem.InnerText = keyringInfo.mTime.ToString();
|
||||
keyringTimeElem.AppendChild(createdTimeElem);
|
||||
|
||||
XmlElement modifiedTimeElem = doc.CreateElement(ConstStrings.CCF_MDTIME);
|
||||
modifiedTimeElem.InnerText = keyringInfo.cTime.ToString();
|
||||
keyringTimeElem.AppendChild(modifiedTimeElem);
|
||||
|
||||
keyringElem.AppendChild(keyringTimeElem);
|
||||
|
||||
XmlElement lockElem = doc.CreateElement(ConstStrings.CCF_LOCK);
|
||||
|
||||
XmlAttribute lockStatusAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKSTATUS);
|
||||
if( keyringInfo.isLocked == 1 )
|
||||
lockStatusAttr.Value = "locked";
|
||||
else
|
||||
lockStatusAttr.Value = "unlocked";
|
||||
lockElem.SetAttributeNode(lockStatusAttr);
|
||||
|
||||
XmlAttribute lockOnIdleAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKHAND);
|
||||
if( keyringInfo.lockOnIdle == 1)
|
||||
lockOnIdleAttr.Value = "true";
|
||||
else
|
||||
lockOnIdleAttr.Value = "false";
|
||||
lockElem.SetAttributeNode(lockOnIdleAttr);
|
||||
|
||||
XmlAttribute lockTimeoutAttr = doc.CreateAttribute(ConstStrings.CCF_LOCKTIME);
|
||||
lockTimeoutAttr.Value = keyringInfo.lockTimeout.ToString();
|
||||
lockElem.SetAttributeNode(lockTimeoutAttr);
|
||||
|
||||
keyringElem.AppendChild(lockElem);
|
||||
rootElem.AppendChild(keyringElem);
|
||||
}
|
||||
#if TEST
|
||||
XmlTextWriter writer = new XmlTextWriter("./gk.xml",null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
writer.Close();
|
||||
#endif
|
||||
|
||||
return doc.ChildNodes[0];
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
string password = "";
|
||||
int retValue;
|
||||
|
||||
try
|
||||
{
|
||||
int itemid = ExtractSecretId(secret);
|
||||
string keyringname = ExtractKeyringName(secret);
|
||||
|
||||
NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection();
|
||||
|
||||
XmlNodeList keylist = secret.SelectNodes("descendant::Key");
|
||||
foreach (XmlNode tuple in keylist)
|
||||
{
|
||||
//Get the Key
|
||||
XmlAttributeCollection at = tuple.Attributes;
|
||||
String keyname = (at["ID"]).InnerText;
|
||||
if (keyname.Equals("password"))
|
||||
{
|
||||
password = tuple.ChildNodes[0].InnerText;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newNVC.Add(keyname, tuple.ChildNodes[0].InnerText);
|
||||
}
|
||||
}
|
||||
if (opnType == ConstStrings.OPERATION_ADD_SECRET ) //Add Item Opn
|
||||
{
|
||||
|
||||
string strItemType = ExtractItemType(secret);
|
||||
string secretName = ExtractSecretName(secret, opnType);
|
||||
|
||||
return(GnomeKeyring.CreateSecret(keyringname, strItemType, secretName, password, newNVC));
|
||||
}
|
||||
|
||||
//Modify secret Opn
|
||||
retValue = GnomeKeyring.SetPassword(keyringname, itemid, password);
|
||||
|
||||
if (retValue != 0)
|
||||
{
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
if (newNVC.Count != 0)
|
||||
{
|
||||
|
||||
return (GnomeKeyring.SetAttributes( keyringname, itemid, newNVC));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
//Console.WriteLine("Exception in SetSecret = "+n.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Exception in SetSecret = "+e.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSecret(XmlNode secret)
|
||||
{
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
try
|
||||
{
|
||||
int itemid = ExtractSecretId(secret);
|
||||
string keyringname = ExtractKeyringName(secret);
|
||||
return (GnomeKeyring.RemoveItem( keyringname, itemid));
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
//Console.WriteLine("Exception in Remove = "+n.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_MALFORMED_XML;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
//Console.WriteLine("Exception in Remove = "+e.ToString());
|
||||
return (int)KeyringResultExtended.GNOME_KEYRING_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean IsStoreAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(GnomeKeyring));
|
||||
if (GnomeKeyring.IsGnomeKeyringInstalled())
|
||||
{
|
||||
//Console.WriteLine("IsGnomeKeyringInstalled is true");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("IsGnomeKeyringInstalled is false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(DllNotFoundException d)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception = " + d.ToString());
|
||||
return false;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception = " + e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ExtractSecretId(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
//Check if itemId is present
|
||||
/*if (secretid.EndsWith(":"))
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
*/
|
||||
int itemIdx = secretid.LastIndexOf(":");
|
||||
if (itemIdx == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int itemid = Convert.ToInt32(secretid.Substring(itemIdx + 1));
|
||||
return itemid;
|
||||
}
|
||||
|
||||
string ExtractSecretName(XmlNode secret, int opnType)
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
|
||||
if (opnType == ConstStrings.OPERATION_ADD_SECRET)
|
||||
{
|
||||
return secretid; //Not expecting an item Id
|
||||
|
||||
}
|
||||
int itemIdx = secretid.LastIndexOf(":");
|
||||
//Return substring without itemId
|
||||
return(secretid.Substring(0,itemIdx));
|
||||
}
|
||||
|
||||
string ExtractKeyringName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode;
|
||||
atcol = parentNode.Attributes;
|
||||
String keyringname = atcol["ID"].InnerXml;
|
||||
return keyringname;
|
||||
}
|
||||
|
||||
|
||||
string ExtractItemType(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String itemType = atcol[ConstStrings.CCF_TYPE].InnerXml;
|
||||
return(itemType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if TEST
|
||||
public static void Main()
|
||||
{
|
||||
|
||||
|
||||
GKEngine gk = new GKEngine();
|
||||
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("********** Menu ***********");
|
||||
Console.WriteLine("* 1. Add secret *");
|
||||
Console.WriteLine("* 2. Modify secret *");
|
||||
Console.WriteLine("* 3. Set secret *");
|
||||
Console.WriteLine("* 4. Remove secret *");
|
||||
Console.WriteLine("* 5. Refresh *");
|
||||
Console.WriteLine("* 6. Is Store Avail *");
|
||||
Console.WriteLine("* 7. Quit *");
|
||||
Console.WriteLine("***************************");
|
||||
Console.WriteLine("For all options the input is the file /root/gktest.xml");
|
||||
|
||||
Console.WriteLine("Select option and Press enter");
|
||||
String line = Console.ReadLine();
|
||||
int res = 0;
|
||||
|
||||
if (line.Length > 0)
|
||||
{
|
||||
char[] c = line.Substring(0, 1).ToCharArray();
|
||||
if (c.Length > 0)
|
||||
{
|
||||
if (c[0].Equals('7'))
|
||||
return;
|
||||
if (c[0].Equals('6'))
|
||||
{
|
||||
Console.WriteLine("Store Available is = " + GKEngine.IsStoreAvailable());
|
||||
return;
|
||||
}
|
||||
if (c[0].Equals('5'))
|
||||
{
|
||||
XmlNode node = gk.Aggregate ();
|
||||
XmlDocument doc = node.OwnerDocument;
|
||||
XmlTextWriter writer = new XmlTextWriter("/root/gktest.xml",null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
writer.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
XmlTextReader tr = new XmlTextReader("/root/gktest.xml");
|
||||
tr.Read();
|
||||
xmlDoc.Load(tr);
|
||||
XmlNode root = xmlDoc.LastChild;
|
||||
if (root == null)
|
||||
{
|
||||
Console.WriteLine("Root is null");
|
||||
}
|
||||
|
||||
XmlNode secret = root.ChildNodes[0].ChildNodes[0];
|
||||
Console.WriteLine("secret Name \n" + secret.Name);
|
||||
if (c[0].Equals('4'))
|
||||
res =gk.Remove(secret);
|
||||
else if (c[0].Equals('1'))
|
||||
res = gk.SetSecret(secret, ConstStrings.OPERATION_ADD_SECRET);
|
||||
else if (c[0].Equals('2'))
|
||||
res = gk.SetSecret(secret, ConstStrings.OPERATION_MODIFY_SECRET);
|
||||
else if (c[0].Equals('3'))
|
||||
res = gk.SetSecret(secret);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Result of Operation = " + res);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
55
adlib/IDataEngine.cs
Normal file
55
adlib/IDataEngine.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
/*
|
||||
* Defines the interfaces to be implemenetd by all Data Engines.
|
||||
*/
|
||||
public interface DataEngine
|
||||
{
|
||||
|
||||
XmlNode Aggregate();
|
||||
|
||||
int GetSecret(XmlNode secret);
|
||||
|
||||
int SetSecret(XmlNode secret, int opnType);
|
||||
|
||||
int SetSecret(XmlNode secret);
|
||||
|
||||
int Remove(XmlNode secret);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
542
adlib/KWalletEngine.cs
Normal file
542
adlib/KWalletEngine.cs
Normal file
@@ -0,0 +1,542 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Novell.CASA;
|
||||
using Novell.CASA.DataEngines.Common;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
using Novell.CASA.DataEngines.KWallet;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
/*
|
||||
* This class is implementation of Data engine for KWallet.
|
||||
*/
|
||||
|
||||
|
||||
class KWalletEngine : DataEngine
|
||||
{
|
||||
|
||||
string[] EntryTypes = {"Binary","Passwords","Unknown", "Maps"};
|
||||
enum KWalletResult : int
|
||||
{
|
||||
KWALLET_RESULT_OK,
|
||||
|
||||
KWALLET_RESULT_CANNOT_OPEN_WALLET,
|
||||
KWALLET_RESULT_CANNOT_OPEN_FOLDER,
|
||||
KWALLET_RESULT_CANNOT_WRITE_ENTRY,
|
||||
KWALLET_RESULT_MALFORMED_XML,
|
||||
KWALLET_RESULT_CANNOT_CREATE_FOLDER,
|
||||
KWALLET_RESULT_CANNOT_CREATE_WALLET,
|
||||
KWALLET_RESULT_CANNOT_REMOVE_ENTRY,
|
||||
KWALLET_RESULT_UNKNOWN_ERROR
|
||||
};
|
||||
|
||||
|
||||
public KWalletEngine()
|
||||
{
|
||||
// TBD: Read Policy information and have a list of wallet names;
|
||||
|
||||
}
|
||||
|
||||
public XmlNode Aggregate()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Hashtable lookup = new Hashtable();
|
||||
XmlElement key1;
|
||||
XmlAttribute Atr;
|
||||
XmlElement value1;
|
||||
XmlAttribute idAttr;
|
||||
String secid, val;
|
||||
XmlElement currentWallet;
|
||||
XmlElement Folder;
|
||||
XmlElement Type;
|
||||
XmlElement Secret;
|
||||
String walletName, foldername, entryType, secretval;
|
||||
|
||||
|
||||
|
||||
//Adding Kwallet Top Node
|
||||
XmlElement elem = doc.CreateElement(ConstStrings.CCF_KW);
|
||||
doc.AppendChild(elem);
|
||||
|
||||
EnumSecretList enumList = new EnumSecretList();
|
||||
//kwallet.Try(enumList);
|
||||
kwallet.AggregateKW(enumList);
|
||||
EnumSecretList tempEnumSecretList1 = enumList;
|
||||
|
||||
//This can be Null only when nothing is aggregated.
|
||||
if (((String)Marshal.PtrToStringAnsi(tempEnumSecretList1.walletName)) == null )
|
||||
{
|
||||
//TBD: Log that there are no secrets to aggregate
|
||||
}
|
||||
else // Something to Aggregate
|
||||
{
|
||||
|
||||
|
||||
while (tempEnumSecretList1 != null)
|
||||
{
|
||||
walletName = (String)Marshal.PtrToStringAnsi(tempEnumSecretList1.walletName);
|
||||
// Console.WriteLine("\n\nWallet name is***# : "+walletName);
|
||||
|
||||
foldername = (String)Marshal.PtrToStringAnsi(tempEnumSecretList1.folderName);
|
||||
//Console.WriteLine("\tFolder***# : "+foldername);
|
||||
int entrytype = tempEnumSecretList1.entryType;
|
||||
//Console.WriteLine("\t\tEntryType ***#: "+entrytype);
|
||||
entryType = EntryTypes[entrytype];
|
||||
//Console.WriteLine("\t\tEntryType in string ***#: "+entryType);
|
||||
|
||||
secretval = (String)Marshal.PtrToStringAnsi(tempEnumSecretList1.secretVal);
|
||||
//Console.WriteLine("\t\tSecret***# : "+secretval);
|
||||
|
||||
//Adding Wallet
|
||||
if (lookup.ContainsKey(walletName))
|
||||
{
|
||||
//Console.WriteLine("Wallet Node found");
|
||||
currentWallet = (XmlElement)lookup[walletName];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentWallet = doc.CreateElement(ConstStrings.CCF_WALLET);
|
||||
idAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
idAttr.Value = walletName;
|
||||
currentWallet.SetAttributeNode(idAttr);
|
||||
elem.AppendChild(currentWallet);
|
||||
lookup.Add(walletName,currentWallet);
|
||||
}
|
||||
|
||||
//Adding Folder
|
||||
String xpath = "descendant::Folder[@Name='"+foldername+"']";
|
||||
XmlNodeList folList = currentWallet.SelectNodes(xpath);
|
||||
if (folList.Count == 0)
|
||||
{
|
||||
Folder = doc.CreateElement(ConstStrings.CCF_FOLDER);
|
||||
XmlAttribute name_attr = doc.CreateAttribute(ConstStrings.CCF_NAME);
|
||||
name_attr.Value = foldername;
|
||||
Folder.SetAttributeNode(name_attr);
|
||||
currentWallet.AppendChild(Folder);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Adding Type
|
||||
xpath = "descendant::Folder";
|
||||
XmlNodeList folderlist = currentWallet.SelectNodes(xpath);
|
||||
|
||||
foreach(XmlNode folder in folderlist)
|
||||
{
|
||||
XmlAttributeCollection atcol = folder.Attributes;
|
||||
XmlAttribute attr = atcol[ConstStrings.CCF_NAME];
|
||||
if (attr.InnerXml.Equals(foldername))
|
||||
{
|
||||
xpath = "descendant::Type[@ID='"+entryType+"']";
|
||||
XmlNodeList keylist = folder.SelectNodes(xpath);
|
||||
if (keylist.Count == 0)
|
||||
{
|
||||
Type = doc.CreateElement(ConstStrings.CCF_TYPE);
|
||||
XmlAttribute name_attr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
name_attr.Value = entryType;
|
||||
Type.SetAttributeNode(name_attr);
|
||||
folder.AppendChild(Type);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("Type Already Added");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Adding the Secret
|
||||
xpath = "descendant::Folder";
|
||||
folderlist = currentWallet.SelectNodes(xpath);
|
||||
|
||||
foreach(XmlNode folder in folderlist)
|
||||
{
|
||||
XmlAttributeCollection atcol = folder.Attributes;
|
||||
XmlAttribute attr = atcol[ConstStrings.CCF_NAME];
|
||||
if (attr.InnerXml.Equals(foldername))
|
||||
{
|
||||
xpath = "descendant::Type[@ID='"+entryType+"']";
|
||||
|
||||
XmlNodeList keylist = folder.SelectNodes(xpath);
|
||||
if (keylist.Count == 0)
|
||||
{
|
||||
//Console.WriteLine("Construction of CCF Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
XmlNode TargetType = keylist[0]; //Type Node
|
||||
string[] split = null;
|
||||
|
||||
int index = secretval.IndexOf('=');
|
||||
secid = secretval.Substring(0,index);
|
||||
|
||||
|
||||
Secret = doc.CreateElement(ConstStrings.CCF_SECRET);
|
||||
XmlAttribute idattr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
idattr.Value = secid;
|
||||
Secret.SetAttributeNode(idattr);
|
||||
|
||||
/*XmlAttribute typeAttr = doc.CreateAttribute(ConstStrings.CCF_TYPE);
|
||||
typeAttr.Value = entryType;
|
||||
Secret.SetAttributeNode(typeAttr);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (entryType.Equals("Maps"))
|
||||
{
|
||||
string delim = ";";
|
||||
char[] delimiter = delim.ToCharArray();
|
||||
string realval = secretval.Substring(index+1);
|
||||
|
||||
for(int x = 1; x < 10 ; x++)
|
||||
{
|
||||
split = realval.Split(delimiter, x);
|
||||
}
|
||||
foreach(string s in split)
|
||||
{
|
||||
int ix;
|
||||
string key;
|
||||
string value;
|
||||
|
||||
//Console.WriteLine("The val is :" + s);
|
||||
if (s.Equals(""))
|
||||
{
|
||||
//Console.WriteLine("No Secret Content for a Secret ID");
|
||||
key = " ";
|
||||
value = " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
ix = s.IndexOf(':');
|
||||
key = s.Substring(0,ix);
|
||||
value = s.Substring(ix+1);
|
||||
|
||||
}
|
||||
|
||||
key1 = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
Atr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
Atr.Value = key;
|
||||
key1.SetAttributeNode(Atr);
|
||||
|
||||
//Value
|
||||
value1 = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
value1.InnerText = value;
|
||||
key1.AppendChild(value1);
|
||||
Secret.AppendChild(key1);
|
||||
|
||||
TargetType.AppendChild(Secret);
|
||||
}
|
||||
}//entrytype=Maps
|
||||
else if (entryType.Equals("Passwords"))
|
||||
{
|
||||
//Console.WriteLine("Passwords");
|
||||
val = secretval.Substring(index+1);
|
||||
|
||||
//Key
|
||||
key1 = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
Atr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
Atr.Value = "Credential";
|
||||
key1.SetAttributeNode(Atr);
|
||||
|
||||
//Value
|
||||
value1 = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
value1.InnerText = val;
|
||||
key1.AppendChild(value1);
|
||||
Secret.AppendChild(key1);
|
||||
|
||||
TargetType.AppendChild(Secret);
|
||||
}//entryType=Password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (tempEnumSecretList1.next == IntPtr.Zero)
|
||||
{
|
||||
// Console.WriteLine("Reached End ##");
|
||||
break;
|
||||
}
|
||||
|
||||
tempEnumSecretList1 = (EnumSecretList)Marshal.PtrToStructure(tempEnumSecretList1.next, typeof(EnumSecretList));
|
||||
|
||||
}
|
||||
}
|
||||
kwallet.FreeResources();
|
||||
#if TEST
|
||||
XmlTextWriter writer = new XmlTextWriter("/root/kwtest.xml",null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
writer.Close();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return doc.ChildNodes[0];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string walletName = ExtractWalletName(secret);
|
||||
string folderName = ExtractFolderName(secret);
|
||||
string keyName = ExtractKeyName(secret);
|
||||
int secretType = ExtractSecretType(secret);
|
||||
|
||||
if (secretType != 3) //Type not Map
|
||||
{
|
||||
|
||||
string value = secret.ChildNodes[0].ChildNodes[0].InnerText; //Secret.Key.Value
|
||||
|
||||
return(kwallet.SetSecret(walletName, folderName, secretType, keyName, value, value.Length));
|
||||
}
|
||||
else //If type is Map
|
||||
{
|
||||
|
||||
NameValueCollection nvc = new NameValueCollection();
|
||||
|
||||
for (int i =0; i< secret.ChildNodes.Count; i++)
|
||||
{
|
||||
|
||||
XmlNode key = secret.ChildNodes[i];
|
||||
XmlAttributeCollection atcol;
|
||||
atcol = key.Attributes;
|
||||
String keyMapName = atcol["ID"].InnerXml;
|
||||
|
||||
string value = key.ChildNodes[0].InnerText; //Secret.Key.Value
|
||||
|
||||
nvc.Add(keyMapName,value);
|
||||
}
|
||||
|
||||
|
||||
return(kwallet.SetSecret(walletName, folderName,keyName,nvc));
|
||||
}
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
return SetSecret(secret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int GetSecret(XmlNode secret)
|
||||
{
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
try
|
||||
{
|
||||
string walletName = ExtractWalletName(secret);
|
||||
string folderName = ExtractFolderName(secret);
|
||||
string keyName = ExtractKeyName(secret);
|
||||
int res = kwallet.DeleteSecret(walletName, folderName, keyName);
|
||||
if (res == 0)
|
||||
{
|
||||
XmlNode root = secret.ParentNode;
|
||||
root.RemoveChild(secret);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
catch(NullReferenceException n)
|
||||
{
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + n.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_MALFORMED_XML;
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Exception in Set Secret Cause :" + e.ToString());
|
||||
return (int)KWalletResult.KWALLET_RESULT_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
string ExtractWalletName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode.ParentNode.ParentNode;
|
||||
atcol = parentNode.Attributes;
|
||||
String walletname = atcol["ID"].InnerXml;
|
||||
return walletname;
|
||||
}
|
||||
|
||||
string ExtractFolderName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode.ParentNode; //Folder.Type.Secret
|
||||
atcol = parentNode.Attributes;
|
||||
String foldername = atcol["Name"].InnerXml;
|
||||
return foldername;
|
||||
}
|
||||
|
||||
string ExtractKeyName(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
atcol = secret.Attributes;
|
||||
String keyname = atcol["ID"].InnerXml;
|
||||
return keyname;
|
||||
}
|
||||
|
||||
int ExtractSecretType(XmlNode secret)
|
||||
{
|
||||
XmlAttributeCollection atcol;
|
||||
XmlNode parentNode = secret.ParentNode; //Type.Secret
|
||||
atcol = parentNode.Attributes;
|
||||
String entryType = atcol["ID"].InnerXml;
|
||||
if (entryType.CompareTo("Passwords")== 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (entryType.CompareTo("Binary") == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (entryType.CompareTo("Maps") == 0)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Boolean IsStoreAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Runtime.InteropServices.Marshal.PrelinkAll(typeof(kwallet));
|
||||
return true;
|
||||
}
|
||||
catch(DllNotFoundException d)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception =" + d.ToString());
|
||||
return false;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("Store Not Available Exception =" + e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if TEST
|
||||
public static void Main()
|
||||
{
|
||||
KWalletEngine kw = new KWalletEngine();
|
||||
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("********** Menu ***********");
|
||||
Console.WriteLine("* 1. Add secret *");
|
||||
Console.WriteLine("* 2. Modify secret *");
|
||||
Console.WriteLine("* 3. Set secret *");
|
||||
Console.WriteLine("* 4. Remove secret *");
|
||||
Console.WriteLine("* 5. Refresh *");
|
||||
Console.WriteLine("* 6. Quit *");
|
||||
Console.WriteLine("***************************");
|
||||
Console.WriteLine("For all options the input is the file /root/kwtest.xml");
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("Select option and Press enter");
|
||||
String line = Console.ReadLine();
|
||||
int res = 0;
|
||||
|
||||
if (line.Length > 0)
|
||||
{
|
||||
char[] c = line.Substring(0, 1).ToCharArray();
|
||||
if (c.Length > 0)
|
||||
{
|
||||
if (c[0].Equals('6'))
|
||||
return;
|
||||
if (c[0].Equals('5'))
|
||||
kw.Aggregate ();
|
||||
else
|
||||
{
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
XmlTextReader tr = new XmlTextReader("/root/kwtest.xml");
|
||||
tr.Read();
|
||||
xmlDoc.Load(tr);
|
||||
XmlNode root = xmlDoc.FirstChild;
|
||||
if (root == null)
|
||||
{
|
||||
Console.WriteLine("Root is null");
|
||||
}
|
||||
XmlNode secret = root.ChildNodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[0];
|
||||
|
||||
if (c[0].Equals('4'))
|
||||
res =kw.Remove(secret);
|
||||
else if (c[0].Equals('1'))
|
||||
res = kw.SetSecret(secret,ConstStrings.OPERATION_ADD_SECRET);
|
||||
else if (c[0].Equals('2'))
|
||||
res = kw.SetSecret(secret,ConstStrings.OPERATION_MODIFY_SECRET);
|
||||
else if (c[0].Equals('3'))
|
||||
res = kw.SetSecret(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Result of Operation = " + res);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
119
adlib/Makefile.am
Normal file
119
adlib/Makefile.am
Normal file
@@ -0,0 +1,119 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
CS_EXTRA_FLAGS = $(CSCFLAGS_DEBUG)
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS = ad_kw ad_gk ad_ff
|
||||
DIST_SUBDIRS = ad_kw ad_gk ad_ff
|
||||
|
||||
CASAROOT = ..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
EXTRA_DIST = $(CSFILES)
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME =Novell.CASA.A-D
|
||||
MODULE_EXT =dll
|
||||
|
||||
CSFILES = $(srcdir)/AssemblyInfo.cs \
|
||||
$(srcdir)/Common.cs \
|
||||
$(srcdir)/IDataEngine.cs \
|
||||
$(srcdir)/miCASAEngine.cs \
|
||||
$(srcdir)/AD_Facade.cs \
|
||||
$(srcdir)/KWalletEngine.cs \
|
||||
$(srcdir)/GKEngine.cs \
|
||||
$(srcdir)/FFEngine.cs \
|
||||
$(top_srcdir)/c_gui/Logger.cs
|
||||
|
||||
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
|
||||
CS_FLAGS = $(CSC_LIBFLAG) -pkg:gtk-sharp /d:LINUX
|
||||
CS_RESOURCES =
|
||||
CS_LIBS =$(CASALIBDIR)/$(TARGET_CFG)/Novell.CASA.DataEngines.GnomeKeyring.dll \
|
||||
$(CASALIBDIR)/$(TARGET_CFG)/Novell.CASA.DataEngines.KWallet.dll \
|
||||
$(CASALIBDIR)/$(TARGET_CFG)/Novell.CASA.DataEngines.FireFox.dll \
|
||||
$(CASALIBDIR)/$(TARGET_CFG)/Novell.CASA.CASAPolicy.dll \
|
||||
$(CASALIBDIR)/$(TARGET_CFG)/Novell.CASA.miCASAWrapper.dll
|
||||
CS_LIBPATH = $(CASALIBDIR)/$(TARGET_CFG) $(srcdir)/ad_gk/$(TARGET_CFG) $(srcdir)/ad_kw/$(TARGET_CFG) \
|
||||
$(srcdir)/ad_ff/$(TARGET_CFG)
|
||||
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
#OBJS = $(addprefix $(OBJDIR)/, $(CSFILES:%.dll=%.cs))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
|
||||
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) $(CS_LIBPATH:%=-lib:%) $(CS_LIBS:%=/r:%) -out:$@ $(CSFILES_CSC)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
|
||||
# @echo [======== Linking $@ ========]
|
||||
# $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
195
adlib/Novell.CASA.A-D.csproj
Normal file
195
adlib/Novell.CASA.A-D.csproj
Normal file
@@ -0,0 +1,195 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{25D49F34-F655-4CCF-93F1-449243AF7A32}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "Novell.CASA.DataEngines"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = "Novell.CASA.DataEngines"
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE; WIN32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\Debug\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE; WIN32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\Release\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.CASAPolicy"
|
||||
Project = "{636A9D7E-BFB5-4EB9-96F8-51FF85A98826}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.miCASAWrapper"
|
||||
Project = "{E21DD887-22F4-4935-9851-409715F663B0}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.CASA.Common"
|
||||
Project = "{57CD94A2-5B4A-40C3-8189-CB760FB78357}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "pango-sharp"
|
||||
AssemblyName = "pango-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\pango-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "atk-sharp"
|
||||
AssemblyName = "atk-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\atk-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gdk-sharp"
|
||||
AssemblyName = "gdk-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\gdk-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glade-sharp"
|
||||
AssemblyName = "glade-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\glade-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glib-sharp"
|
||||
AssemblyName = "glib-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\glib-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gtk-sharp"
|
||||
AssemblyName = "gtk-sharp"
|
||||
HintPath = "..\..\..\..\..\..\GtkRun\2.8\lib\gtk-sharp\gtk-sharp.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AD_Facade.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "FFEngine.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "GKEngine.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "IDataEngine.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "KWalletEngine.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "miCASAEngine.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "ad_ff\FireFox.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "ad_gk\GnomeKeyring.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "ad_kw\KWalletEnum.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "ad_kw\KWalletNative.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
48
adlib/Novell.CASA.A-D.csproj.user
Executable file
48
adlib/Novell.CASA.A-D.csproj.user
Executable file
@@ -0,0 +1,48 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "C:\GtkRun\2.8\lib\gtk-sharp\" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "false"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "false"
|
||||
/>
|
||||
</Settings>
|
||||
</Build>
|
||||
<OtherProjectSettings
|
||||
CopyProjectDestinationFolder = ""
|
||||
CopyProjectUncPath = ""
|
||||
CopyProjectOption = "0"
|
||||
ProjectView = "ProjectFiles"
|
||||
ProjectTrust = "0"
|
||||
/>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
80
adlib/ad_ff/AssemblyInfo.cs
Normal file
80
adlib/ad_ff/AssemblyInfo.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Novell.CASA.DataEngines.FireFox.dll")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Novell, Inc")]
|
||||
[assembly: AssemblyProduct("CASA")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
401
adlib/ad_ff/FireFox.cs
Normal file
401
adlib/ad_ff/FireFox.cs
Normal file
@@ -0,0 +1,401 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines.FF
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class Host
|
||||
{
|
||||
public IntPtr hostName;
|
||||
public IntPtr hostElement;
|
||||
public IntPtr next;
|
||||
/*public Host()
|
||||
//NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
|
||||
//WE MARSHAL PTR TO STRUCTURE
|
||||
{
|
||||
hostName = Marshal.AllocHGlobal(128);
|
||||
}
|
||||
~Host()
|
||||
{
|
||||
try
|
||||
{
|
||||
Marshal.FreeHGlobal(hostName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for Host:");
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class HostElement
|
||||
{
|
||||
public IntPtr name;
|
||||
public IntPtr value;
|
||||
public int isPassword;
|
||||
public IntPtr next;
|
||||
/*public HostElement()
|
||||
{
|
||||
name = Marshal.AllocHGlobal(128);
|
||||
value = Marshal.AllocHGlobal(128);
|
||||
}
|
||||
~HostElement()
|
||||
{
|
||||
try
|
||||
{
|
||||
Marshal.FreeHGlobal(name);
|
||||
Marshal.FreeHGlobal(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for HostElement:");
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class KeyringInfo
|
||||
{
|
||||
public int lockOnIdle;
|
||||
public uint lockTimeout;
|
||||
public uint mTime;
|
||||
public uint cTime;
|
||||
public int isLocked;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class NativeItemInfo
|
||||
{
|
||||
public int itemType;
|
||||
public IntPtr displayName;
|
||||
public IntPtr secret;
|
||||
public int mTime;
|
||||
public int cTime;
|
||||
public NativeItemInfo()
|
||||
{
|
||||
displayName = Marshal.AllocHGlobal(128);
|
||||
secret = Marshal.AllocHGlobal(128);
|
||||
}
|
||||
~NativeItemInfo()
|
||||
{
|
||||
Marshal.FreeHGlobal(displayName);
|
||||
Marshal.FreeHGlobal(secret);
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemInfo
|
||||
{
|
||||
public string itemType;
|
||||
public string displayName;
|
||||
public string secret;
|
||||
public int mTime;
|
||||
public int cTime;
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class NativeAttribute
|
||||
{
|
||||
public uint type;
|
||||
public IntPtr key;
|
||||
public IntPtr value;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class Attribute
|
||||
{
|
||||
public uint type;
|
||||
public string key;
|
||||
public string value;
|
||||
|
||||
}
|
||||
|
||||
public class FireFox
|
||||
{
|
||||
private static int MAX_PROFILES = 5; //FIXME:Maximum Profiles for Firefox - To be removed when done dynamically via a native api
|
||||
private static int LOAD_PROFILE_ALWAYSFROM_FILE = 1;
|
||||
|
||||
#if WIN32
|
||||
private const string FF_LIB = "ad_ff.dll";
|
||||
#else
|
||||
private const string FF_LIB = "libad_ff.so.1.1.1";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//Initialization functions
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_GetProfileList(out IntPtr[] profileList, out IntPtr[] profileFlag);
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_FirefoxProfileInit(string profileName);
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_IsStoreAvailable();
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_FirefoxProfileExit(string profileName);
|
||||
|
||||
//Master Password functions
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_IsMasterPasswordSet(string profileName);
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_CheckMasterPassword(string profileName, string masterPassword);
|
||||
|
||||
//Signon functions
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh);
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
|
||||
|
||||
[DllImport(FF_LIB)]
|
||||
public static extern int FPM_RemoveHost(string profileName, string hostName, int doUpdate);
|
||||
|
||||
//TBD
|
||||
//int FPM_WriteSignonData(char *profileName)
|
||||
//int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
|
||||
|
||||
public static int IsStoreAvailable()
|
||||
{
|
||||
return FPM_IsStoreAvailable();
|
||||
}
|
||||
|
||||
public static int Remove_Host(string ProfileName, string hostName)
|
||||
{
|
||||
return (FPM_RemoveHost(ProfileName, hostName, 1));
|
||||
}
|
||||
|
||||
public static int Modify_Host(string profileName, Host mhost, int doUpdate)
|
||||
{
|
||||
//Console.WriteLine("FireFox.cs : ProfileName : " + profileName);
|
||||
//Console.WriteLine("FireFox.cs : HostName : " + (String)Marshal.PtrToStringAnsi(mhost.hostName));
|
||||
|
||||
return FPM_ModifyHost(profileName, mhost,1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//GetDefaultProfileName
|
||||
//@param None
|
||||
//@return Default ProfileName on success
|
||||
// else null if not retrivable
|
||||
//--------------------------------------------------------------
|
||||
public static String GetDefaultProfileName()
|
||||
{
|
||||
|
||||
IntPtr[] profileListIntPtr=new IntPtr[MAX_PROFILES];;
|
||||
IntPtr[] profileFlagsIntPtr=new IntPtr[MAX_PROFILES];;
|
||||
String[] profileList=null;
|
||||
int[] profileFlags=null;
|
||||
String profileName=null;
|
||||
int profileFlag=0;
|
||||
int profCount=0;
|
||||
String defaultProfileName=null;
|
||||
|
||||
//Console.WriteLine("FireFox:Invoking FPM_GetProfileList:");
|
||||
profCount=FPM_GetProfileList(out profileListIntPtr,out profileFlagsIntPtr);
|
||||
//Console.WriteLine("FireFox:No of Profiles found= "+profCount);
|
||||
|
||||
//try
|
||||
///{
|
||||
for(int i=0; i< profCount; i++)
|
||||
{
|
||||
//Console.WriteLine("Firefox.cs : Inside The for Loop");
|
||||
profileName=Marshal.PtrToStringAnsi(profileListIntPtr[i]);
|
||||
profileFlag=(int)profileFlagsIntPtr[i];
|
||||
//Console.WriteLine("FireFox:Iter="+i+"profileName="+profileName);
|
||||
//Console.WriteLine("FireFox:Iter="+i+"profileFlag="+profileFlag);
|
||||
if(profileFlag==1)
|
||||
defaultProfileName=profileName; //Get the default profile name to init later
|
||||
}
|
||||
|
||||
|
||||
return defaultProfileName;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//GetAllProfileNames
|
||||
//@param None
|
||||
//@return ProfileNames (String[]) - List of all Profile Names
|
||||
// else null
|
||||
//--------------------------------------------------------------
|
||||
public static String[] GetAllProfileNames()
|
||||
{
|
||||
//TBD:To be implemented if\when required
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//GetProfileData
|
||||
//GetProfileData for the specified profile
|
||||
//@param
|
||||
// profileName (string)
|
||||
//
|
||||
//@return hostList (Host) on success
|
||||
// else null
|
||||
//--------------------------------------------------------------
|
||||
public static Host GetProfileData(string profileName)
|
||||
{
|
||||
Host hostList; // = new Host(); - NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
|
||||
// WE MARSHAL PTR TO STRUCTURE
|
||||
int methodStatusCode=-1;
|
||||
String defaultProfileName = null;
|
||||
int initProfileStatus = -1;
|
||||
|
||||
//if(methodStatusCode==1)
|
||||
{//If Init of the profile was sucessfull, get the sigon data to complete the aggregation
|
||||
IntPtr hostListIntPtr = new IntPtr();
|
||||
try
|
||||
{
|
||||
//Console.WriteLine("FireFox:Getting Data for profile "+profileName);
|
||||
methodStatusCode=-1;
|
||||
methodStatusCode = FPM_GetSignonData(profileName,out hostListIntPtr,LOAD_PROFILE_ALWAYSFROM_FILE);
|
||||
if( 1 != methodStatusCode )
|
||||
{
|
||||
//Console.WriteLine("FireFox:Getting Data for profile Failed with error "+methodStatusCode);
|
||||
hostList=null;
|
||||
return hostList;
|
||||
}
|
||||
hostList = null;
|
||||
hostList = (Host)Marshal.PtrToStructure(hostListIntPtr, typeof(Host));
|
||||
//This can be Null only when nothing is aggregated.
|
||||
if (((String)Marshal.PtrToStringAnsi(hostList.hostName)) == null )
|
||||
{
|
||||
//TBD: Log that there are no secrets to aggregate
|
||||
//Console.WriteLine("FireFox:no secrets to aggregate");
|
||||
hostList = null;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine("FireFox:Exception during invokation of FPM_GetSignonData");
|
||||
//Console.WriteLine(e.ToString());
|
||||
hostList = null;
|
||||
}
|
||||
|
||||
//Uninitialize the profile
|
||||
//Console.WriteLine("FireFox:UnInitializing the Profile "+profileName);
|
||||
//UninitProfile(profileName);
|
||||
}
|
||||
return hostList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//InitFFProfile
|
||||
//@param profileName name of the profile
|
||||
//@return 1 on success
|
||||
// <=0 on error
|
||||
//--------------------------------------------------------------
|
||||
public static int InitProfile(string profileName)
|
||||
{
|
||||
return FPM_FirefoxProfileInit(profileName);
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//UninitProfile
|
||||
//UninitProfile for the specified profile
|
||||
//@param
|
||||
// profileName (string)
|
||||
//
|
||||
//@return 1 on success
|
||||
// <=0 on error
|
||||
//--------------------------------------------------------------
|
||||
public static int UninitProfile(string profileName)
|
||||
{
|
||||
int methodStatusCode=-1;
|
||||
|
||||
//Console.WriteLine("FireFox:UninitProfile for "+profileName);
|
||||
methodStatusCode=-1;
|
||||
methodStatusCode = FPM_FirefoxProfileExit(profileName);
|
||||
/*if( 1 != methodStatusCode )
|
||||
{
|
||||
Console.WriteLine("FireFox:UninitProfile Failed with error "+methodStatusCode);
|
||||
} */
|
||||
|
||||
return methodStatusCode;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//isMasterPasswordSetFor
|
||||
//Is MasterPassword Set For specified profile
|
||||
//@param
|
||||
// profileName (string)
|
||||
//
|
||||
//@param profileName name of the profile
|
||||
// @return 1 if master password is set
|
||||
// 0 if master password not set
|
||||
//--------------------------------------------------------------
|
||||
public static int isMasterPasswordSetFor(string profileName)
|
||||
{
|
||||
int methodStatusCode=0;
|
||||
|
||||
//Console.WriteLine("FireFox:isMasterPasswordSetFor "+profileName);
|
||||
methodStatusCode = FPM_IsMasterPasswordSet(profileName);
|
||||
|
||||
return methodStatusCode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//checkMasterPassword
|
||||
//Check if the specified master password is correct or not.
|
||||
//If it is correct then password is stored to the internal store for later use.
|
||||
//If it is wrong then nothing is stored and 0 will be returned.
|
||||
//
|
||||
//@param
|
||||
// profileName (string)
|
||||
// masterPassword (string)
|
||||
//
|
||||
// @return 1 if the specified master password is correct
|
||||
// 0 if the master password is wrong.
|
||||
//--------------------------------------------------------------
|
||||
public static int checkMasterPassword(string profileName,string masterPassword)
|
||||
{
|
||||
int methodStatusCode=0;
|
||||
|
||||
//Console.WriteLine("FireFox:checking MasterPassword for "+profileName);
|
||||
methodStatusCode = FPM_CheckMasterPassword(profileName,masterPassword);
|
||||
|
||||
return methodStatusCode;
|
||||
}
|
||||
|
||||
//=================Local Methods====================================
|
||||
|
||||
}
|
||||
}
|
||||
106
adlib/ad_ff/Makefile.am
Normal file
106
adlib/ad_ff/Makefile.am
Normal file
@@ -0,0 +1,106 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
CS_EXTRA_FLAGS = $(CSCFLAGS_DEBUG)
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS = native
|
||||
DIST_SUBDIRS = native
|
||||
|
||||
EXTRA_DIST = $(CSFILES)
|
||||
|
||||
CASAROOT = ../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME =Novell.CASA.DataEngines.FireFox
|
||||
MODULE_EXT =dll
|
||||
|
||||
CSFILES = $(srcdir)/FireFox.cs \
|
||||
$(srcdir)/AssemblyInfo.cs
|
||||
|
||||
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
|
||||
CS_FLAGS = $(CSC_LIBFLAG) -target:library
|
||||
CS_RESOURCES =
|
||||
CS_LIBS =
|
||||
CS_LIBPATH =
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
#OBJS = $(addprefix $(OBJDIR)/, $(CSFILES:%.dll=%.cs))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
|
||||
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) -out:$@ $(CSFILES_CSC)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
|
||||
# @echo [======== Linking $@ ========]
|
||||
# $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
168
adlib/ad_ff/firefox.vcproj
Normal file
168
adlib/ad_ff/firefox.vcproj
Normal file
@@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="ad_firefox_native"
|
||||
ProjectGUID="{BB304ECF-FCBA-4693-9D47-86749815DDC8}"
|
||||
RootNamespace="ad_firefox_native"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FIREFOX_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="D:/casaClean2/c_gui/Debug/ad_ff.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/firefox.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/firefox.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FIREFOX_EXPORTS"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/ad_ff.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(OutDir)/firefox.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\native\Common.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\CryptManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\DataManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\FirefoxPasswordManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\ProfileManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\SignonManager.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\native\Common.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\CryptManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\DataManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\FirefoxPasswordManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\ProfileManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\native\SignonManager.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
115
adlib/ad_ff/native/Common.cpp
Normal file
115
adlib/ad_ff/native/Common.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
|
||||
char lastErrorMesg[10000];
|
||||
|
||||
void PrintMessage( int level, char *mesg , ...)
|
||||
{
|
||||
va_list vl;
|
||||
|
||||
va_start( vl , mesg );
|
||||
vsprintf( lastErrorMesg , mesg , vl );
|
||||
va_end( vl );
|
||||
|
||||
// if we are not debugging then print DEBUG level messages
|
||||
#ifdef DEBUG
|
||||
printf("%s", lastErrorMesg );
|
||||
#else
|
||||
if( level != MESG_DEBUG )
|
||||
{
|
||||
//printf("%s", lastErrorMesg );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts given string to lower case....
|
||||
*
|
||||
*/
|
||||
void StrLwr(char *str)
|
||||
{
|
||||
int n=strlen(str);
|
||||
|
||||
for(int i=0; i<n; i++)
|
||||
{
|
||||
if( str[i] >=65 && str[i]<=90 )
|
||||
str[i]+=32;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if specified directory exists
|
||||
*
|
||||
* return MC_TRUE if directory exists else MC_FALSE
|
||||
*
|
||||
*/
|
||||
int IsDirectoryExists( char *path )
|
||||
{
|
||||
if( path == NULL )
|
||||
return 0;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
DWORD attr = GetFileAttributes(path);
|
||||
|
||||
if( (attr == -1) || !(attr & FILE_ATTRIBUTE_DIRECTORY ) )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
#else
|
||||
|
||||
char *program = (char*) malloc(strlen(path)+20);
|
||||
|
||||
if( program == NULL )
|
||||
return 0;
|
||||
|
||||
strcpy(program, "test -d ");
|
||||
strcat(program, path);
|
||||
|
||||
int result= system(program);
|
||||
free(program);
|
||||
|
||||
if( result != 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
74
adlib/ad_ff/native/Common.h
Normal file
74
adlib/ad_ff/native/Common.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef __FPM_COMMON_H__
|
||||
#define __FPM_COMMON_H__
|
||||
|
||||
// Common structure declarations...
|
||||
|
||||
struct Host
|
||||
{
|
||||
char *hostName;
|
||||
struct HostElement *child;
|
||||
struct Host *next;
|
||||
};
|
||||
|
||||
|
||||
// Each name/value pair for the Host is represented by HostElement
|
||||
struct HostElement
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
int isPassword;
|
||||
struct HostElement *next;
|
||||
};
|
||||
|
||||
|
||||
struct RejectHost
|
||||
{
|
||||
char *hostName;
|
||||
struct RejectHost *next;
|
||||
};
|
||||
|
||||
|
||||
// Error codes
|
||||
|
||||
#define FPM_PROFILE_NOT_PRESENT -101 // Specified profile does not exist
|
||||
#define FPM_LIBRARY_LOAD_FAILED -102 // Failed to load the firefox library
|
||||
#define FPM_LIBRARY_INIT_FAILED -103 // Failed to initialize firefox library
|
||||
#define FPM_PROFILE_NOT_INITIALIZED -104 // Specified profile not initialized
|
||||
#define FPM_MASTERPASSWORD_WRONG -105 // Wrong master password is specified
|
||||
#define FPM_SIGNON_DATASTORE_EMPTY -106 // Internal signon data store is empty
|
||||
#define FPM_SIGNON_FILE_NOT_PRESENT -107 // Signon file is not present in profile directory
|
||||
#define FPM_SIGNON_FILE_READ_ERROR -108 // Error in reading signon file
|
||||
#define FPM_SIGNON_FILE_WRITE_ERROR -109 // Error in writing signon file
|
||||
#define FPM_SIGNON_FILE_LOCKED -110 // Signon file is locked.
|
||||
#define FPM_INSUFFICIENT_MEMORY -111 // Insufficient memory.
|
||||
#define FPM_ILLEGAL_HOSTNAME -112 // Hostname is not in proper form
|
||||
#define FPM_HOSTNAME_NOT_PRESENT -113 // Specified hostname is not present
|
||||
#define FPM_NAME_NOT_PRESENT -114 // Specified name is not present
|
||||
#define FPM_SIGNON_FILE_INVALID_DATA -115 // Invalid data is read from signon file
|
||||
#define FPM_PROFILE_LIMIT_EXCEEDED -116 // Maximum number of profiles exceeded...
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
458
adlib/ad_ff/native/CryptManager.cpp
Normal file
458
adlib/ad_ff/native/CryptManager.cpp
Normal file
@@ -0,0 +1,458 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include "CryptManager.h"
|
||||
|
||||
|
||||
|
||||
void CryptManager::SetupFunctions(void *funList[])
|
||||
{
|
||||
|
||||
//PK11SetPasswordFunc = (PK11_SetPasswordFunc) funList[0];
|
||||
PK11GetInternalKeySlot = (PK11_GetInternalKeySlot) funList[1];
|
||||
PK11FreeSlot = (PK11_FreeSlot) funList[2];
|
||||
PK11Authenticate = (PK11_Authenticate) funList[3];
|
||||
PK11CheckUserPassword =(PK11_CheckUserPassword) funList[4];
|
||||
PK11SDRDecrypt = (PK11SDR_Decrypt) funList[5];
|
||||
PK11SDREncrypt = (PK11SDR_Encrypt) funList[6];
|
||||
PLBase64Encode = (PL_Base64Encode) funList[7];
|
||||
PLBase64Decode = (PL_Base64Decode) funList[8];
|
||||
|
||||
}
|
||||
|
||||
int CryptManager::GetEncryptionPref()
|
||||
{
|
||||
|
||||
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.
|
||||
*
|
||||
* @param(in) clearData clear text data to be encrypted
|
||||
* @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;
|
||||
char *encryptData = NULL;
|
||||
char *encodeData = NULL;
|
||||
int retValue;
|
||||
|
||||
|
||||
if( clearData == NULL )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n EncryptString : Performing PK11 Encryption...");
|
||||
|
||||
retValue = FPM_FALSE;
|
||||
if( ((retValue = CryptPK11EncryptString(clearData, strlen(clearData), &encryptData, &encryptDataLen)) != FPM_TRUE) || ( encryptData == NULL) )
|
||||
{
|
||||
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");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n EncryptString : Success ");
|
||||
|
||||
// WARNING : If you uncomment , then be ready for side effects , crashes..etc
|
||||
// Need full analysis of malloc for this data..
|
||||
// Free the allocated blocks...
|
||||
|
||||
//if( encryptData )
|
||||
// free( encryptData);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
// otherwise do our own obscuring using Base64 encoding
|
||||
PrintMessage(MESG_DEBUG, "\n EncryptString : Performing JUST base64 encoding...");
|
||||
|
||||
if( (CryptBase64Encode(clearData, strlen(clearData), &encodeData) == FPM_FALSE) || (encodeData == NULL) )
|
||||
{
|
||||
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
|
||||
|
||||
int prefixLen = strlen( CRYPT_PREFIX );
|
||||
int encodeLen = strlen( encodeData );
|
||||
*finalData = (char *)malloc( prefixLen + encodeLen + 1);
|
||||
|
||||
if( *finalData == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n EncryptString : Insufficient memory");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// FinalData = CRYPT_PREFIX + Encoded Data + '\0'
|
||||
strcpy(*finalData, CRYPT_PREFIX);
|
||||
strcat(*finalData, encodeData);
|
||||
*(*finalData + prefixLen + encodeLen) = 0;
|
||||
|
||||
free(encodeData);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function decrypts the encrypted data. First it performs base64 decoding and
|
||||
* then performs TRIPLE DES decryption.
|
||||
*
|
||||
* @param(in) cryptData encrypted data
|
||||
* @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 finalLen = 0;
|
||||
char *decodeData = NULL;
|
||||
char *finalData = NULL;
|
||||
int retValue;
|
||||
|
||||
if( cryptData == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DecryptString: CryptData is NULL...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// treat zero-length crypt string as a special case
|
||||
if(cryptData[0] == '\0')
|
||||
{
|
||||
*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] )
|
||||
{
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Performing PK11 Decryption ");
|
||||
|
||||
// First do base64 decoding.....
|
||||
if( (CryptBase64Decode(cryptData, &decodeData, &decodeLen) != FPM_TRUE) || (decodeData == NULL) )
|
||||
{
|
||||
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
|
||||
retValue = FPM_FALSE;
|
||||
retValue = CryptPK11DecryptString(decodeData, decodeLen, &finalData, &finalLen);
|
||||
|
||||
if( retValue != FPM_TRUE )
|
||||
{
|
||||
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...
|
||||
|
||||
*clearData = (char*) malloc( finalLen + 1 );
|
||||
|
||||
if( *clearData == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DecryptString :Insufficient memory... ");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
|
||||
if( decodeData )
|
||||
free(decodeData);
|
||||
|
||||
if( finalData )
|
||||
free(finalData);
|
||||
*/
|
||||
|
||||
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 ");
|
||||
|
||||
unsigned int PREFIX_Len = strlen(CRYPT_PREFIX);
|
||||
if( strlen(cryptData) == PREFIX_Len )
|
||||
{
|
||||
*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 ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Performs base64 encoding of the encrypted data..
|
||||
*
|
||||
* @param(in) cryptData encrypted data
|
||||
* @param(in) cryptDataLen length of encrypted data
|
||||
* @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)
|
||||
{
|
||||
|
||||
*encodeData = (*PLBase64Encode)((const char *)cryptData, cryptDataLen, NULL);
|
||||
|
||||
if ( *encodeData == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n Base64 encoding failed ...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Performs base64 decoding of the encrypted data..
|
||||
*
|
||||
* @param(in) cryptData encrypted data
|
||||
* @param(out) decodeData base64 decoded data
|
||||
* @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 adjust = 0;
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n CryptBase64Decode : Length of crypt data = %d", len);
|
||||
|
||||
// Compute length adjustment
|
||||
if (cryptData[len-1] == '=')
|
||||
{
|
||||
adjust++;
|
||||
if (cryptData[len-2] == '=')
|
||||
adjust++;
|
||||
}
|
||||
|
||||
*decodeData = ( char *)(*PLBase64Decode)(cryptData, len, NULL);
|
||||
|
||||
if( *decodeData == NULL )
|
||||
{
|
||||
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);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs TRIPLE DES encryption of clear text data
|
||||
*
|
||||
* @param(in) clearData clear text data to be encrypted
|
||||
* @param(in) clearDataLen length of clear text data
|
||||
* @param(out) cryptData TRIPLE DES encrypted data
|
||||
* @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;
|
||||
SECItem keyid;
|
||||
SECItem request;
|
||||
SECItem reply;
|
||||
SECStatus status;
|
||||
|
||||
slot = (*PK11GetInternalKeySlot)();
|
||||
|
||||
if (!slot)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_GetInternalKeySlot failed ...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// PK11 authentication
|
||||
if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
|
||||
{
|
||||
// since we have specified password callback function , we won't come here...
|
||||
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;
|
||||
request.data = (unsigned char *)clearData;
|
||||
request.len = clearDataLen;
|
||||
reply.data = 0;
|
||||
reply.len = 0;
|
||||
|
||||
status = (*PK11SDREncrypt)(&keyid, &request, &reply, NULL);
|
||||
|
||||
if (status != SECSuccess)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11SDR_Encrypt failed ...");
|
||||
(*PK11FreeSlot) (slot);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
*cryptData = (char*)reply.data;
|
||||
*cryptDataLen = reply.len;
|
||||
|
||||
(*PK11FreeSlot) (slot);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Performs TRIPLE DES decryption of base64 decoded data
|
||||
*
|
||||
* @param(in) decodeData base64 decoded data
|
||||
* @param(in) decodeLen length of base64 decoded data
|
||||
* @param(out) clearData decrypted data
|
||||
* @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;
|
||||
SECStatus status;
|
||||
SECItem request;
|
||||
SECItem reply;
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n CryptPK11DecryptString entered ...");
|
||||
|
||||
// Find token with SDR key
|
||||
slot = (*PK11GetInternalKeySlot)();
|
||||
|
||||
if (!slot)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n PK11_GetInternalKeySlot failed ...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
|
||||
|
||||
// Force authentication
|
||||
if ( (*PK11Authenticate)(slot, PR_TRUE, NULL) != SECSuccess)
|
||||
{
|
||||
// since we have specified password callback function , we won't come here...
|
||||
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
|
||||
request.data = (unsigned char *)decodeData;
|
||||
request.len = decodeLen;
|
||||
reply.data = 0;
|
||||
reply.len = 0;
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n calling PK11SDR_Decrypt ...");
|
||||
|
||||
status = (*PK11SDRDecrypt)(&request, &reply, NULL);
|
||||
|
||||
if (status != SECSuccess)
|
||||
{
|
||||
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..
|
||||
*clearData = (char*)reply.data;
|
||||
*finalLen = reply.len;
|
||||
|
||||
// Free the slot
|
||||
(*PK11FreeSlot) (slot);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
62
adlib/ad_ff/native/CryptManager.h
Normal file
62
adlib/ad_ff/native/CryptManager.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef __FPM_CRYPT_MANAGER_H__
|
||||
#define __FPM_CRYPT_MANAGER_H__
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
|
||||
|
||||
class CryptManager
|
||||
{
|
||||
|
||||
//PK11_SetPasswordFunc PK11SetPasswordFunc;
|
||||
PK11_GetInternalKeySlot PK11GetInternalKeySlot;
|
||||
PK11_FreeSlot PK11FreeSlot;
|
||||
PK11_Authenticate PK11Authenticate;
|
||||
PK11_CheckUserPassword PK11CheckUserPassword;
|
||||
PK11SDR_Decrypt PK11SDRDecrypt;
|
||||
PK11SDR_Encrypt PK11SDREncrypt;
|
||||
|
||||
PL_Base64Encode PLBase64Encode;
|
||||
PL_Base64Decode PLBase64Decode;
|
||||
|
||||
public:
|
||||
|
||||
int DecryptString(char *cryptData, char **clearData);
|
||||
int EncryptString (char *clearData, char **finalData) ;
|
||||
int CryptBase64Decode(char *cryptData, char **decodeData, int *decodeLen);
|
||||
int CryptBase64Encode(char *cryptData, int cryptDataLen, char **encodeData);
|
||||
int CryptPK11DecryptString(char *decodeData, int decodeLen, char **clearData, int *finalLen);
|
||||
int CryptPK11EncryptString(char *clearData, int clearDataLen, char **cryptData, int *cryptDataLen);
|
||||
|
||||
void SetupFunctions(void *funList[]);
|
||||
int GetEncryptionPref();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
608
adlib/ad_ff/native/DataManager.cpp
Normal file
608
adlib/ad_ff/native/DataManager.cpp
Normal file
@@ -0,0 +1,608 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include "DataManager.h"
|
||||
|
||||
|
||||
DataManager::DataManager()
|
||||
{
|
||||
hostList = NULL;
|
||||
rejectHostList = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DataManager::~DataManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int DataManager::AddRejectHost(char *hostName)
|
||||
{
|
||||
RejectHost *t;
|
||||
|
||||
if( hostName == NULL || hostName[0] == 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Host name is NULL or empty ");
|
||||
// Just ignore this..
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
// check if the specified host is already present
|
||||
for(t=rejectHostList; t ; t = t->next)
|
||||
{
|
||||
if( STRCMPI(hostName, t->hostName) == 0 )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n DataManager : Specified hostname [%s] is already present ", hostName);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new Host element for new host
|
||||
RejectHost *tempHost = (RejectHost *) malloc(sizeof(RejectHost));
|
||||
|
||||
if( tempHost )
|
||||
tempHost->hostName = (char*) malloc(strlen(hostName) + 1);
|
||||
|
||||
if( !tempHost || !tempHost->hostName)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Failed to add reject host due to insufficient memory ");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(tempHost->hostName, hostName);
|
||||
tempHost->next = NULL;
|
||||
|
||||
if( rejectHostList == NULL )
|
||||
rejectHostList = tempHost;
|
||||
else
|
||||
{ // Add new host at the end
|
||||
for(t=rejectHostList; t->next ; t=t->next);
|
||||
|
||||
t->next = tempHost;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//invoked from outside
|
||||
int DataManager::RemoveRejectHost(char *hostName)
|
||||
{
|
||||
RejectHost *prev = NULL;
|
||||
|
||||
if( !hostName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Host name is Null ....");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// Find out and destroy it..!
|
||||
for(RejectHost *t=rejectHostList; t ; prev=t,t=t->next)
|
||||
{
|
||||
if( STRCMPI(hostName, t->hostName) == 0 )
|
||||
{
|
||||
// if this is the first node
|
||||
if( rejectHostList == t )
|
||||
rejectHostList = t->next;
|
||||
else
|
||||
prev->next = t->next;
|
||||
|
||||
free(t->hostName);
|
||||
free(t);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified hostname[%s] is not present in the reject host list", hostName);
|
||||
|
||||
return FPM_FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DataManager::PrintAllRejectHosts()
|
||||
{
|
||||
|
||||
PrintMessage(MESG_PRINT, "\n\n ****** List of Reject Hosts ******");
|
||||
|
||||
for(RejectHost *t=rejectHostList; t ; t=t->next)
|
||||
PrintMessage(MESG_PRINT, "\n %s", t->hostName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// internal function
|
||||
int DataManager::AddHost(char *hostName)
|
||||
{
|
||||
Host *host, *t;
|
||||
|
||||
if( hostName == NULL || hostName[0] == 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Host name is NULL or empty ");
|
||||
return FPM_ILLEGAL_HOSTNAME;
|
||||
}
|
||||
|
||||
// check if the specified host is already present
|
||||
for(host=hostList; host ; host = host->next)
|
||||
{
|
||||
if( STRCMPI(hostName, host->hostName) == 0 )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n DataManager : Specified hostname [%s] is already present ", hostName);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new Host
|
||||
Host *tempHost = (Host *) malloc(sizeof(Host));
|
||||
|
||||
if( tempHost )
|
||||
tempHost->hostName = (char*) malloc(strlen(hostName) + 1);
|
||||
|
||||
if( !tempHost || !tempHost->hostName)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Failed to add host due to insufficient memory ");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(tempHost->hostName, hostName);
|
||||
tempHost->child = NULL;
|
||||
tempHost->next = NULL;
|
||||
|
||||
// Now add the new host to the existing store
|
||||
if( hostList == NULL )
|
||||
hostList = tempHost;
|
||||
else
|
||||
{ // Add new host at the end
|
||||
for(t=hostList; t->next ; t=t->next);
|
||||
|
||||
t->next = tempHost;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// invoked from outside...
|
||||
int DataManager::ModifyHost(char *oldHostName, char *newHostName)
|
||||
{
|
||||
if( !oldHostName || !newHostName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Null parameters passed....");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
for(Host *t=hostList; t ; t=t->next)
|
||||
{
|
||||
if( STRCMPI(oldHostName, t->hostName) == 0 )
|
||||
{
|
||||
free(t->hostName);
|
||||
t->hostName = (char*) malloc( strlen(newHostName) + 1 );
|
||||
|
||||
if( !t->hostName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Failed to modify host entry due to insufficient memory ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
strcpy(t->hostName, newHostName);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified hostname[%s] is not present ", oldHostName);
|
||||
return FPM_FALSE;
|
||||
|
||||
}
|
||||
|
||||
int DataManager::AddHost(Host *host)
|
||||
{
|
||||
|
||||
Host *t;
|
||||
|
||||
if( host == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : host is NULL....");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
for(t=hostList; t ; t=t->next)
|
||||
{
|
||||
if( STRCMPI(host->hostName, t->hostName) == 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Specified hostname %s is already present..", host->hostName);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Host *newHost = DuplicateHost(host);
|
||||
|
||||
if( newHost == NULL)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Insufficient memory");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
// Add the new host at the end of the list...
|
||||
if( hostList == NULL )
|
||||
hostList = newHost;
|
||||
else
|
||||
{
|
||||
for(t=hostList; t->next ; t=t->next);
|
||||
|
||||
t->next = newHost;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n AddHost : Host %s added successfully", newHost->hostName);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DataManager::ModifyHost(Host *host)
|
||||
{
|
||||
Host *prev = NULL;
|
||||
|
||||
if( host == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : host is NULL....");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// check if the specified host is present
|
||||
// If present remove it and add new host ...
|
||||
for(Host *t=hostList; t ; prev=t,t=t->next)
|
||||
{
|
||||
if( STRCMPI(host->hostName, t->hostName) == 0 )
|
||||
{
|
||||
Host *newHost = DuplicateHost(host);
|
||||
|
||||
if( newHost == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Insufficient memory");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
// if this is the first node
|
||||
if( hostList == t )
|
||||
{
|
||||
hostList = newHost;
|
||||
newHost->next = t->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->next = newHost;
|
||||
newHost->next = t->next;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n ModifyHost : Host %s modified successfully", newHost->hostName);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Specified host %s is not present", host->hostName);
|
||||
|
||||
return FPM_HOSTNAME_NOT_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//invoked from outside
|
||||
int DataManager::RemoveHost(char *hostName)
|
||||
{
|
||||
Host *prev = NULL;
|
||||
|
||||
if( !hostName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Host name is Null ....");
|
||||
return FPM_ILLEGAL_HOSTNAME;
|
||||
}
|
||||
|
||||
// Find out and destroy it..!
|
||||
for(Host *t=hostList; t ; prev=t,t=t->next)
|
||||
{
|
||||
if( STRCMPI(hostName, t->hostName) == 0 )
|
||||
{
|
||||
// if this is the first node
|
||||
if( hostList == t )
|
||||
hostList = t->next;
|
||||
else
|
||||
prev->next = t->next;
|
||||
|
||||
free(t->hostName);
|
||||
free(t);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified hostname[%s] is not present ", hostName);
|
||||
|
||||
return FPM_HOSTNAME_NOT_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
Host* DataManager::DuplicateHost(Host *host)
|
||||
{
|
||||
HostElement *prev = NULL;
|
||||
HostElement *t, *temp;
|
||||
|
||||
Host *newHost = (Host *) malloc(sizeof(Host));
|
||||
|
||||
if( newHost )
|
||||
newHost->hostName = (char*) malloc(strlen(host->hostName) + 1);
|
||||
|
||||
if( !newHost || !newHost->hostName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DuplicateHost : Insufficient memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(newHost->hostName, host->hostName);
|
||||
newHost->child = NULL;
|
||||
newHost->next = NULL;
|
||||
|
||||
for(t=host->child; t ; t = t->next)
|
||||
{
|
||||
HostElement *nh = (HostElement*) malloc(sizeof(HostElement));
|
||||
|
||||
if( nh )
|
||||
{
|
||||
nh->name = (char*) malloc(strlen(t->name) + 1 );
|
||||
nh->value = (char*) malloc(strlen(t->value) + 1);
|
||||
}
|
||||
|
||||
if( !nh || !nh->name || !nh->value)
|
||||
goto duplicate_error;
|
||||
|
||||
nh->isPassword = t->isPassword;
|
||||
strcpy(nh->name, t->name);
|
||||
strcpy(nh->value, t->value);
|
||||
nh->next = NULL;
|
||||
|
||||
if( prev == NULL )
|
||||
newHost->child = nh;
|
||||
else
|
||||
prev->next = nh;
|
||||
|
||||
prev = nh;
|
||||
}
|
||||
|
||||
|
||||
return newHost;
|
||||
|
||||
duplicate_error:
|
||||
|
||||
// cleanup partially loaded data
|
||||
for(t=newHost->child; t ; )
|
||||
{
|
||||
if(t->name) free(t);
|
||||
if(t->value) free(t);
|
||||
|
||||
temp = t;
|
||||
t = t->next;
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
if(newHost->hostName)
|
||||
free(newHost->hostName);
|
||||
|
||||
free(newHost);
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n DuplicateHost : Insufficient memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DataManager::PrintAllHosts()
|
||||
{
|
||||
PrintMessage(MESG_PRINT, "\n\n List of hosts ");
|
||||
|
||||
for(Host *t=hostList; t ; t=t->next)
|
||||
{
|
||||
PrintMessage(MESG_PRINT, "\n\n %s", t->hostName);
|
||||
for(HostElement *h=t->child; h ; h= h->next)
|
||||
{
|
||||
PrintMessage(MESG_PRINT, "\n %s : %s ", h->name, h->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int DataManager::AddHostElement(char *hostName, char *name, char *value, unsigned char isPassword)
|
||||
{
|
||||
Host *host;
|
||||
HostElement *h, *t;
|
||||
|
||||
|
||||
if( !hostName || !name || !value)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Null parameters passed....");
|
||||
return FPM_SIGNON_FILE_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
||||
// First find the specified host
|
||||
for(host = hostList; host ; host = host->next)
|
||||
{
|
||||
if( STRCMPI(hostName, host->hostName) == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if( !host )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified hostname[%s] is not present ", hostName);
|
||||
return FPM_HOSTNAME_NOT_PRESENT;
|
||||
}
|
||||
|
||||
// check if specified name/value pair exist already....
|
||||
for(h = host->child; h ; h=h->next)
|
||||
{
|
||||
if( (STRCMPI(h->name,name) == 0 ) && (strcmp(h->value, value) == 0 ) )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified name/value [%s/%s]pair is already present ", name,value);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
HostElement *temp = (HostElement *) malloc(sizeof(HostElement));
|
||||
if( temp )
|
||||
{
|
||||
temp->name = (char*) malloc( strlen(name)+1 );
|
||||
temp->value = (char*) malloc( strlen( value) + 1 );
|
||||
}
|
||||
|
||||
if( !temp || !temp->name || !temp->value )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Failed to add name/value due to insufficient memory ");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(temp->name,name);
|
||||
strcpy(temp->value, value);
|
||||
temp->isPassword = isPassword;
|
||||
temp->next = NULL;
|
||||
|
||||
// Now add it to the host...
|
||||
if( host->child == NULL )
|
||||
{
|
||||
host->child = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(t = host->child; t->next ; t=t->next);
|
||||
|
||||
t->next = temp;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
// invoked from outside..
|
||||
int DataManager::RemoveHostElement(char *hostName, char *value)
|
||||
{
|
||||
|
||||
Host *host;
|
||||
|
||||
if( !hostName || !value )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Null parameters passed....");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// First find the specified hot
|
||||
for(host = hostList; host; host = host->next)
|
||||
{
|
||||
if( STRCMPI(hostName, host->hostName) == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
if( !host )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n DataManager : Specified hostname[%s] is not present ", hostName);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
HostElement *prev = host->child;
|
||||
for(HostElement *h = host->child; h ;prev=h, h=h->next)
|
||||
{
|
||||
if( strcmp(h->value, value) == 0 )
|
||||
{
|
||||
|
||||
if( host->child == h )
|
||||
host->child = h->next;
|
||||
else
|
||||
prev->next = h->next;
|
||||
|
||||
free(h->value);
|
||||
free(h->name);
|
||||
free(h);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
// internal
|
||||
int DataManager::RemoveAllData()
|
||||
{
|
||||
|
||||
RemoveAllRejectHosts();
|
||||
RemoveAllHosts();
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
int DataManager::RemoveAllRejectHosts()
|
||||
{
|
||||
RejectHost *t = rejectHostList;
|
||||
RejectHost *temp;
|
||||
|
||||
for( ; t; )
|
||||
{
|
||||
temp = t;
|
||||
t= t->next;
|
||||
RemoveRejectHost(temp->hostName);
|
||||
}
|
||||
|
||||
rejectHostList = NULL;
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
int DataManager::RemoveAllHosts()
|
||||
{
|
||||
Host *t = hostList;
|
||||
Host *temp;
|
||||
|
||||
for( ; t ; )
|
||||
{
|
||||
temp = t;
|
||||
t = t->next;
|
||||
|
||||
RemoveHost(temp->hostName);
|
||||
}
|
||||
|
||||
hostList = NULL;
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
65
adlib/ad_ff/native/DataManager.h
Normal file
65
adlib/ad_ff/native/DataManager.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef __FPM_DATA_MANAGER_H__
|
||||
#define __FPM_DATA_MANAGER_H__
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
|
||||
|
||||
class DataManager
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Host *hostList;
|
||||
RejectHost *rejectHostList;
|
||||
|
||||
DataManager();
|
||||
virtual ~DataManager();
|
||||
|
||||
int AddRejectHost(char *hostName);
|
||||
int RemoveRejectHost(char *hostName);
|
||||
void PrintAllRejectHosts();
|
||||
|
||||
|
||||
int AddHost(char *hostName);
|
||||
int AddHost(Host *host);
|
||||
int ModifyHost(struct Host *host);
|
||||
int ModifyHost(char *oldHostName, char *newHostName);
|
||||
int RemoveHost(char *hostName);
|
||||
void PrintAllHosts();
|
||||
|
||||
int AddHostElement(char *hostName, char *name, char *value, unsigned char isPassword);
|
||||
int RemoveHostElement(char *hostName, char *clearValue);
|
||||
Host* DuplicateHost(Host *host);
|
||||
|
||||
int RemoveAllData();
|
||||
int RemoveAllRejectHosts();
|
||||
int RemoveAllHosts();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
727
adlib/ad_ff/native/FirefoxPasswordManager.cpp
Normal file
727
adlib/ad_ff/native/FirefoxPasswordManager.cpp
Normal file
@@ -0,0 +1,727 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
#include "ProfileManager.h"
|
||||
|
||||
|
||||
ProfileManager profileManager[MAX_PROFILE_COUNT];
|
||||
int profileCount = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if firefox is there on the system
|
||||
*
|
||||
* @return 1 if firefox libraries are present
|
||||
* 0 otherwise
|
||||
*
|
||||
* It loads the libraries from the firefox library path and if they are loaded
|
||||
* successfully then that indicates that firefox is present.
|
||||
*
|
||||
*/
|
||||
extern "C" APIEXPORT int FPM_IsStoreAvailable()
|
||||
{
|
||||
ProfileManager pm;
|
||||
return pm.IsStoreAvailable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Gets the list of profile names...
|
||||
*
|
||||
* @param[in/out] profiles pointer to array of profile names
|
||||
* @param[in/out] profileFlag Indicates if default profile or not.
|
||||
* @return count count of profiles
|
||||
* 0 no profiles found
|
||||
* < 0 on error
|
||||
*
|
||||
* If one or more profiles found then profiles array is filled with
|
||||
* the profile names and count of profiles is returned. ProfileFlag[]
|
||||
* array is filled with 1 or 0 to indicate if the respective profile
|
||||
* is default profile or not.If no profiles found then value 0 is
|
||||
* returned and negative values is returned if there is an error.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFlag[])
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
char profileDir[MAX_PATH] = "";
|
||||
char partialPath[] = "Application Data\\Mozilla\\Firefox";
|
||||
char profilePath[MAX_PATH];
|
||||
char line[1024];
|
||||
|
||||
DWORD pathSize = MAX_PATH;
|
||||
char *finalProfilePath = NULL;
|
||||
int profileCount = 0;
|
||||
unsigned int i;
|
||||
HANDLE token;
|
||||
|
||||
|
||||
// Get current user's profile directory
|
||||
if( OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == FALSE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Failed to get current process token ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
if( GetUserProfileDirectory(token, profileDir, &pathSize) == FALSE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Failed to get user profile directory");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetProfileList : User Profile directory = %s", profileDir);
|
||||
|
||||
// Get firefox profile directory
|
||||
strcpy(profilePath, profileDir);
|
||||
strcat(profilePath,"\\");
|
||||
strcat(profilePath,partialPath);
|
||||
strcat(profilePath,"\\profiles.ini");
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetProfileList : Firefox profile dir path = %s ", profilePath);
|
||||
|
||||
|
||||
#else // Linux platform....
|
||||
|
||||
char profileDir[] ="/.mozilla/firefox";
|
||||
char profileFile[] ="/.mozilla/firefox/profiles.ini";
|
||||
|
||||
char line[1024];
|
||||
char *profilePath = NULL;
|
||||
char *homeDir = NULL;
|
||||
char *finalProfilePath = NULL;
|
||||
int profileCount = 0;
|
||||
unsigned int i;
|
||||
|
||||
// Get home directory
|
||||
homeDir = getenv("HOME");
|
||||
|
||||
if(homeDir == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Unable to get home directory ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
profilePath = (char*) malloc( strlen(homeDir) + strlen(profileFile) + 3 );
|
||||
if( profilePath == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Insufficient memory ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
strcpy(profilePath,homeDir);
|
||||
strcat(profilePath,profileFile);
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetProfileList : Firefox profile dir path = %s ", profilePath);
|
||||
|
||||
#endif
|
||||
|
||||
// Open the firefox profile setting file
|
||||
FILE *profile = fopen(profilePath, "r");
|
||||
|
||||
if( profile == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Unable to find firefox profile file : %s ", profilePath);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// First find out the count of profiles....
|
||||
profileCount = 0;
|
||||
while(fgets(line, 1024, profile))
|
||||
{
|
||||
// Remove trailing end of line character
|
||||
line[strlen(line)-1]= 0;
|
||||
|
||||
// Convert to smaller case until "=" found....
|
||||
for(i=0; i<strlen(line); i++)
|
||||
{
|
||||
if( line[i] == '=' )
|
||||
break;
|
||||
|
||||
if( line[i] >=65 && line[i]<=90 )
|
||||
line[i]+=32;
|
||||
}
|
||||
|
||||
if( strstr(line, "name=") != NULL )
|
||||
profileCount++;
|
||||
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetProfileList : Total profiles found = %d ", profileCount);
|
||||
|
||||
if( profileCount == 0 )
|
||||
{
|
||||
fclose(profile);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
*profileList = ( char**) malloc(profileCount * sizeof (char *));
|
||||
*profileFlag = ( int * ) malloc(profileCount * sizeof(int));
|
||||
|
||||
if( *profileList == NULL || *profileFlag == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Insufficient memory ");
|
||||
fclose(profile);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
char **profList = *profileList;
|
||||
int *profFlag = *profileFlag;
|
||||
|
||||
// Now read the profile names and store it..
|
||||
fseek(profile, 0, SEEK_SET);
|
||||
|
||||
profileCount = 0;
|
||||
while(fgets(line, 1024, profile))
|
||||
{
|
||||
// Remove trailing end of line character
|
||||
line[strlen(line)-1]= 0;
|
||||
|
||||
// Convert to smaller case until "=" found....
|
||||
for(i=0; i<strlen(line); i++)
|
||||
{
|
||||
if( line[i] == '=' )
|
||||
break;
|
||||
|
||||
if( line[i] >=65 && line[i]<=90 )
|
||||
line[i]+=32;
|
||||
}
|
||||
|
||||
if( strstr(line, "name=") != NULL )
|
||||
{
|
||||
char *temp = strchr(line,'=') + 1;
|
||||
profList[profileCount] = (char*) malloc(strlen(temp)+1);
|
||||
|
||||
if( profList[profileCount] == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetProfileList : Insufficient memory ");
|
||||
fclose(profile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(profList[profileCount],temp);
|
||||
profFlag[profileCount] = 0;
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetProfileList : Found profile = [%s]", profList[profileCount]);
|
||||
profileCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if the current profile is default
|
||||
if( strstr(line, "default=1") != NULL )
|
||||
{
|
||||
profFlag[profileCount-1] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(profile);
|
||||
|
||||
// if there is only one profile then set it default profile
|
||||
if( profileCount == 1 )
|
||||
{
|
||||
**profileFlag = 1;
|
||||
}
|
||||
|
||||
return profileCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the firefox library with the specified profile
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @return 1 on success
|
||||
* <=0 on error
|
||||
*
|
||||
* It initializes the firefox library with the specified profile. This must be called before
|
||||
* invoking any operation on the specified profile.
|
||||
* It performs following tasks
|
||||
* * Determine firefox profile directory
|
||||
* * Loads the firefox security libraries.
|
||||
* * Initializes the firefox security library for the profile.
|
||||
*
|
||||
* If the mentioned profile is not found then FPM_PROFILE_NOT_PRESENT will be returned. If there is
|
||||
* an error in loading or initializing the firefox library then FPM_LIBRARY_LOAD_FAILED or FPM_LIBRARY_INIT_FAILED
|
||||
* is returned. If user has not enabled "remember passwords" then certain files (key3.db, cert8.db) required for
|
||||
* initialization will not be present in the profile directory. This can cause FPM_LIBRARY_INIT_FAILED error.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName)
|
||||
{
|
||||
int retValue;
|
||||
int profileIndex = -1;
|
||||
|
||||
// Check if the object for specified profile already present...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n FirefoxProfileInit : Object for specified profile %s exist ", profileName);
|
||||
profileIndex = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is new profile...
|
||||
if( profileIndex == -1)
|
||||
{
|
||||
if( (profileCount + 1) >= MAX_PROFILE_COUNT)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Max profile count exceeded.");
|
||||
return FPM_PROFILE_LIMIT_EXCEEDED;
|
||||
}
|
||||
|
||||
profileIndex = profileCount;
|
||||
profileCount++;
|
||||
}
|
||||
|
||||
// check if the profile is already initialized...
|
||||
if( profileManager[profileIndex].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n FirefoxProfileInit : Specified profile %s is already initialized", profileName);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
if( (retValue = profileManager[profileIndex].ProfileInit(profileName)) != FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Failed to initialize the profile %s ", profileName);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n FirefoxProfileInit : Firefox profile %s initialized successfully ", profileName);
|
||||
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Uninitializes the specified profile.
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @return 1 on success
|
||||
* <=0 on error
|
||||
*
|
||||
* Uninitializes the specified profile and unloads the firefox security library.
|
||||
* It also cleans up internal data structure.
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_FirefoxProfileExit(char *profileName)
|
||||
{
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n FirefoxProfileExit : Exiting the firefox profile %s ", profileName);
|
||||
profileManager[i].ProfileExit();
|
||||
return FPM_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n FirefoxProfileExit : Specified profile %s is not initialized , cannot exit the profile", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n FirefoxProfileExit : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies if master passsword is set for the specified profile
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @return 1 if master password is set
|
||||
* 0 if master password not set
|
||||
*
|
||||
* Checks if the master password is set or not for the specified profile. The application can
|
||||
* use this function to determine if the user has set the master password. If so it can prompt
|
||||
* the user to enter the master password.
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_IsMasterPasswordSet(char *profileName)
|
||||
{
|
||||
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : invoking IsMasterPasswordSet for profile %s", profileName);
|
||||
return profileManager[i].IsMasterPasswordSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsMasterPasswordSet : Specified profile %s is not initialized ", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n IsMasterPasswordSet : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the master password is correct for the specified profile.
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @param masterPassword Master password to be checked.
|
||||
* @return 1 if the specified master password is correct
|
||||
* 0 if the master password is wrong.
|
||||
*
|
||||
*
|
||||
* Check if the specified master password is correct or not. If it is
|
||||
* correct then password is stored to the internal store for later use.
|
||||
* If it is wrong then nothing is stored and 0 will be returned.
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_CheckMasterPassword(char *profileName, char *masterPassword)
|
||||
{
|
||||
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n CheckMasterPassword : invoking CheckMasterPassword for profile %s", profileName);
|
||||
return profileManager[i].CheckMasterPassword(masterPassword, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CheckMasterPassword : Specified profile %s is not initialized ", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n CheckMasterPassword : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the signon data from the firefox signon file for specified profile
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @param struct Host** pointer to list of signon host structure
|
||||
* @param doRefresh signon data to be refreshed or not
|
||||
* @return 1 success
|
||||
* <= 0 If an error has occurred.
|
||||
*
|
||||
* Returns the pointer to the internal signon data store which contains list of hosts
|
||||
* and associated name/value pairs. If doRefresh value is positive then fresh signon
|
||||
* data is loaded from the signon file. Otherwise current signon data is returned.
|
||||
*
|
||||
* If the master password is set and its not specified or wrong password is specified
|
||||
* then error code FPM_MASTERPASSWORD_WRONG will be returned. In this case use
|
||||
* CheckMasterPassword function to set the correct master password and then call this
|
||||
* function again.
|
||||
*
|
||||
* In case of error in reading signon information FPM_SIGNON_FILE_READ_ERROR or
|
||||
* FPM_SIGNON_FILE_NOT_PRESENT will be returned.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
extern "C" APIEXPORT int FPM_GetSignonData(char *profileName,struct Host **host, int doRefresh)
|
||||
{
|
||||
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n GetSignonData : invoking GetSignonData for profile %s", profileName);
|
||||
return profileManager[i].GetSignonData(host, doRefresh);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetSignonData : Specified profile %s is not initialized", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n GetSignonData : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the firefox signon file with new signon data.
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @return 1 If signon data written to the disk successfully
|
||||
* <=0 If an error has occurred.
|
||||
*
|
||||
* Writes the signon data from the internal signon data store to the disk. If an
|
||||
* error occurs then proper error code will be returned. If the master password is set
|
||||
* and its not specified or wrong password is specified then error code FPM_MASTERPASSWORD_WRONG
|
||||
* will be returned. In this case use CheckMasterPassword function to set the correct
|
||||
* master password and then call this function again.
|
||||
*
|
||||
* In case of write error, error code FPM_SIGNON_FILE_WRITE_ERROR will be returned.
|
||||
*
|
||||
* If the signon file is locked then error code FPM_SIGNON_FILE_LOCKED will be
|
||||
* returned. In this case application should ask the user to close the firefox
|
||||
* application and then it should call this function again.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_WriteSignonData(char *profileName)
|
||||
{
|
||||
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n WriteSignonData : invoking WriteSignonData for profile %s", profileName);
|
||||
return profileManager[i].WriteSignonData();
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Specified profile %s is not initialized", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds signon data for new host...
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @param struct Host* pointer to host structure to be added
|
||||
* @param doUpdate signon data to be written to the file or not
|
||||
* @return 1 success
|
||||
* <=0 error
|
||||
*
|
||||
* Adds the specified host information to the internal signon data store. If the
|
||||
* value of doUpdate is positive then the entire signon data is written to the file.
|
||||
* Otherwise changes are done only in the internal data store.
|
||||
*
|
||||
* If doUpdate is positive then error code may be from FPM_WriteSignonData function.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
extern "C" APIEXPORT int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
|
||||
{
|
||||
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n AddHost : invoking AddHost for profile %s", profileName);
|
||||
return profileManager[i].AddHost(host, doUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Specified profile %s is not initialized", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the credentials for the specified host url for specified profile.
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @param struct Host* pointer to host structure to be modified.
|
||||
* @param doUpdate signon data to be written to the file or not
|
||||
* @return 1 success
|
||||
* <=0 error
|
||||
*
|
||||
* Modifes the values of the specified host with new values. If the value
|
||||
* of doUpdate is positive then the entire signon data is written to the file.
|
||||
* Otherwise changes are done only in the internal data store. If any of
|
||||
* the names ( name/value pairs ) is not matched with the existing name in the
|
||||
* Host's username/password list then error FPM_NAME_NOT_PRESENT is returned.
|
||||
*
|
||||
* If doUpdate is positive then error code may be from FPM_WriteSignonData function.
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C" APIEXPORT int FPM_ModifyHost(char *profileName, struct Host *host, int doUpdate)
|
||||
{
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ModifyHost : invoking ModifyHost for profile %s", profileName);
|
||||
return profileManager[i].ModifyHost(host, doUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Specified profile %s is not initialized", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the signon credentials for specified host
|
||||
*
|
||||
* @param profileName name of the profile
|
||||
* @param hostName complete URL of the host name
|
||||
* @param doUpdate signon data to be written to the file or not
|
||||
*
|
||||
* @return 1 on success
|
||||
* <=0 on error
|
||||
*
|
||||
* Removes the specified host from the internal signon data store. All
|
||||
* name-value pairs associated with specified host will also be removed.
|
||||
* If the value of doUpdate is positive then the entire signon data is
|
||||
* written to the file. Otherwise changes are done only in the internal data store.
|
||||
*
|
||||
* If doUpdate is positive then error code may be from FPM_WriteSignonData function.
|
||||
*
|
||||
*/
|
||||
extern "C" APIEXPORT int FPM_RemoveHost(char *profileName, char *hostName, int doUpdate)
|
||||
{
|
||||
// Find the profile...
|
||||
for(int i=0; i< profileCount; i++)
|
||||
{
|
||||
if( profileManager[i].profileName != NULL )
|
||||
{
|
||||
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
|
||||
{
|
||||
// check if its initialized
|
||||
if( profileManager[i].isInitialized == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n RemoveHost : invoking RemoveHost for profile %s", profileName);
|
||||
return profileManager[i].RemoveHost(hostName, doUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n RemoveHost : Specified profile %s is not initialized", profileName);
|
||||
return FPM_PROFILE_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintMessage(MESG_ERROR, "\n RemoveHost : Specified profile %s is not found", profileName);
|
||||
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
186
adlib/ad_ff/native/FirefoxPasswordManager.h
Normal file
186
adlib/ad_ff/native/FirefoxPasswordManager.h
Normal file
@@ -0,0 +1,186 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef __FPM_Firefox_Password_MANAGER_H__
|
||||
#define __FPM_Firefox_Password_MANAGER_H__
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <userenv.h>
|
||||
#pragma comment(lib,"userenv.lib")
|
||||
|
||||
#define STRCMPI strcmpi
|
||||
#define APIEXPORT __declspec(dllexport)
|
||||
|
||||
#define NSS_LIBRARY_NAME "nss3.dll"
|
||||
#define PLC_LIBRARY_NAME "plc4.dll"
|
||||
#define NSPR_LIBRARY_NAME "nspr4.dll"
|
||||
#define PLDS_LIBRARY_NAME "plds4.dll"
|
||||
#define SOFTN_LIBRARY_NAME "softokn3.dll"
|
||||
|
||||
#define LOADLIBRARY(x) LoadLibrary(x)
|
||||
#define GETPROCADDRESS GetProcAddress
|
||||
#define FREELIBRARY FreeLibrary
|
||||
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#define STRCMPI strcasecmp
|
||||
#define APIEXPORT
|
||||
|
||||
#define NSS_LIBRARY_NAME "libnss3.so"
|
||||
#define PLC_LIBRARY_NAME "libplc4.so"
|
||||
#define NSPR_LIBRARY_NAME "libnspr4.so"
|
||||
#define PLDS_LIBRARY_NAME "libplds4.so"
|
||||
#define SOFTN_LIBRARY_NAME "libsoftokn3.so"
|
||||
|
||||
#define LOADLIBRARY(x) dlopen(x, RTLD_LAZY) // alternative : RTLD_NOW
|
||||
#define GETPROCADDRESS dlsym
|
||||
#define FREELIBRARY dlclose
|
||||
|
||||
#define HMODULE void *
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define FPM_TRUE 1
|
||||
#define FPM_FALSE 0
|
||||
|
||||
#define MESG_DEBUG 0
|
||||
#define MESG_PRINT 1
|
||||
#define MESG_ERROR 2
|
||||
|
||||
#define MAX_PROFILE_COUNT 5
|
||||
|
||||
//#define DEBUG 11
|
||||
|
||||
#define Unichar unsigned int
|
||||
|
||||
#define HEADER_VERSION "#2c"
|
||||
#define CRYPT_PREFIX "~"
|
||||
|
||||
#define SIGNON_FILE_NAME "signons.txt"
|
||||
|
||||
// Internal structure declaration taken from firefox.....
|
||||
typedef enum SECItemType
|
||||
{
|
||||
siBuffer = 0,
|
||||
siClearDataBuffer = 1,
|
||||
siCipherDataBuffer = 2,
|
||||
siDERCertBuffer = 3,
|
||||
siEncodedCertBuffer = 4,
|
||||
siDERNameBuffer = 5,
|
||||
siEncodedNameBuffer = 6,
|
||||
siAsciiNameString = 7,
|
||||
siAsciiString = 8,
|
||||
siDEROID = 9,
|
||||
siUnsignedInteger = 10,
|
||||
siUTCTime = 11,
|
||||
siGeneralizedTime = 12
|
||||
};
|
||||
|
||||
//typedef struct SECItemStr SECItem;
|
||||
|
||||
struct SECItem
|
||||
{
|
||||
SECItemType type;
|
||||
unsigned char *data;
|
||||
unsigned int len;
|
||||
};
|
||||
|
||||
|
||||
typedef enum SECStatus
|
||||
{
|
||||
SECWouldBlock = -2,
|
||||
SECFailure = -1,
|
||||
SECSuccess = 0
|
||||
};
|
||||
|
||||
// For some PR type varialbes...just to remove gecko-sdk dependency
|
||||
// following is added here.
|
||||
#define PRBool int
|
||||
#define PRUint32 unsigned int
|
||||
#define PR_TRUE 1
|
||||
#define PR_FALSE 0
|
||||
|
||||
|
||||
|
||||
// End
|
||||
|
||||
|
||||
|
||||
typedef struct PK11SlotInfoStr PK11SlotInfo;
|
||||
|
||||
// NSS Library functions
|
||||
//typedef char *(PR_CALLBACK *PK11PasswordFunc)(PK11SlotInfo *slot, PRBool retry, void *arg);
|
||||
typedef SECStatus (*NSS_Init) (const char *configdir);
|
||||
typedef SECStatus (*NSS_Shutdown) (void);
|
||||
//typedef void (*PK11_SetPasswordFunc) (PK11PasswordFunc func);
|
||||
typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void);
|
||||
typedef void (*PK11_FreeSlot) (PK11SlotInfo *slot);
|
||||
typedef SECStatus (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
|
||||
typedef SECStatus (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw);
|
||||
typedef SECStatus (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx);
|
||||
typedef SECStatus (*PK11SDR_Encrypt) (SECItem *keyid, SECItem *data, SECItem *result, void *cx);
|
||||
|
||||
// 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);
|
||||
|
||||
void PrintMessage( int level, char *mesg , ...);
|
||||
int IsDirectoryExists( char *path );
|
||||
void StrLwr(char *str);
|
||||
|
||||
|
||||
|
||||
// Profile initiliazation functions
|
||||
extern "C" APIEXPORT int FPM_IsStoreAvailable();
|
||||
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int **profileFlag);
|
||||
extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName);
|
||||
extern "C" APIEXPORT int FPM_FirefoxProfileExit(char *profileName);
|
||||
|
||||
// Master password functions
|
||||
extern "C" APIEXPORT int FPM_IsMasterPasswordSet(char *profileName);
|
||||
extern "C" APIEXPORT int FPM_CheckMasterPassword(char *profileName, char *masterPassword);
|
||||
|
||||
// Signon data update functions
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
123
adlib/ad_ff/native/Makefile.am
Normal file
123
adlib/ad_ff/native/Makefile.am
Normal file
@@ -0,0 +1,123 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS =
|
||||
DIST_SUBDIRS =
|
||||
|
||||
EXTRA_DIST = $(CXXFILES) *.h
|
||||
|
||||
CASAROOT = ../../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
BUILD_VER = 1.1.1
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
CXX = g++
|
||||
|
||||
MODULE_NAME =libad_ff
|
||||
MODULE_EXT =so
|
||||
|
||||
CXXFILES = $(srcdir)/Common.cpp \
|
||||
$(srcdir)/CryptManager.cpp \
|
||||
$(srcdir)/FirefoxPasswordManager.cpp \
|
||||
$(srcdir)/ProfileManager.cpp \
|
||||
$(srcdir)/SignonManager.cpp \
|
||||
$(srcdir)/DataManager.cpp
|
||||
|
||||
|
||||
CXXFILES_CXX :=
|
||||
INCLUDES = -I. -I.. -I$(CASAROOT)/include \
|
||||
-I/opt/gnome/include/gnome-keyring-1
|
||||
CXXFLAGS = $(CPP_LIBFLAG) $(INCLUDES)
|
||||
EXTRA_CXXFLAGS = -fPIC -DPIC -DSSCS_LINUX_PLAT_F -DQT_THREAD_SUPPORT -DQT_CLEAN_NANESPACE \
|
||||
-DQT_NO_ASCII_CAS -O2 -fmessage-length=0 -Wall -g -D_REENTRANT \
|
||||
-DALIGNMENT -DN_PLAT_UNIX -DUNIX -DLINUX -DIAPX386
|
||||
CXX_RESOURCES =
|
||||
LIBS = -lpthread -ldl -L/opt/kde3/lib
|
||||
LDFLAGS = -fno-exception -fno-check-new -Wl,-Bsymbolic -shared -pthread -O2 \
|
||||
-Wl,-soname -Wl,libkwallets_rw.so.1
|
||||
|
||||
EXTRA_LDFLAGS = -L/usr/$(LIB) -lqt-mt -L/usr/X11R6/$(LIB) -L/usr/lib/qt3/$(LIB)
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/, $(CXXFILES:%.cpp=%.o))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $@ $<
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER): $(OBJDIR) $(OBJS)
|
||||
@echo [======== Linking $@ ========]
|
||||
c++ -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(LIBS)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
ln -sf $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).1
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
984
adlib/ad_ff/native/ProfileManager.cpp
Normal file
984
adlib/ad_ff/native/ProfileManager.cpp
Normal file
@@ -0,0 +1,984 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include "ProfileManager.h"
|
||||
|
||||
|
||||
|
||||
// Private functions....
|
||||
|
||||
ProfileManager::ProfileManager()
|
||||
{
|
||||
isInitialized = 0;
|
||||
libnss = NULL;
|
||||
libplc = NULL;
|
||||
|
||||
profileName = NULL;
|
||||
profilePath = NULL;
|
||||
libraryPath = NULL;
|
||||
masterPassword = NULL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
char * ProfileManager::GetFirefoxProfilePath(char *profileName)
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
char profileDir[MAX_PATH] = "";
|
||||
char partialPath[] = "Application Data\\Mozilla\\Firefox";
|
||||
char profilePath[MAX_PATH];
|
||||
char line[1024];
|
||||
|
||||
DWORD pathSize = MAX_PATH;
|
||||
char *finalProfilePath = NULL;
|
||||
unsigned int i;
|
||||
HANDLE token;
|
||||
|
||||
|
||||
// Get current user's profile directory
|
||||
if( OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == FALSE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Failed to get current process token ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( GetUserProfileDirectory(token, profileDir, &pathSize) == FALSE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Failed to get user profile directory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxProfilePath : User Profile directory = %s", profileDir);
|
||||
|
||||
// Get firefox profile directory
|
||||
strcpy(profilePath, profileDir);
|
||||
strcat(profilePath,"\\");
|
||||
strcat(profilePath,partialPath);
|
||||
strcat(profilePath,"\\profiles.ini");
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxProfilePath : Firefox profile.ini path = %s ", profilePath);
|
||||
|
||||
|
||||
#else // Linux platform....
|
||||
|
||||
char profileDir[] ="/.mozilla/firefox";
|
||||
char profileFile[] ="/.mozilla/firefox/profiles.ini";
|
||||
|
||||
char line[1024];
|
||||
char *profilePath = NULL;
|
||||
char *homeDir = NULL;
|
||||
char *finalProfilePath = NULL;
|
||||
unsigned int i;
|
||||
|
||||
// Get home directory
|
||||
homeDir = getenv("HOME");
|
||||
|
||||
if(homeDir == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Unable to get home directory ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
profilePath = (char*) malloc( strlen(homeDir) + strlen(profileFile) + 3 );
|
||||
if( profilePath == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Insufficient memory ");
|
||||
return 0;
|
||||
}
|
||||
strcpy(profilePath,homeDir);
|
||||
strcat(profilePath,profileFile);
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxProfilePath : Firefox profile dir path = %s ", profilePath);
|
||||
|
||||
#endif
|
||||
|
||||
// Open the firefox profile setting file
|
||||
FILE *profile = fopen(profilePath, "r");
|
||||
|
||||
if( profile == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Unable to find firefox profile file : %s ", profilePath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Find out the profile path for given profile name
|
||||
char *temp;
|
||||
int isProfileFound = 0;
|
||||
int isRelative = 1;
|
||||
char *path = NULL;
|
||||
|
||||
while(fgets(line, 1024, profile))
|
||||
{
|
||||
// Remove trailing end of line character
|
||||
line[strlen(line)-1]= 0;
|
||||
|
||||
// Convert to smaller case until "=" found....
|
||||
for(i=0; i<strlen(line); i++)
|
||||
{
|
||||
if( line[i] == '=' )
|
||||
break;
|
||||
|
||||
if( line[i] >=65 && line[i]<=90 )
|
||||
line[i]+=32;
|
||||
}
|
||||
|
||||
if( isProfileFound )
|
||||
{
|
||||
|
||||
temp = strchr(line,'=') + 1;
|
||||
|
||||
// check for IsRelative=
|
||||
if( strstr(line, "isrelative=") != NULL )
|
||||
{
|
||||
// Is the value greater than 0 ( ascii 48 )
|
||||
isRelative = (*temp > 48)? 1 : 0 ;
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for Path=
|
||||
if( strstr(line, "path=") != NULL )
|
||||
{
|
||||
path = (char*) malloc(strlen(temp) + 1);
|
||||
if( !path )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Insufficient memory ");
|
||||
fclose(profile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(path,temp);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Break once you encounter next profile
|
||||
if( strstr(line, "profile") != NULL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( strstr(line, "name=") != NULL )
|
||||
{
|
||||
temp = strchr(line,'=') + 1;
|
||||
|
||||
if( STRCMPI(temp, profileName) == 0 )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxProfilePath : Profile name [%s] found ", profileName);
|
||||
isProfileFound = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fclose(profile);
|
||||
|
||||
if( !isProfileFound )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Specified Profile [%s] not present ", profileName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !path )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Profile [%s] path not found ", profileName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( isRelative )
|
||||
{
|
||||
#ifdef WIN32
|
||||
// if path contains '/' then make it '\\'
|
||||
char *slash = strstr(path,"/");
|
||||
|
||||
if( slash != NULL )
|
||||
*slash = '\\';
|
||||
|
||||
int totalLen = strlen(profileDir) + strlen(partialPath) + strlen(path) + 3 ;
|
||||
finalProfilePath = (char *) malloc(totalLen);
|
||||
|
||||
if( finalProfilePath )
|
||||
{
|
||||
strcpy(finalProfilePath,profileDir);
|
||||
strcat(finalProfilePath,"\\");
|
||||
strcat(finalProfilePath,partialPath);
|
||||
strcat(finalProfilePath,"\\");
|
||||
strcat(finalProfilePath,path);
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Final profile path is : %s ", finalProfilePath);
|
||||
}
|
||||
|
||||
#else // Linux platform
|
||||
|
||||
int totalLen = strlen(homeDir) + strlen(profileDir) + strlen(path) + 2 ;
|
||||
finalProfilePath = (char *) malloc(totalLen);
|
||||
|
||||
if( finalProfilePath )
|
||||
{
|
||||
strcpy(finalProfilePath,homeDir);
|
||||
strcat(finalProfilePath,profileDir);
|
||||
strcat(finalProfilePath,"/");
|
||||
strcat(finalProfilePath,path);
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Final profile path is : %s ", finalProfilePath);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if(path)
|
||||
free(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalProfilePath = path;
|
||||
|
||||
}
|
||||
|
||||
if( !finalProfilePath)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Insufficient memory ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check if profile directory exists.....
|
||||
if( !IsDirectoryExists(finalProfilePath) )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxProfilePath : Profile directory [%s] does not exist", finalProfilePath);
|
||||
free(finalProfilePath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return finalProfilePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char* ProfileManager::GetFirefoxLibPath()
|
||||
{
|
||||
char *firefoxPath = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
char regSubKey[] = "SOFTWARE\\Clients\\StartMenuInternet\\firefox.exe\\shell\\open\\command";
|
||||
char pathValue[MAX_PATH] ="";
|
||||
DWORD pathSize = MAX_PATH;
|
||||
DWORD valueType;
|
||||
HKEY rkey;
|
||||
|
||||
// Open firefox registry key
|
||||
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, regSubKey, 0, KEY_READ, &rkey) != ERROR_SUCCESS )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxLibPath : Failed to open the firefox registry key : HKCU\\%s", regSubKey );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read the firefox path value
|
||||
if( RegQueryValueEx(rkey, NULL, 0, &valueType, (unsigned char*)&pathValue, &pathSize) != ERROR_SUCCESS )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxLibPath : Failed to read the firefox path value from registry ");
|
||||
RegCloseKey(rkey);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( pathSize <= 0 || pathValue[0] == 0)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxLibPath : Path value read from the registry is empty");
|
||||
RegCloseKey(rkey);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RegCloseKey(rkey);
|
||||
|
||||
// This path may contain extra double quote....
|
||||
if( pathValue[0] == '\"' )
|
||||
{
|
||||
for(unsigned int i=0; i< strlen(pathValue)-1 ; i++)
|
||||
pathValue[i] = pathValue[i+1];
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxLibPath : Path value read from registry is %s", pathValue);
|
||||
|
||||
StrLwr(pathValue);
|
||||
char *firefox = strstr(pathValue, "firefox.exe");
|
||||
|
||||
if( firefox == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n GetFirefoxLibPath : Path value read from registry is invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// remove the firefox.exe from the end...
|
||||
*(firefox-1) = 0;
|
||||
|
||||
firefoxPath = (char*) malloc( strlen(pathValue) + 1);
|
||||
|
||||
if( firefoxPath )
|
||||
{
|
||||
strcpy(firefoxPath, pathValue);
|
||||
|
||||
if( !IsDirectoryExists(firefoxPath) )
|
||||
{
|
||||
free(firefoxPath);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else // Linux platform...
|
||||
|
||||
char path[]="/opt/MozillaFirefox/lib";
|
||||
|
||||
firefoxPath = (char*) malloc( strlen(path) + 1);
|
||||
|
||||
if( firefoxPath )
|
||||
{
|
||||
strcpy(firefoxPath, path);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n GetFirefoxLibPath : Firefox library path = [%s] ", firefoxPath);
|
||||
|
||||
return firefoxPath;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HMODULE ProfileManager::PMLoadLibrary(char *firefoxDir, char *libName)
|
||||
{
|
||||
char *loadPath;
|
||||
HMODULE libtmp = NULL;
|
||||
|
||||
if( firefoxDir != NULL )
|
||||
loadPath = ( char*) malloc(strlen(firefoxDir) + strlen(libName) + 2);
|
||||
else
|
||||
loadPath = ( char*) malloc(strlen(libName) + 1);
|
||||
|
||||
if( !loadPath )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n\n LoadLibrary : Insufficient memory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( firefoxDir != NULL )
|
||||
{
|
||||
strcpy(loadPath, firefoxDir);
|
||||
strcat(loadPath, "/");
|
||||
strcat(loadPath, libName);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(loadPath, libName);
|
||||
}
|
||||
|
||||
libtmp = LOADLIBRARY(loadPath);
|
||||
|
||||
if( !libtmp )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n\n LoadLibrary : Failed to load library %s ", loadPath);
|
||||
free(loadPath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(loadPath);
|
||||
|
||||
return libtmp;
|
||||
}
|
||||
|
||||
//
|
||||
// Checks if store is available...
|
||||
//
|
||||
int ProfileManager::IsStoreAvailable()
|
||||
{
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n IsStoreAvailable : Checking if firefox and its libraries are present ");
|
||||
|
||||
|
||||
|
||||
libraryPath = GetFirefoxLibPath();
|
||||
|
||||
if( !libraryPath )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsStoreAvailable : Failed to find firefox profile or library path ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// First check if firefox binary is present....
|
||||
// Because on NLD, NSS library is no longer shipped with firefox.
|
||||
// Hence NSS libraries will still be there even if firefox is removed :)
|
||||
#ifdef WIN32
|
||||
|
||||
char *firefox_bin_file = (char*) malloc(strlen(libraryPath)+ strlen("firefox.exe") + 2);
|
||||
if( !firefox_bin_file )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsStoreAvailable : Insufficient memory..malloc failed \n");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
strcpy(firefox_bin_file,libraryPath);
|
||||
strcat(firefox_bin_file,"\\firefox.exe");
|
||||
|
||||
FILE *firefox_bin = fopen(firefox_bin_file,"r");
|
||||
|
||||
if( firefox_bin == NULL)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsStoreAvailable : Failed to find firefox binary file %s\n", firefox_bin_file);
|
||||
free(firefox_bin_file);
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
free(firefox_bin_file);
|
||||
fclose(firefox_bin);
|
||||
|
||||
#else
|
||||
|
||||
FILE *firefox_bin = fopen("/usr/bin/firefox","r");
|
||||
|
||||
if( firefox_bin == NULL)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsStoreAvailable : Failed to find firefox binary file /usr/bin/firefox \n");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
fclose(firefox_bin);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// Next try to load from the library path then try to load from default lib path
|
||||
|
||||
// Here we have to first load all dependent libraries and then
|
||||
// load main library , otherwise face the problems...:)
|
||||
if( PMLoadLibrary(libraryPath, NSPR_LIBRARY_NAME) )
|
||||
{
|
||||
if((libplc=PMLoadLibrary(libraryPath, PLC_LIBRARY_NAME)) )
|
||||
{
|
||||
if( PMLoadLibrary(libraryPath, PLDS_LIBRARY_NAME) )
|
||||
{
|
||||
if( PMLoadLibrary(libraryPath, SOFTN_LIBRARY_NAME) )
|
||||
libnss=PMLoadLibrary(libraryPath, NSS_LIBRARY_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // try to load library from default library path
|
||||
{
|
||||
if( PMLoadLibrary(NULL, NSPR_LIBRARY_NAME) )
|
||||
{
|
||||
if((libplc=PMLoadLibrary(NULL, PLC_LIBRARY_NAME)) )
|
||||
{
|
||||
if( PMLoadLibrary(NULL, PLDS_LIBRARY_NAME) )
|
||||
{
|
||||
if( PMLoadLibrary(NULL, SOFTN_LIBRARY_NAME) )
|
||||
libnss=PMLoadLibrary(NULL, NSS_LIBRARY_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !libnss || !libplc )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsStoreAvailable : Failed to load the required firefox library");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
// Free the library
|
||||
if( libnss != NULL )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsStoreAvailable : Freeing library libnss.dll");
|
||||
FREELIBRARY(libnss);
|
||||
}
|
||||
|
||||
if( libplc != NULL )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsStoreAvailable : Freeing library libplc.dll");
|
||||
FREELIBRARY(libplc);
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Public functions...
|
||||
|
||||
|
||||
int ProfileManager::ProfileInit(char *profileName)
|
||||
{
|
||||
|
||||
if( isInitialized == FPM_TRUE)
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileInit : Firefox profile [%s] is already initialized ", profileName);
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
profilePath = GetFirefoxProfilePath(profileName);
|
||||
libraryPath = GetFirefoxLibPath();
|
||||
|
||||
if( !profilePath || !libraryPath )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ProfileInit : Failed to find firefox profile or library path ");
|
||||
return FPM_PROFILE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Profile path = [%s] ", profilePath);
|
||||
PrintMessage(MESG_DEBUG, "\n Library path = [%s] ", libraryPath);
|
||||
|
||||
// First try to load from the library path then try to load from default lib path
|
||||
|
||||
// Here we have to first load all dependent libraries and then
|
||||
// load main library , otherwise face the problems...:)
|
||||
if( PMLoadLibrary(libraryPath, NSPR_LIBRARY_NAME) )
|
||||
{
|
||||
if((libplc=PMLoadLibrary(libraryPath, PLC_LIBRARY_NAME)) )
|
||||
{
|
||||
if( PMLoadLibrary(libraryPath, PLDS_LIBRARY_NAME) )
|
||||
{
|
||||
if( PMLoadLibrary(libraryPath, SOFTN_LIBRARY_NAME) )
|
||||
libnss=PMLoadLibrary(libraryPath, NSS_LIBRARY_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // try to load library from default library path
|
||||
{
|
||||
if( PMLoadLibrary(NULL, NSPR_LIBRARY_NAME) )
|
||||
{
|
||||
if((libplc=PMLoadLibrary(NULL, PLC_LIBRARY_NAME)) )
|
||||
{
|
||||
if( PMLoadLibrary(NULL, PLDS_LIBRARY_NAME) )
|
||||
{
|
||||
if( PMLoadLibrary(NULL, SOFTN_LIBRARY_NAME) )
|
||||
libnss=PMLoadLibrary(NULL, NSS_LIBRARY_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !libnss || !libplc )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ProfileInit : Failed to load the required firefox library");
|
||||
return FPM_LIBRARY_LOAD_FAILED;
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileInit : Required libraries are loaded from firefox path successfully..");
|
||||
|
||||
|
||||
// Get all the functions from NSS library
|
||||
NSSInit = (NSS_Init) GETPROCADDRESS(libnss, "NSS_Init");
|
||||
NSSShutdown = (NSS_Shutdown)GETPROCADDRESS(libnss, "NSS_Shutdown");
|
||||
//PK11SetPasswordFunc = (PK11_SetPasswordFunc) GETPROCADDRESS(libnss, "PK11_SetPasswordFunc");
|
||||
PK11GetInternalKeySlot = (PK11_GetInternalKeySlot) GETPROCADDRESS(libnss, "PK11_GetInternalKeySlot");
|
||||
PK11FreeSlot = (PK11_FreeSlot) GETPROCADDRESS(libnss, "PK11_FreeSlot");
|
||||
PK11Authenticate = (PK11_Authenticate) GETPROCADDRESS(libnss, "PK11_Authenticate");
|
||||
PK11SDRDecrypt = (PK11SDR_Decrypt) GETPROCADDRESS(libnss, "PK11SDR_Decrypt");
|
||||
PK11SDREncrypt = (PK11SDR_Encrypt) GETPROCADDRESS(libnss, "PK11SDR_Encrypt");
|
||||
PK11CheckUserPassword = (PK11_CheckUserPassword) GETPROCADDRESS(libnss, "PK11_CheckUserPassword");
|
||||
|
||||
if( !NSSInit || !NSSShutdown || !PK11GetInternalKeySlot || !PK11Authenticate || !PK11SDRDecrypt || !PK11SDREncrypt || !PK11FreeSlot || !PK11CheckUserPassword)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n\n ProfileInit : Failed to get function address for library %s ", NSS_LIBRARY_NAME);
|
||||
ProfileExit();
|
||||
return FPM_LIBRARY_LOAD_FAILED;
|
||||
}
|
||||
|
||||
// Get all the functions from PLC library
|
||||
PLBase64Encode = ( PL_Base64Encode ) GETPROCADDRESS(libplc, "PL_Base64Encode");
|
||||
PLBase64Decode = ( PL_Base64Decode ) GETPROCADDRESS(libplc, "PL_Base64Decode");
|
||||
|
||||
if( !PLBase64Encode || !PLBase64Decode )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\nProfileInit : Failed to get function address for library %s ", PLC_LIBRARY_NAME);
|
||||
ProfileExit();
|
||||
return FPM_LIBRARY_LOAD_FAILED;
|
||||
}
|
||||
|
||||
|
||||
// Initialize the NSS library
|
||||
if( (*NSSInit) (profilePath) != SECSuccess )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ProfileInit : Initialization failed , Make sure key3.db and cert8.db");
|
||||
PrintMessage(MESG_ERROR, "\n files are present in the specified directory\n");
|
||||
ProfileExit();
|
||||
|
||||
return FPM_LIBRARY_INIT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileInit : NSS_Init success..");
|
||||
|
||||
// Copy the profile name for later use
|
||||
this->profileName = (char*) malloc(strlen(profileName)+1);
|
||||
if( !this->profileName )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ProfileInit : Insufficient memory..");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(this->profileName, profileName);
|
||||
|
||||
|
||||
// TODO
|
||||
// Read the preference from the config file present in the profile...
|
||||
|
||||
isInitialized = FPM_TRUE;
|
||||
|
||||
// Setup the function pointers...
|
||||
void *funList[9];
|
||||
|
||||
funList[0] = (void*)NULL ; //PK11SetPasswordFunc;
|
||||
funList[1] = (void*)PK11GetInternalKeySlot;
|
||||
funList[2] = (void*)PK11FreeSlot;
|
||||
funList[3] = (void*)PK11Authenticate;
|
||||
funList[4] = (void*)PK11CheckUserPassword;
|
||||
funList[5] = (void*)PK11SDRDecrypt;
|
||||
funList[6] = (void*)PK11SDREncrypt;
|
||||
funList[7] = (void*)PLBase64Encode;
|
||||
funList[8] = (void*)PLBase64Decode;
|
||||
|
||||
signonManager.SetupFunctions(funList);
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ProfileManager::ProfileExit()
|
||||
{
|
||||
int i;
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit : Shutting down the profile %s", profileName);
|
||||
|
||||
if( (isInitialized == FPM_TRUE) && NSSShutdown != NULL )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit : invoking NSSShutdown for profile", profileName);
|
||||
for(i=0; (i<5) && ((*NSSShutdown)() == SECFailure); i++ )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit %d: NSSShutdown : FAILURE",i);
|
||||
//Sleep(500);
|
||||
}
|
||||
|
||||
if( i != 5)
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit :NSSShutdown : SUCCESS");
|
||||
|
||||
}
|
||||
else
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit : NSSShutdown : FAILURE");
|
||||
|
||||
}
|
||||
|
||||
if( libnss != NULL )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libnss.dll");
|
||||
FREELIBRARY(libnss);
|
||||
}
|
||||
|
||||
if( libplc != NULL )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libplc.dll");
|
||||
FREELIBRARY(libplc);
|
||||
}
|
||||
|
||||
// clean up signon data...
|
||||
signonManager.RemoveSignonData();
|
||||
|
||||
isInitialized = FPM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::IsMasterPasswordSet()
|
||||
{
|
||||
PK11SlotInfo *slot = 0;
|
||||
int retValue = 0;
|
||||
SECStatus status;
|
||||
|
||||
slot = (*PK11GetInternalKeySlot)();
|
||||
|
||||
if (!slot)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n IsMasterPasswordSet PK11_GetInternalKeySlot failed ...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
|
||||
|
||||
// Check with empty password....If it succeeds then master password is not set
|
||||
|
||||
status = (*PK11CheckUserPassword)(slot,"");
|
||||
if( status == SECSuccess )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is not set...");
|
||||
retValue = FPM_FALSE;
|
||||
}
|
||||
else if(status == SECWouldBlock ) // password is wrong
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is set...");
|
||||
retValue = FPM_TRUE;
|
||||
}
|
||||
else // something is wrong, may be key3.db is not initialized for crypt
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is not set...");
|
||||
retValue = FPM_FALSE;
|
||||
}
|
||||
|
||||
// Free the slot
|
||||
(*PK11FreeSlot) (slot);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::CheckMasterPassword(char *masterPassword, int doSave)
|
||||
{
|
||||
PK11SlotInfo *slot = 0;
|
||||
int retValue = 0;
|
||||
|
||||
slot = (*PK11GetInternalKeySlot)();
|
||||
|
||||
if (!slot)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CheckMasterPassword PK11_GetInternalKeySlot failed ...");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if( (*PK11CheckUserPassword)(slot, masterPassword) == SECSuccess )
|
||||
{
|
||||
// Store the password for internal use...
|
||||
if( doSave )
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n CheckMasterPassword : saving master password for future use ******...");
|
||||
|
||||
this->masterPassword = (char *) malloc( strlen(masterPassword)+1 );
|
||||
|
||||
if( !this->masterPassword )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CheckMasterPassword : Insufficient memory");
|
||||
(*PK11FreeSlot) (slot); // Free the slot...
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(this->masterPassword, masterPassword);
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n CheckMasterPassword : specified master password is correct...");
|
||||
retValue = FPM_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n CheckMasterPassword : specified master password is wrong...");
|
||||
retValue = FPM_FALSE;
|
||||
}
|
||||
|
||||
// Free the slot
|
||||
(*PK11FreeSlot) (slot);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::GetSignonData( struct Host **host, int doRefresh)
|
||||
{
|
||||
int retValue;
|
||||
|
||||
//TODO NAG:
|
||||
//check if "remember password" enabled....
|
||||
|
||||
// Reload the signon data from the file...
|
||||
if( doRefresh )
|
||||
{
|
||||
retValue = RefreshSignonData();
|
||||
*host = signonManager.GetHostInfo();
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// if host list is null read again....
|
||||
// TODO NAG : If there is no data , this will cause refresh to happen every time...
|
||||
|
||||
if( signonManager.GetHostInfo() == NULL )
|
||||
{
|
||||
retValue = RefreshSignonData();
|
||||
*host = signonManager.GetHostInfo();
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// Just return the previously loaded data
|
||||
*host = signonManager.GetHostInfo();
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::RefreshSignonData()
|
||||
{
|
||||
|
||||
// First check if master password is correct....
|
||||
if( masterPassword )
|
||||
{
|
||||
// Just check for password , don't save....
|
||||
if( CheckMasterPassword(masterPassword, 0 ) != FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n RefreshSignonData : master password is wrong..can't proceed with signon decryption" );
|
||||
return FPM_MASTERPASSWORD_WRONG;
|
||||
}
|
||||
}
|
||||
else // check if master password is set...
|
||||
{
|
||||
// master password is set and its not specified
|
||||
if( IsMasterPasswordSet() == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n RefreshSignonData : master password is set..but its not specified " );
|
||||
return FPM_MASTERPASSWORD_WRONG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return signonManager.LoadSignonData(profilePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::WriteSignonData()
|
||||
{
|
||||
// First check if master password is correct....
|
||||
if( masterPassword )
|
||||
{
|
||||
// Just check for password , don't save....
|
||||
if( CheckMasterPassword(masterPassword, 0 ) != FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : master password is wrong..can't proceed with signon decryption" );
|
||||
return FPM_MASTERPASSWORD_WRONG;
|
||||
}
|
||||
}
|
||||
else // check if master password is set...
|
||||
{
|
||||
// master password is set and its not specified
|
||||
if( IsMasterPasswordSet() == FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : master password is set..but its not specified " );
|
||||
return FPM_MASTERPASSWORD_WRONG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return signonManager.WriteSignonData(profilePath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::AddHost(struct Host *host, int doUpdate)
|
||||
{
|
||||
int retValue;
|
||||
|
||||
if( (retValue = signonManager.AddHost(host)) != FPM_TRUE)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Failed to add the host %s ", host->hostName);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
if( doUpdate > 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n AddHost : Updating the signon file ");
|
||||
return WriteSignonData();
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ProfileManager::ModifyHost(struct Host *host, int doUpdate)
|
||||
{
|
||||
int retValue;
|
||||
|
||||
if( (retValue = signonManager.ModifyHost(host)) != FPM_TRUE)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Failed to modify the host %s ", host->hostName);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
if( doUpdate > 0)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n ModifyHost : Updating the signon file ");
|
||||
return WriteSignonData();
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ProfileManager::RemoveHost(char *hostName, int doUpdate)
|
||||
{
|
||||
int retValue;
|
||||
|
||||
if( (retValue = signonManager.RemoveHost(hostName)) != FPM_TRUE)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n RemoveHost : Failed to remove the hsot %s ", hostName);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
if( doUpdate > 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n RemoveHost : Updating the signon file ");
|
||||
return WriteSignonData();
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
93
adlib/ad_ff/native/ProfileManager.h
Normal file
93
adlib/ad_ff/native/ProfileManager.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef __FPM_PROFILE_MANAGER_H__
|
||||
#define __FPM_PROFILE_MANAGER_H__
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
#include "SignonManager.h"
|
||||
|
||||
|
||||
class ProfileManager
|
||||
{
|
||||
SignonManager signonManager;
|
||||
|
||||
char *profilePath;
|
||||
char *libraryPath;
|
||||
char *masterPassword;
|
||||
|
||||
HMODULE libnss;
|
||||
HMODULE libplc;
|
||||
|
||||
// NSS Library function pointers
|
||||
NSS_Init NSSInit;
|
||||
NSS_Shutdown NSSShutdown;
|
||||
//PK11_SetPasswordFunc PK11SetPasswordFunc;
|
||||
PK11_GetInternalKeySlot PK11GetInternalKeySlot;
|
||||
PK11_FreeSlot PK11FreeSlot;
|
||||
PK11_Authenticate PK11Authenticate;
|
||||
PK11_CheckUserPassword PK11CheckUserPassword;
|
||||
PK11SDR_Decrypt PK11SDRDecrypt;
|
||||
PK11SDR_Encrypt PK11SDREncrypt;
|
||||
|
||||
PL_Base64Encode PLBase64Encode;
|
||||
PL_Base64Decode PLBase64Decode;
|
||||
|
||||
public :
|
||||
|
||||
char *profileName;
|
||||
int isInitialized;
|
||||
|
||||
private :
|
||||
|
||||
char *GetFirefoxProfilePath(char *profileName);
|
||||
char *GetFirefoxLibPath();
|
||||
HMODULE PMLoadLibrary(char *firefoxDir, char *libName);
|
||||
int RefreshSignonData();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ProfileManager();
|
||||
|
||||
int IsStoreAvailable();
|
||||
int ProfileInit(char *profileName);
|
||||
void ProfileExit();
|
||||
|
||||
int IsMasterPasswordSet();
|
||||
int CheckMasterPassword(char *masterPassword, int doSave);
|
||||
|
||||
int GetSignonData( struct Host **host, int doRefresh);
|
||||
int WriteSignonData();
|
||||
|
||||
int AddHost(struct Host *host, int doUpdate);
|
||||
int ModifyHost(struct Host *host, int doUpdat);
|
||||
int RemoveHost(char *hostname, int doUpdate);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
637
adlib/ad_ff/native/SignonManager.cpp
Normal file
637
adlib/ad_ff/native/SignonManager.cpp
Normal file
@@ -0,0 +1,637 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include "SignonManager.h"
|
||||
|
||||
// Static data to keep track of buffers
|
||||
// Look at function ReadChar
|
||||
static int last = 0;
|
||||
static int next = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SignonManager::SignonManager()
|
||||
{
|
||||
signonFile = NULL;
|
||||
}
|
||||
|
||||
SignonManager::~SignonManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SignonManager::SetupFunctions(void *funList[])
|
||||
{
|
||||
cryptManager.SetupFunctions(funList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int SignonManager::OpenSignonFile(char *firefoxProfileDir, char *fileName, char *accessType )
|
||||
{
|
||||
char *signonFilePath = NULL;
|
||||
|
||||
// Clean up previous buffers
|
||||
last = 0;
|
||||
next = 0;
|
||||
|
||||
|
||||
signonFilePath = (char*) malloc( strlen(firefoxProfileDir) + strlen(fileName) + 3 );
|
||||
|
||||
if( signonFilePath == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n Insufficient memory ....");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(signonFilePath, firefoxProfileDir);
|
||||
strcat(signonFilePath, "/");
|
||||
strcat(signonFilePath, fileName);
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Final signon filename is = %s ", signonFilePath);
|
||||
|
||||
// Open the signon file
|
||||
signonFile = fopen(signonFilePath, accessType);
|
||||
|
||||
if( signonFile == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n SignonManager : Error opening signon file %s", signonFilePath);
|
||||
free(signonFilePath);
|
||||
return FPM_SIGNON_FILE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free(signonFilePath);
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SignonManager::CloseSignonFile()
|
||||
{
|
||||
|
||||
if( signonFile )
|
||||
fclose(signonFile);
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SignonManager::ReadLine(char *buffer, int size)
|
||||
{
|
||||
Unichar c;
|
||||
int strLength = 0, i=0;
|
||||
|
||||
buffer[0] = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
c = ReadCharUTF8();
|
||||
|
||||
/* note that eof is not set until we read past the end of the file */
|
||||
if ( c == FPM_FALSE ) // || feof(file) )
|
||||
return FPM_FALSE;
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
buffer[strLength++] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (c != '\r')
|
||||
{
|
||||
for(i=0; i < 4 && ( (c & 0xff) != 0 ) ; i++)
|
||||
{
|
||||
if( strLength >= size )
|
||||
{
|
||||
// Increase the capacity dynamically
|
||||
PrintMessage(MESG_ERROR, "SignonManager : Buffer is insufficient to store data");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
buffer[strLength++] = (char)c;
|
||||
c = c >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PrintMessage(MESG_DEBUG,"SignonManager : ReadLine = %s ",buffer);
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Unichar SignonManager::ReadCharUTF8()
|
||||
{
|
||||
Unichar c = ReadChar();
|
||||
|
||||
if ((c & 0x80) == 0x00)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
else if ((c & 0xE0) == 0xC0)
|
||||
{
|
||||
return (((c & 0x1F)<<6) + (ReadChar() & 0x3F));
|
||||
}
|
||||
else if ((c & 0xF0) == 0xE0)
|
||||
{
|
||||
return (((c & 0x0F)<<12) + ((ReadChar() & 0x3F)<<6) + (ReadChar() & 0x3F));
|
||||
}
|
||||
|
||||
|
||||
return FPM_FALSE; // 0 => not a utf8 character...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// This does buffered reading...
|
||||
//
|
||||
char SignonManager::ReadChar()
|
||||
{
|
||||
const int buflen = 1000;
|
||||
static char buf[buflen+1];
|
||||
|
||||
if (next >= last)
|
||||
{
|
||||
next = 0;
|
||||
last = fread(buf, 1, buflen, signonFile);
|
||||
PrintMessage(MESG_DEBUG,"\n SignonManager : ReadChar = Read %d bytes ",last);
|
||||
|
||||
if (last <= 0) // || feof(file)
|
||||
{
|
||||
/* note that eof is not set until we read past the end of the file */
|
||||
PrintMessage(MESG_DEBUG,"\n SignonManager : ReadChar = End of file..! ");
|
||||
return FPM_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (buf[next++]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SignonManager::WriteCharUTF8(Unichar c)
|
||||
{
|
||||
if (c <= 0x7F)
|
||||
{
|
||||
if( fputc((char)c, signonFile) == EOF )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
}
|
||||
else if (c <= 0x7FF)
|
||||
{
|
||||
if( fputc( ((Unichar)0xC0) | ((c>>6) & 0x1F), signonFile) == EOF )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
|
||||
if( fputc( ((Unichar)0x80) | (c & 0x3F), signonFile ) == EOF )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fputc( ((Unichar)0xE0) | ((c>>12) & 0xF), signonFile) == EOF )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
if( fputc( ((Unichar)0x80) | ((c>>6) & 0x3F), signonFile) == EOF)
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
if( fputc( ((Unichar)0x80) | (c & 0x3F), signonFile) == EOF)
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
return FPM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int SignonManager::WriteLine(char *line)
|
||||
{
|
||||
|
||||
for(int i=0; i < strlen(line); i++)
|
||||
{
|
||||
if( WriteCharUTF8(line[i]) != FPM_TRUE )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
|
||||
}
|
||||
|
||||
if( WriteCharUTF8('\n') != FPM_TRUE )
|
||||
return FPM_SIGNON_FILE_WRITE_ERROR;
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Load the signon data from firefox signon file.....
|
||||
*
|
||||
*
|
||||
*/
|
||||
int SignonManager::LoadSignonData(char *firefoxProfileDir )
|
||||
{
|
||||
char header[256];
|
||||
char buffer[4096];
|
||||
char hostName[4096];
|
||||
char name[1024];
|
||||
int bufferLength = 4095;
|
||||
int retValue;
|
||||
char *clearData = NULL;
|
||||
int count = 0;
|
||||
|
||||
|
||||
// open the signon file
|
||||
if( (retValue = OpenSignonFile(firefoxProfileDir, SIGNON_FILE_NAME, "r")) != FPM_TRUE )
|
||||
{
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// Clean up any previously loaded data...
|
||||
dataManager.RemoveAllData();
|
||||
|
||||
// read the signon header information
|
||||
if( ReadLine(header, 256) != FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n SignonManager : Error in reading signon format header %s", header);
|
||||
CloseSignonFile();
|
||||
return FPM_SIGNON_FILE_READ_ERROR;
|
||||
}
|
||||
|
||||
// check if the format is right...
|
||||
if( strcmp(header, HEADER_VERSION) != 0)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n SignonManager : Header version information is not proper");
|
||||
CloseSignonFile();
|
||||
return FPM_SIGNON_FILE_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n\n ****** Reject Host List *******");
|
||||
|
||||
// read the reject list
|
||||
while ( ReadLine(buffer, bufferLength) == FPM_TRUE)
|
||||
{
|
||||
// Check for end of reject list i.e full stop
|
||||
if (strlen(buffer) != 0 && buffer[0] == '.')
|
||||
{
|
||||
break; // end of reject list
|
||||
}
|
||||
|
||||
if( (retValue = dataManager.AddRejectHost(buffer) ) != FPM_TRUE )
|
||||
{
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up any partial loaded data
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n Reject Host : %s ", buffer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n\n ****** Host list with username / password ****** ");
|
||||
|
||||
|
||||
while (ReadLine(hostName, bufferLength) == FPM_TRUE)
|
||||
{
|
||||
// a blank line is perfectly valid here -- corresponds to a local file
|
||||
if (strlen(hostName) < 1)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n SignonManager : Host URL is not proper");
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up partial loaded data
|
||||
|
||||
return FPM_ILLEGAL_HOSTNAME;
|
||||
}
|
||||
|
||||
if( ( retValue = dataManager.AddHost(hostName) ) != FPM_TRUE )
|
||||
{
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up partial loaded data
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n\n Host : %s ", hostName);
|
||||
|
||||
// prepare to read the name/value pairs
|
||||
while( ReadLine(buffer, bufferLength) == FPM_TRUE )
|
||||
{
|
||||
// line starting with . terminates the pairs for this URL entry
|
||||
if (buffer[0] == '.')
|
||||
{
|
||||
break; // end of URL entry
|
||||
}
|
||||
|
||||
// save the name part and determine if it is a password
|
||||
unsigned char isPassword = 0;
|
||||
if (buffer[0] == '*')
|
||||
{
|
||||
isPassword = 1;
|
||||
strcpy(name,&buffer[1]);
|
||||
retValue = ReadLine(buffer, bufferLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
isPassword = 0;
|
||||
strcpy(name, buffer);
|
||||
retValue = ReadLine(buffer, bufferLength);
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n\n name = %s and value = %s ", name, buffer);
|
||||
|
||||
// read in and save the value part
|
||||
if ( retValue != FPM_TRUE )
|
||||
{
|
||||
// error in input file so give up
|
||||
PrintMessage(MESG_ERROR, "\n SignonManager : Error occured while reading VALUE for : %s ", name);
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up partial loaded data
|
||||
|
||||
return FPM_SIGNON_FILE_READ_ERROR;
|
||||
}
|
||||
|
||||
// Decrypt the encrypted value....
|
||||
retValue = FPM_FALSE;
|
||||
if( ((retValue = cryptManager.DecryptString(buffer, &clearData)) == FPM_TRUE) && (clearData != NULL) )
|
||||
{
|
||||
// Add the name/value pair to the existing store....
|
||||
retValue = dataManager.AddHostElement(hostName, name, clearData, isPassword);
|
||||
|
||||
if( retValue != FPM_TRUE )
|
||||
{
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up partial loaded data
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
CloseSignonFile();
|
||||
dataManager.RemoveAllData(); // clean up partial loaded data
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Now close the signon file
|
||||
CloseSignonFile();
|
||||
|
||||
// Print data for cross checking
|
||||
#ifdef DEBUG
|
||||
dataManager.PrintAllRejectHosts();
|
||||
dataManager.PrintAllHosts();
|
||||
#endif
|
||||
return FPM_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SignonManager::WriteSignonData(char *firefoxProfileDir)
|
||||
{
|
||||
int retValue;
|
||||
char *cryptData = NULL;
|
||||
char *signonFilePath = NULL;
|
||||
char *tempFilePath = NULL;
|
||||
char fileName[256];
|
||||
|
||||
Host *t;
|
||||
HostElement *h;
|
||||
RejectHost *r;
|
||||
|
||||
// TODO : If signon data has not changed since last write then return...
|
||||
/* // There may be requirement to write empty data...
|
||||
if( dataManager.hostList == NULL )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Signon data is empty...");
|
||||
return FPM_SIGNON_DATASTORE_EMPTY;
|
||||
}
|
||||
*/
|
||||
|
||||
// Generate random file name
|
||||
srand( (unsigned)time( NULL ) );
|
||||
sprintf(fileName,"signon_fpm_%d.txt", rand());
|
||||
|
||||
// Setup the signon and temp filename..
|
||||
signonFilePath = (char*) malloc( strlen(firefoxProfileDir) + strlen(SIGNON_FILE_NAME) + 3);
|
||||
tempFilePath =(char*) malloc( strlen(firefoxProfileDir) + strlen(fileName) + 3);
|
||||
|
||||
if( signonFilePath == NULL || tempFilePath == NULL)
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Insufficient memory ....");
|
||||
return FPM_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
strcpy(signonFilePath, firefoxProfileDir);
|
||||
strcat(signonFilePath, "/");
|
||||
strcat(signonFilePath, SIGNON_FILE_NAME);
|
||||
|
||||
strcpy(tempFilePath, firefoxProfileDir);
|
||||
strcat(tempFilePath, "/");
|
||||
strcat(tempFilePath, fileName);
|
||||
|
||||
// Open signon file
|
||||
if( (retValue = OpenSignonFile(firefoxProfileDir, fileName, "w")) != FPM_TRUE )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\nWriteSignonData : Failed to create temp signon file : %s.", fileName);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
// write out the format revision number
|
||||
if( (retValue = WriteLine(HEADER_VERSION)) != FPM_TRUE)
|
||||
goto write_signon_error;
|
||||
|
||||
// write out reject host list
|
||||
for(r=dataManager.rejectHostList; r ; r=r->next)
|
||||
{
|
||||
if( (retValue = WriteLine(r->hostName)) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
|
||||
}
|
||||
|
||||
// End of reject host list
|
||||
if( (retValue = WriteLine(".")) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
|
||||
|
||||
/* format for cached logins shall be:
|
||||
* url LINEBREAK {name LINEBREAK value LINEBREAK}* . LINEBREAK
|
||||
* if type is password, name is preceded by an asterisk (*)
|
||||
*/
|
||||
|
||||
|
||||
// write out each URL node
|
||||
for(t=dataManager.hostList; t ; t=t->next)
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n\nWriteSignonData : Adding name/value pairs for host %s", t->hostName);
|
||||
|
||||
if( (retValue = WriteLine(t->hostName)) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
|
||||
|
||||
for(h=t->child; h ; h= h->next)
|
||||
{
|
||||
PrintMessage(MESG_DEBUG, "\n nWriteSignonData : %s : %s ", h->name, h->value);
|
||||
|
||||
if( h->isPassword)
|
||||
{
|
||||
if( (retValue = WriteCharUTF8('*')) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
}
|
||||
|
||||
if( (retValue = WriteLine(h->name)) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
|
||||
|
||||
// encrypt the value
|
||||
retValue = FPM_FALSE;
|
||||
retValue = cryptManager.EncryptString(h->value, &cryptData);
|
||||
|
||||
if( (retValue == FPM_TRUE) && (cryptData != NULL ))
|
||||
{
|
||||
if( (retValue = WriteLine(cryptData)) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n nWriteSignonData : Encryption of value %s failed ", h->value);
|
||||
goto write_signon_error;
|
||||
}
|
||||
}
|
||||
|
||||
if( (retValue = WriteLine(".")) != FPM_TRUE )
|
||||
goto write_signon_error;
|
||||
}
|
||||
|
||||
// close this temporary file...
|
||||
CloseSignonFile();
|
||||
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n WriteSignonData : Removing previous signon file %s ", signonFilePath);
|
||||
|
||||
// Delete previous signon file
|
||||
if( remove(signonFilePath) != 0 )
|
||||
{
|
||||
// Either file not present or file is locked...
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Failed to delete signon file : %s ", signonFilePath);
|
||||
FILE *sfile= NULL;
|
||||
if( (sfile = fopen(signonFilePath,"r") ) != NULL )
|
||||
{
|
||||
// we are able to open signon file in read only mode => file is present
|
||||
fclose(sfile);
|
||||
remove(tempFilePath); // delete temporary signon file
|
||||
|
||||
PrintMessage(MESG_ERROR, "\nWriteSignonData : Signon file is locked ");
|
||||
return FPM_SIGNON_FILE_LOCKED;
|
||||
}
|
||||
|
||||
// File is not present ..that's good news , so continue...
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "success \n WriteSignonData : Renaming temp file %s back to signon file %s ", tempFilePath, signonFilePath);
|
||||
|
||||
// Rename temp file back to signon file
|
||||
if( ( retValue = rename(tempFilePath, signonFilePath) ) != 0 )
|
||||
{
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Failed to rename the temp file %s back to signon file %s ", tempFilePath, signonFilePath);
|
||||
PrintMessage(MESG_ERROR, "\n WriteSignonData : Following error has occured : %d ", retValue);
|
||||
|
||||
return FPM_FALSE;
|
||||
}
|
||||
|
||||
PrintMessage(MESG_DEBUG, "\n WriteSignonData : Successfully written new signon data ...");
|
||||
|
||||
return FPM_TRUE;
|
||||
|
||||
write_signon_error:
|
||||
|
||||
CloseSignonFile();
|
||||
remove(tempFilePath); // remove the temporary signon file....
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int SignonManager::RemoveSignonData()
|
||||
{
|
||||
|
||||
return dataManager.RemoveAllData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SignonManager::AddHost(struct Host *host)
|
||||
{
|
||||
|
||||
return dataManager.AddHost(host);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SignonManager::ModifyHost(struct Host *host)
|
||||
{
|
||||
|
||||
return dataManager.ModifyHost(host);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int SignonManager::RemoveHost(char *hostName)
|
||||
{
|
||||
return dataManager.RemoveHost(hostName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct Host * SignonManager::GetHostInfo()
|
||||
{
|
||||
|
||||
return dataManager.hostList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
78
adlib/ad_ff/native/SignonManager.h
Normal file
78
adlib/ad_ff/native/SignonManager.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
// SignonManager.h: interface for the SignonManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __FPM_SIGNON_MANAGER_H__
|
||||
#define __FPM_SIGNON_MANAGER_H__
|
||||
|
||||
|
||||
|
||||
#include "FirefoxPasswordManager.h"
|
||||
#include "Common.h"
|
||||
#include "DataManager.h"
|
||||
#include "CryptManager.h"
|
||||
|
||||
|
||||
class SignonManager
|
||||
{
|
||||
|
||||
DataManager dataManager;
|
||||
CryptManager cryptManager;
|
||||
FILE *signonFile;
|
||||
|
||||
public:
|
||||
SignonManager();
|
||||
virtual ~SignonManager();
|
||||
|
||||
int OpenSignonFile(char *firefoxProfileDir, char *fileName, char *accessType );
|
||||
int CloseSignonFile();
|
||||
|
||||
int ReadLine(char *buffer, int size);
|
||||
char ReadChar();
|
||||
Unichar ReadCharUTF8();
|
||||
int WriteCharUTF8(Unichar c);
|
||||
int WriteLine(char *line);
|
||||
|
||||
|
||||
int LoadSignonData(char *firefoxProfileDir);
|
||||
int WriteSignonData(char *firefoxProfileDir);
|
||||
int RemoveSignonData();
|
||||
|
||||
int AddUser(char *host, char *userName, char *password);
|
||||
int RemoveHost(char *hostName);
|
||||
int ModifyHost(struct Host *host);
|
||||
int AddHost(struct Host *host);
|
||||
|
||||
|
||||
struct Host* GetHostInfo();
|
||||
void SetupFunctions(void *funList[]);
|
||||
|
||||
|
||||
int CheckSignonPref();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
5
adlib/ad_ff/native/link.lux
Normal file
5
adlib/ad_ff/native/link.lux
Normal file
@@ -0,0 +1,5 @@
|
||||
LINK = $(CPP) \
|
||||
-shared \
|
||||
-Wl \
|
||||
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
|
||||
$(OBJDIR)*.$(O)
|
||||
7
adlib/ad_ff/native/objs.lux
Normal file
7
adlib/ad_ff/native/objs.lux
Normal file
@@ -0,0 +1,7 @@
|
||||
OBJS=\
|
||||
Common.$(O) \
|
||||
CryptManager.$(O) \
|
||||
FirefoxPasswordManager.$(O) \
|
||||
ProfileManager.$(O) \
|
||||
SignonManager.$(O) \
|
||||
DataManager.$(O)
|
||||
3
adlib/ad_ff/objs.lux
Normal file
3
adlib/ad_ff/objs.lux
Normal file
@@ -0,0 +1,3 @@
|
||||
OBJS=\
|
||||
AssembyInfo\
|
||||
FireFox
|
||||
3
adlib/ad_ff/src.lux
Normal file
3
adlib/ad_ff/src.lux
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC=\
|
||||
AssemblyInfo.cs\
|
||||
FireFox.cs
|
||||
80
adlib/ad_gk/AssemblyInfo.cs
Normal file
80
adlib/ad_gk/AssemblyInfo.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Novell.CASA.DataEngines.GnomeKeyring.dll")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Novell, Inc")]
|
||||
[assembly: AssemblyProduct("CASA")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
440
adlib/ad_gk/GnomeKeyring.cs
Normal file
440
adlib/ad_gk/GnomeKeyring.cs
Normal file
@@ -0,0 +1,440 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using Gtk;
|
||||
using GLib;
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines.GK
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class KeyringInfo
|
||||
{
|
||||
public int lockOnIdle;
|
||||
public uint lockTimeout;
|
||||
public uint mTime;
|
||||
public uint cTime;
|
||||
public int isLocked;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class NativeItemInfo
|
||||
{
|
||||
public int itemType;
|
||||
public IntPtr displayName;
|
||||
public IntPtr secret;
|
||||
public int mTime;
|
||||
public int cTime;
|
||||
public NativeItemInfo()
|
||||
{
|
||||
/* The GUI allows 513 as the max number of chars for these items */
|
||||
displayName = Marshal.AllocHGlobal(512 + 1);
|
||||
secret = Marshal.AllocHGlobal(512 + 1);
|
||||
}
|
||||
~NativeItemInfo()
|
||||
{
|
||||
Marshal.FreeHGlobal(displayName);
|
||||
Marshal.FreeHGlobal(secret);
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemInfo
|
||||
{
|
||||
public string itemType;
|
||||
public string displayName;
|
||||
public string secret;
|
||||
public int mTime;
|
||||
public int cTime;
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class NativeAttribute
|
||||
{
|
||||
public uint type;
|
||||
public IntPtr key;
|
||||
public IntPtr value;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class Attribute
|
||||
{
|
||||
public uint type;
|
||||
public string key;
|
||||
public string value;
|
||||
|
||||
}
|
||||
|
||||
public class GnomeKeyring
|
||||
{
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int GetKeyrings(out IntPtr list);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int GetKeyringInfo(string name,KeyringInfo info);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int GetItems(string keyring,out IntPtr list);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int GetItemInfo(string keyring,int itemId, NativeItemInfo info);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int GetAttributeList(string keyring,int itemId, out IntPtr attrList);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int FreeAttributeList(IntPtr attrList);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int SetPassword (string keyring, int itemid, string password);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int RemoveItem (string keyring, int itemid);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int SetItemAttributes (string keyring, int itemid, IntPtr[] attrs, int length);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int CreateItem(string keyringName, int itemType, string displayName, string password, IntPtr[] arrptr, int attrCount);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int UnlockRing(string sKeyringName, string sPassword);
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int LoadGnomeKeyringLibrary();
|
||||
[DllImport("libad_gk.so")]
|
||||
public static extern int ReleaseGnomeKeyringLibrary();
|
||||
|
||||
public static bool IsGnomeKeyringInstalled()
|
||||
{
|
||||
if (0 == LoadGnomeKeyringLibrary())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ReleaseGnomeKeyringLib()
|
||||
{
|
||||
ReleaseGnomeKeyringLibrary();
|
||||
}
|
||||
|
||||
public static void AttemptGKUnlock(string sPassword)
|
||||
{
|
||||
ArrayList alKeyRings = GKGetKeyrings();
|
||||
IEnumerator kEtor = alKeyRings.GetEnumerator();
|
||||
while (kEtor.MoveNext())
|
||||
{
|
||||
string sKeyring = (string)(kEtor.Current);
|
||||
try
|
||||
{
|
||||
UnlockGnomeKeyring(sKeyring, sPassword);
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int UnlockGnomeKeyring(string sKeyringName, string sPassword)
|
||||
{
|
||||
int rcode = UnlockRing(sKeyringName, sPassword);
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static KeyringInfo GKGetKeyringInfo(string name)
|
||||
{
|
||||
KeyringInfo info = null;
|
||||
try
|
||||
{
|
||||
info = new KeyringInfo();
|
||||
int retVal = GetKeyringInfo(name,info);
|
||||
if( 0 != retVal )
|
||||
info = null;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
info = null;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public static void PrintKeyringInfo(KeyringInfo info)
|
||||
{
|
||||
if( null == info )
|
||||
return;
|
||||
try
|
||||
{
|
||||
//Console.WriteLine("lockOnIdle = " + info.lockOnIdle);
|
||||
//Console.WriteLine("lockTimeout = " + info.lockTimeout);
|
||||
//Console.WriteLine("mTime = " + info.mTime);
|
||||
//Console.WriteLine("cTime = " + info.cTime);
|
||||
//Console.WriteLine("isLocked = " + info.isLocked);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemInfo GKGetItemInfo(string keyring, int itemId)
|
||||
{
|
||||
ItemInfo info = null;
|
||||
try
|
||||
{
|
||||
NativeItemInfo nativeItemInfo = new NativeItemInfo();
|
||||
int retVal = GetItemInfo(keyring, itemId, nativeItemInfo);
|
||||
|
||||
if( 0 != retVal )
|
||||
info = null;
|
||||
else
|
||||
{
|
||||
info = new ItemInfo();
|
||||
if(nativeItemInfo.itemType == 0)
|
||||
info.itemType = "Generic Secret";
|
||||
else if(nativeItemInfo.itemType == 1)
|
||||
info.itemType = "Network Password";
|
||||
else if(nativeItemInfo.itemType == 2)
|
||||
info.itemType = "Note";
|
||||
else
|
||||
info.itemType = "No Type"; // need to have a better name
|
||||
|
||||
info.displayName = Marshal.PtrToStringAnsi(nativeItemInfo.displayName);
|
||||
info.secret = Marshal.PtrToStringAnsi(nativeItemInfo.secret);
|
||||
info.mTime = nativeItemInfo.mTime;
|
||||
info.cTime = nativeItemInfo.cTime;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
info = null;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public static void PrintItemInfo(ItemInfo info)
|
||||
{
|
||||
if( null == info )
|
||||
return;
|
||||
try
|
||||
{
|
||||
//Console.WriteLine("CS : itemType = " + info.itemType);
|
||||
//Console.WriteLine("CS : displayName = " + info.displayName);
|
||||
//Console.WriteLine("CS : secret = " + info.secret);
|
||||
//Console.WriteLine("CS : mTime = " + info.mTime);
|
||||
//Console.WriteLine("CS : cTime = " + info.cTime);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList GKGetKeyrings()
|
||||
{
|
||||
ArrayList retList;
|
||||
try
|
||||
{
|
||||
retList = new ArrayList();
|
||||
IntPtr list = new IntPtr();
|
||||
int retVal = GetKeyrings(out list);
|
||||
if ( 0 != retVal )
|
||||
retList = null;
|
||||
GLib.List keyringList = new List(list,typeof(string));
|
||||
IEnumerator etor = (IEnumerator)(keyringList.GetEnumerator());
|
||||
string name;
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
name = (string)etor.Current;
|
||||
retList.Add(name);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public static ArrayList GKGetItems(string keyring)
|
||||
{
|
||||
ArrayList retList = null;
|
||||
try
|
||||
{
|
||||
retList = new ArrayList();
|
||||
IntPtr list = new IntPtr();
|
||||
int retVal = GetItems(keyring,out list);
|
||||
if( 0 != retVal )
|
||||
retList = null;
|
||||
GLib.List itemList = new List(list,typeof(int));
|
||||
IEnumerator etor = (IEnumerator)(itemList.GetEnumerator());
|
||||
int itemId;
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
itemId = (int)etor.Current;
|
||||
retList.Add(itemId);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public static ArrayList GKGetAttributeList(string keyring, int itemId)
|
||||
{
|
||||
ArrayList retList = null;
|
||||
try
|
||||
{
|
||||
retList = new ArrayList();
|
||||
IntPtr list = new IntPtr();
|
||||
int retVal = GetAttributeList(keyring, itemId,out list);
|
||||
if( 0 != retVal )
|
||||
retList = null;
|
||||
GLib.List attrList = new List(list,typeof(int));
|
||||
IEnumerator etor = (IEnumerator)(attrList.GetEnumerator());
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
int test = (int)etor.Current;
|
||||
IntPtr ptr = new IntPtr(test);
|
||||
|
||||
NativeAttribute attr = new NativeAttribute();
|
||||
attr = (NativeAttribute)Marshal.PtrToStructure(ptr,typeof(NativeAttribute));
|
||||
|
||||
string key = Marshal.PtrToStringAnsi(attr.key);
|
||||
string value = Marshal.PtrToStringAnsi(attr.value);
|
||||
|
||||
Attribute retAttr = new Attribute();
|
||||
retAttr.type = attr.type;
|
||||
retAttr.key = String.Copy(key);
|
||||
retAttr.value = String.Copy(value);
|
||||
retList.Add(retAttr);
|
||||
}
|
||||
if(retList.Count > 0)
|
||||
FreeAttributeList(list);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
retList = null;
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public static void PrintAttrList(ArrayList attrList)
|
||||
{
|
||||
if( null == attrList )
|
||||
return;
|
||||
Attribute attr;
|
||||
try
|
||||
{
|
||||
IEnumerator etor = (IEnumerator)(attrList.GetEnumerator());
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
attr = (Attribute)(etor.Current);
|
||||
//Console.WriteLine("CS : AttrType = " + attr.type);
|
||||
//Console.WriteLine("CS : AttrKey = " + attr.key);
|
||||
//Console.WriteLine("CS : AttrValue = " + attr.value);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int SetAttributes(String keyringName, int itemId, NameValueCollection nvc)
|
||||
{
|
||||
IntPtr[] arrptr = new IntPtr[nvc.Count];
|
||||
for(int i=0; i < nvc.Count; i++)
|
||||
{
|
||||
string key = nvc.GetKey(i);
|
||||
string value = nvc.Get(key);
|
||||
Attribute attr = new Attribute();
|
||||
attr.type=0;
|
||||
attr.key=key;
|
||||
attr.value=value;
|
||||
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(attr));
|
||||
Marshal.StructureToPtr(attr,ptr,false);
|
||||
arrptr[i] = ptr;
|
||||
}
|
||||
int ret = SetItemAttributes( keyringName,itemId,arrptr,nvc.Count);
|
||||
FreeIntPtrArray(arrptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static int RemoveSecret(string keyringname, int itemid)
|
||||
{
|
||||
|
||||
return(RemoveItem(keyringname,itemid));
|
||||
}
|
||||
|
||||
public static int CreateSecret(String keyringName, string strItemType, string displayName, string password, NameValueCollection nvc)
|
||||
{
|
||||
//Console.WriteLine("In CreateSecret ");
|
||||
int itemType = 3; //No Type
|
||||
IntPtr[] arrptr = new IntPtr[nvc.Count];
|
||||
if(strItemType.CompareTo("Generic Secret") == 0 )
|
||||
{
|
||||
itemType = 0;
|
||||
}
|
||||
else
|
||||
if(strItemType.CompareTo("Network Password") == 0 )
|
||||
{
|
||||
itemType = 1;
|
||||
}
|
||||
else
|
||||
if(strItemType.CompareTo("Note") == 0 )
|
||||
{
|
||||
itemType = 2;
|
||||
}
|
||||
//Console.WriteLine("In CreateSecret ItemType = "+itemType);
|
||||
for(int i=0; i < nvc.Count; i++)
|
||||
{
|
||||
string key = nvc.GetKey(i);
|
||||
//Console.WriteLine("In CreateSecret Key "+i + " = " + key);
|
||||
string value = nvc.Get(key);
|
||||
//Console.WriteLine("In CreateSecret Value "+i + " = " + value);
|
||||
Attribute attr = new Attribute();
|
||||
attr.type=0;
|
||||
attr.key=key;
|
||||
attr.value=value;
|
||||
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(attr));
|
||||
Marshal.StructureToPtr(attr,ptr,false);
|
||||
arrptr[i] = ptr;
|
||||
}
|
||||
//Console.WriteLine("Calling Create item ");
|
||||
int ret = CreateItem(keyringName, itemType, displayName, password, arrptr, nvc.Count);
|
||||
FreeIntPtrArray(arrptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void FreeIntPtrArray(IntPtr[] arrptr)
|
||||
{
|
||||
for(int i=0; i < arrptr.Length; i++)
|
||||
{
|
||||
Marshal.FreeHGlobal(arrptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
105
adlib/ad_gk/Makefile.am
Normal file
105
adlib/ad_gk/Makefile.am
Normal file
@@ -0,0 +1,105 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
CS_EXTRA_FLAGS = $(CSCFLAGS_DEBUG)
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS = native
|
||||
DIST_SUBDIRS = native
|
||||
|
||||
EXTRA_DIST = $(CSFILES)
|
||||
|
||||
CASAROOT = ../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME =Novell.CASA.DataEngines.GnomeKeyring
|
||||
MODULE_EXT =dll
|
||||
|
||||
CSFILES = $(srcdir)/GnomeKeyring.cs
|
||||
|
||||
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
|
||||
CS_FLAGS = $(CSC_LIBFLAG) /target:library -pkg:gtk-sharp
|
||||
CS_RESOURCES =
|
||||
CS_LIBS =
|
||||
CS_LIBPATH =
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
#OBJS = $(addprefix $(OBJDIR)/, $(CSFILES:%.dll=%.cs))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
|
||||
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) -out:$@ $(CSFILES_CSC)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
|
||||
# @echo [======== Linking $@ ========]
|
||||
# $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
129
adlib/ad_gk/native/Makefile.am
Normal file
129
adlib/ad_gk/native/Makefile.am
Normal file
@@ -0,0 +1,129 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS =
|
||||
DIST_SUBDIRS =
|
||||
|
||||
EXTRA_DIST = $(CFILES) *.h
|
||||
|
||||
CASAROOT = ../../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
BUILD_VER = 1.1.1
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME = libad_gk
|
||||
MODULE_EXT = so
|
||||
|
||||
CFILES = $(srcdir)/ad_gk.c
|
||||
|
||||
LIBDIR = $(LIB)
|
||||
|
||||
CSFILES_CSC :=
|
||||
INCLUDES = -I. -I.. -I$(CASAROOT)/include \
|
||||
-I/opt/gnome/include/gnome-keyring-1 \
|
||||
-I/opt/gnome/include/glib-2.0 \
|
||||
-I/opt/gnome/$(LIBDIR)/glib-2.0/include \
|
||||
-L/opt/gnome/$(LIBDIR) -lglib-2.0
|
||||
|
||||
RESOURCES =
|
||||
EXTRA_CFLAGS =
|
||||
CFLAGS += $(INCLUDES) $(DEFINES)
|
||||
|
||||
LIBS = -lpthread -ldl
|
||||
LDFLAGS = -fno-exceptions -fno-check-new -Wl,-Bsymbolic -shared -pthread -O2 \
|
||||
-Wl,-rpath -Wl,/usr/$(LIBDIR) -Wl,-soname -Wl,libad_gk.so.1
|
||||
|
||||
EXTRA_LDFLAGS = -L/opt/gnome/$(LIBDIR) -lglib-2.0 -L/$(CASAROOT)/$(LIBDIR)
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIBDIR)
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o))
|
||||
|
||||
EXTRA_DIST = $(CFILES) *.h
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
|
||||
# @echo [======== Linking $@ ========]
|
||||
# $(LINK) -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(LIBS)
|
||||
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER): $(OBJDIR) $(OBJS)
|
||||
@echo [======== Linking $@ ========]
|
||||
c++ -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(LIBS)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
ln -sf $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).1
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
|
||||
1029
adlib/ad_gk/native/ad_gk.c
Normal file
1029
adlib/ad_gk/native/ad_gk.c
Normal file
File diff suppressed because it is too large
Load Diff
133
adlib/ad_gk/native/ad_gk.h
Normal file
133
adlib/ad_gk/native/ad_gk.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _AD_GK_H_
|
||||
#define _AD_GK_H_
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <glib.h>
|
||||
#include <casa-gnome-keyring.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1
|
||||
|
||||
#define KEY_SIZE 128
|
||||
#define VAL_SIZE 128
|
||||
|
||||
enum KeyringResultExtended { GNOME_KEYRING_RESULT_NO_SUCH_ITEM = 128,
|
||||
GNOME_KEYRING_RESULT_CANNOT_DELETE_SECRET_VALUE,
|
||||
GNOME_KEYRING_RESULT_MALFORMED_XML,
|
||||
GNOME_KEYRING_RESULT_CANNOT_CREATE_KEYRING
|
||||
};
|
||||
|
||||
typedef struct _KeyringInfo
|
||||
{
|
||||
int32_t lockOnIdle;
|
||||
uint32_t lockTimeout;
|
||||
uint32_t mTime;
|
||||
uint32_t cTime;
|
||||
int32_t isLocked;
|
||||
}KeyringInfo;
|
||||
|
||||
typedef struct _ItemInfo
|
||||
{
|
||||
int32_t itemType;
|
||||
char *displayName;
|
||||
char *secret;
|
||||
uint32_t mTime;
|
||||
uint32_t cTime;
|
||||
}ItemInfo;
|
||||
|
||||
typedef struct _Attribute
|
||||
{
|
||||
uint32_t type;
|
||||
char *key;
|
||||
char *value;
|
||||
}Attribute;
|
||||
|
||||
|
||||
int GetKeyrings(GList **retList);
|
||||
int GetKeyringInfo(char *keyring,KeyringInfo *info);
|
||||
int GetItems(char *keyring, GList **itemList);
|
||||
int GetItemInfo(char *keyring, int itemId, ItemInfo *info);
|
||||
int GetAttributeList(char *keyring, int itemId, GList **);
|
||||
int FreeAttributeList(GList *attrList);
|
||||
int LoadGnomeKeyringLibrary();
|
||||
int ReleaseGnomeKeyringLibrary();
|
||||
|
||||
int
|
||||
UnlockRing(char *keyring, char *password);
|
||||
int
|
||||
SetItemAttributes (char *keyring, guint32 item_id, Attribute **attrs, int length);
|
||||
int
|
||||
CreateItem(char *keyring, int32_t itemType, char *display_name, char *secret, Attribute **attrs, int attrcnt);
|
||||
int
|
||||
RemoveItem (char *keyring, guint32 itemid);
|
||||
int
|
||||
SetPassword (char *keyring, guint32 itemid, char *secret);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _GetKeyringsCbData
|
||||
{
|
||||
GList **keyringList;
|
||||
GMainLoop *loop;
|
||||
}GetKeyringsCbData;
|
||||
|
||||
typedef struct _GetKeyringInfoCbData
|
||||
{
|
||||
KeyringInfo *info;
|
||||
GMainLoop *loop;
|
||||
}GetKeyringInfoCbData;
|
||||
|
||||
typedef struct _GetItemsCbData
|
||||
{
|
||||
GList **itemList;
|
||||
GMainLoop *loop;
|
||||
}GetItemsCbData;
|
||||
|
||||
typedef struct _GetItemInfoCbData
|
||||
{
|
||||
ItemInfo *info;
|
||||
GMainLoop *loop;
|
||||
}GetItemInfoCbData;
|
||||
|
||||
typedef struct _GetAttributeListCbData
|
||||
{
|
||||
GList **attrList;
|
||||
GMainLoop *loop;
|
||||
}GetAttributeListCbData;
|
||||
typedef struct _OperationCompleted
|
||||
{
|
||||
char *OperationName;
|
||||
GnomeKeyringResult result;
|
||||
|
||||
}OperationCompleted;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
729
adlib/ad_gk/native/casa-gnome-keyring.h
Normal file
729
adlib/ad_gk/native/casa-gnome-keyring.h
Normal file
@@ -0,0 +1,729 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _CASA_GNOME_KEYRING_H
|
||||
#define _CASA_GNOME_KEYRING_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CASA_GNOME_KEYRING_RESULT_OK,
|
||||
CASA_GNOME_KEYRING_RESULT_DENIED,
|
||||
CASA_GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON,
|
||||
CASA_GNOME_KEYRING_RESULT_ALREADY_UNLOCKED,
|
||||
CASA_GNOME_KEYRING_RESULT_NO_SUCH_KEYRING,
|
||||
CASA_GNOME_KEYRING_RESULT_BAD_ARGUMENTS,
|
||||
CASA_GNOME_KEYRING_RESULT_IO_ERROR,
|
||||
CASA_GNOME_KEYRING_RESULT_CANCELLED,
|
||||
CASA_GNOME_KEYRING_RESULT_ALREADY_EXISTS
|
||||
} CASA_GnomeKeyringResult_T;
|
||||
|
||||
#define GNOME_KEYRING_RESULT_OK CASA_GNOME_KEYRING_RESULT_OK
|
||||
#define GNOME_KEYRING_RESULT_DENIED CASA_GNOME_KEYRING_RESULT_DENIED
|
||||
#define GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON CASA_GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON
|
||||
#define GNOME_KEYRING_RESULT_ALREADY_UNLOCKED CASA_GNOME_KEYRING_RESULT_ALREADY_UNLOCKED
|
||||
#define GNOME_KEYRING_RESULT_NO_SUCH_KEYRING CASA_GNOME_KEYRING_RESULT_NO_SUCH_KEYRING
|
||||
#define GNOME_KEYRING_RESULT_BAD_ARGUMENTS CASA_GNOME_KEYRING_RESULT_BAD_ARGUMENTS
|
||||
#define GNOME_KEYRING_RESULT_IO_ERROR CASA_GNOME_KEYRING_RESULT_IO_ERROR
|
||||
#define GNOME_KEYRING_RESULT_CANCELLED CASA_GNOME_KEYRING_RESULT_CANCELLED
|
||||
#define GNOME_KEYRING_RESULT_ALREADY_EXISTS CASA_GNOME_KEYRING_RESULT_ALREADY_EXISTS
|
||||
|
||||
#define GnomeKeyringResult CASA_GnomeKeyringResult_T
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CASA_GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||
CASA_GNOME_KEYRING_ITEM_NETWORK_PASSWORD,
|
||||
CASA_GNOME_KEYRING_ITEM_NOTE,
|
||||
CASA_GNOME_KEYRING_ITEM_LAST_TYPE,
|
||||
CASA_GNOME_KEYRING_ITEM_NO_TYPE = 0xffffffff,
|
||||
} CASA_GnomeKeyringItemType_T;
|
||||
|
||||
#define GNOME_KEYRING_ITEM_GENERIC_SECRET CASA_GNOME_KEYRING_ITEM_GENERIC_SECRET
|
||||
#define GNOME_KEYRING_ITEM_NETWORK_PASSWORD CASA_GNOME_KEYRING_ITEM_NETWORK_PASSWORD
|
||||
#define GNOME_KEYRING_ITEM_NOTE CASA_GNOME_KEYRING_ITEM_NOTE
|
||||
#define GNOME_KEYRING_ITEM_LAST_TYPE CASA_GNOME_KEYRING_ITEM_LAST_TYPE
|
||||
#define GNOME_KEYRING_ITEM_NO_TYPE CASA_GNOME_KEYRING_ITEM_NO_TYPE
|
||||
|
||||
#define GnomeKeyringItemType CASA_GnomeKeyringItemType_T
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CASA_GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
CASA_GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32
|
||||
} CASA_GnomeKeyringAttributeType_T;
|
||||
|
||||
#define GNOME_KEYRING_ATTRIBUTE_TYPE_STRING CASA_GNOME_KEYRING_ATTRIBUTE_TYPE_STRING
|
||||
#define GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 CASA_GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32
|
||||
|
||||
#define GnomeKeyringAttributeType CASA_GnomeKeyringAttributeType_T
|
||||
|
||||
typedef struct GnomeKeyringAccessControl CASA_GnomeKeyringAccessControl_T;
|
||||
typedef struct GnomeKeyringApplicationRef CASA_GnomeKeyringApplicationRef_T;
|
||||
typedef GArray CASA_GnomeKeyringAttributeList_T;
|
||||
|
||||
#define GnomeKeyringAccessControl CASA_GnomeKeyringAccessControl_T
|
||||
#define GnomeKeyringApplicationRef CASA_GnomeKeyringApplicationRef_T
|
||||
#define GnomeKeyringAttributeList CASA_GnomeKeyringAttributeList_T
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CASA_GNOME_KEYRING_ACCESS_READ = 1<<0,
|
||||
CASA_GNOME_KEYRING_ACCESS_WRITE = 1<<1,
|
||||
CASA_GNOME_KEYRING_ACCESS_REMOVE = 1<<2
|
||||
} CASA_GnomeKeyringAccessType_T;
|
||||
|
||||
#define GNOME_KEYRING_ACCESS_READ CASA_GNOME_KEYRING_ACCESS_READ
|
||||
#define GNOME_KEYRING_ACCESS_WRITE CASA_GNOME_KEYRING_ACCESS_WRITE
|
||||
#define GNOME_KEYRING_ACCESS_REMOVE CASA_GNOME_KEYRING_ACCESS_REMOVE
|
||||
|
||||
#define GnomeKeyringAccessType CASA_GnomeKeyringAccessType_T
|
||||
|
||||
|
||||
typedef struct GnomeKeyringInfo CASA_GnomeKeyringInfo_T;
|
||||
typedef struct GnomeKeyringItemInfo CASA_GnomeKeyringItemInfo_T;
|
||||
|
||||
#define GnomeKeyringInfo CASA_GnomeKeyringInfo_T
|
||||
#define GnomeKeyringItemInfo CASA_GnomeKeyringItemInfo_T
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
CASA_GnomeKeyringAttributeType_T type;
|
||||
union
|
||||
{
|
||||
char *string;
|
||||
guint32 integer;
|
||||
} value;
|
||||
} CASA_GnomeKeyringAttribute_T;
|
||||
|
||||
#define GnomeKeyringAttribute CASA_GnomeKeyringAttribute_T
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *keyring;
|
||||
guint item_id;
|
||||
CASA_GnomeKeyringAttributeList_T *attributes;
|
||||
char *secret;
|
||||
} CASA_GnomeKeyringFound_T;
|
||||
|
||||
#define GnomeKeyringFound CASA_GnomeKeyringFound_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationDoneCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationDoneCallback CASA_GnomeKeyringOperationDoneCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetStringCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
const char *string,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetStringCallback CASA_GnomeKeyringOperationGetStringCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetIntCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
guint32 val,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetIntCallback CASA_GnomeKeyringOperationGetIntCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetListCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
GList *list,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetListCallback CASA_GnomeKeyringOperationGetListCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetKeyringInfoCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
CASA_GnomeKeyringInfo_T *info,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetKeyringInfoCallback CASA_GnomeKeyringOperationGetKeyringInfoCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetItemInfoCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
CASA_GnomeKeyringItemInfo_T*info,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetItemInfoCallback CASA_GnomeKeyringOperationGetItemInfoCallback_T
|
||||
|
||||
typedef void (*CASA_GnomeKeyringOperationGetAttributesCallback_T)
|
||||
(
|
||||
CASA_GnomeKeyringResult_T result,
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
gpointer data
|
||||
);
|
||||
|
||||
#define GnomeKeyringOperationGetAttributesCallback CASA_GnomeKeyringOperationGetAttributesCallback_T
|
||||
|
||||
#define CASA_gnome_keyring_attribute_list_index(a, i) g_array_index ((a), GnomeKeyringAttribute, (i))
|
||||
#define gnome_keyring_attribute_list_index CASA_gnome_keyring_attribute_list_index
|
||||
|
||||
#define CASA_gnome_keyring_attribute_list_new() (g_array_new (FALSE, FALSE, sizeof (GnomeKeyringAttribute)))
|
||||
#define gnome_keyring_attribute_list_new CASA_gnome_keyring_attribute_list_new
|
||||
|
||||
void CASA_gnome_keyring_attribute_list_append_string
|
||||
(
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
const char *attribute,
|
||||
const char *value
|
||||
);
|
||||
|
||||
#define gnome_keyring_attribute_list_append_string CASA_gnome_keyring_attribute_list_append_string
|
||||
|
||||
void CASA_gnome_keyring_attribute_list_append_uint32
|
||||
(
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
const char *attribute,
|
||||
guint32 value
|
||||
);
|
||||
|
||||
#define gnome_keyring_attribute_list_append_uint32 CASA_gnome_keyring_attribute_list_append_uint32
|
||||
|
||||
GnomeKeyringAttributeList *CASA_gnome_keyring_attribute_list_copy
|
||||
(
|
||||
CASA_GnomeKeyringAttributeList_T *attributes
|
||||
);
|
||||
|
||||
#define gnome_keyring_attribute_list_copy CASA_gnome_keyring_attribute_list_copy
|
||||
|
||||
gboolean CASA_gnome_keyring_is_available (void);
|
||||
|
||||
#define gnome_keyring_is_available CASA_gnome_keyring_is_available
|
||||
|
||||
void CASA_gnome_keyring_free_password (char *password);
|
||||
|
||||
#define gnome_keyring_free_password CASA_gnome_keyring_free_password
|
||||
|
||||
void CASA_gnome_keyring_found_free (CASA_GnomeKeyringFound_T *found);
|
||||
|
||||
#define gnome_keyring_found_free CASA_gnome_keyring_found_free
|
||||
|
||||
void CASA_gnome_keyring_found_list_free (GList *found_list);
|
||||
|
||||
#define gnome_keyring_found_list_free CASA_gnome_keyring_found_list_free
|
||||
|
||||
void CASA_gnome_keyring_cancel_request (gpointer request);
|
||||
|
||||
#define gnome_keyring_cancel_request CASA_gnome_keyring_cancel_request
|
||||
|
||||
gpointer CASA_gnome_keyring_set_default_keyring
|
||||
(
|
||||
const char *keyring,
|
||||
CASA_GnomeKeyringOperationDoneCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_set_default_keyring CASA_gnome_keyring_set_default_keyring
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_set_default_keyring_sync
|
||||
(
|
||||
const char *keyring
|
||||
);
|
||||
|
||||
#define gnome_keyring_set_default_keyring_sync CASA_gnome_keyring_set_default_keyring_sync
|
||||
|
||||
|
||||
gpointer CASA_gnome_keyring_get_default_keyring
|
||||
(
|
||||
CASA_GnomeKeyringOperationGetStringCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_get_default_keyring CASA_gnome_keyring_get_default_keyring
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_get_default_keyring_sync
|
||||
(
|
||||
char **keyring
|
||||
);
|
||||
|
||||
#define gnome_keyring_get_default_keyring_sync CASA_gnome_keyring_get_default_keyring_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_list_keyring_names_sync
|
||||
(
|
||||
GList **keyrings
|
||||
);
|
||||
|
||||
#define gnome_keyring_list_keyring_names_sync CASA_gnome_keyring_list_keyring_names_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_lock_all
|
||||
(
|
||||
CASA_GnomeKeyringOperationDoneCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_lock_all CASA_gnome_keyring_lock_all
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_lock_all_sync(void);
|
||||
|
||||
#define gnome_keyring_lock_all_sync CASA_gnome_keyring_lock_all_sync
|
||||
|
||||
/* NULL password means ask user */
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_create_sync
|
||||
(
|
||||
const char *keyring_name,
|
||||
const char *password
|
||||
);
|
||||
|
||||
#define gnome_keyring_create_sync CASA_gnome_keyring_create_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_unlock_sync
|
||||
(
|
||||
const char *keyring,
|
||||
const char *password
|
||||
);
|
||||
|
||||
#define gnome_keyring_unlock_sync CASA_gnome_keyring_unlock_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_lock
|
||||
(
|
||||
const char *keyring,
|
||||
CASA_GnomeKeyringOperationDoneCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_lock CASA_gnome_keyring_lock
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_lock_sync
|
||||
(
|
||||
const char *keyring
|
||||
);
|
||||
|
||||
#define gnome_keyring_lock_sync CASA_gnome_keyring_lock_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_delete
|
||||
(
|
||||
const char *keyring,
|
||||
CASA_GnomeKeyringOperationDoneCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_delete CASA_gnome_keyring_delete
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_delete_sync
|
||||
(
|
||||
const char *keyring
|
||||
);
|
||||
|
||||
#define gnome_keyring_delete_sync CASA_gnome_keyring_delete_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_get_info_sync
|
||||
(
|
||||
const char *keyring,
|
||||
CASA_GnomeKeyringInfo_T **info
|
||||
);
|
||||
|
||||
#define gnome_keyring_get_info_sync CASA_gnome_keyring_get_info_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_set_info_sync
|
||||
(
|
||||
const char *keyring,
|
||||
GnomeKeyringInfo *info
|
||||
|
||||
);
|
||||
|
||||
#define gnome_keyring_set_info_sync CASA_gnome_keyring_set_info_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_list_item_ids_sync
|
||||
(
|
||||
const char *keyring,
|
||||
GList **ids
|
||||
);
|
||||
|
||||
#define gnome_keyring_list_item_ids_sync CASA_gnome_keyring_list_item_ids_sync
|
||||
|
||||
void CASA_gnome_keyring_info_free
|
||||
(
|
||||
CASA_GnomeKeyringInfo_T *keyring_info
|
||||
);
|
||||
|
||||
#define gnome_keyring_info_free CASA_gnome_keyring_info_free
|
||||
|
||||
CASA_GnomeKeyringInfo_T *CASA_gnome_keyring_info_copy
|
||||
(
|
||||
CASA_GnomeKeyringInfo_T *keyring_info
|
||||
);
|
||||
|
||||
|
||||
#define gnome_keyring_info_copy CASA_gnome_keyring_info_copy
|
||||
|
||||
void CASA_gnome_keyring_info_set_lock_on_idle
|
||||
(
|
||||
GnomeKeyringInfo *keyring_info,
|
||||
gboolean value
|
||||
);
|
||||
|
||||
|
||||
gpointer CASA_gnome_keyring_find_items
|
||||
(
|
||||
CASA_GnomeKeyringItemType_T type,
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
CASA_GnomeKeyringOperationGetListCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_items CASA_gnome_keyring_find_items
|
||||
|
||||
gpointer CASA_gnome_keyring_find_itemsv
|
||||
(
|
||||
CASA_GnomeKeyringItemType_T type,
|
||||
CASA_GnomeKeyringOperationGetListCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data,
|
||||
...
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_itemsv CASA_gnome_keyring_find_itemsv
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_find_items_sync
|
||||
(
|
||||
CASA_GnomeKeyringItemType_T type,
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
GList **found
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_items_sync CASA_gnome_keyring_find_items_sync
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_find_itemsv_sync
|
||||
(
|
||||
CASA_GnomeKeyringItemType_T type,
|
||||
GList **found,
|
||||
...
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_itemsv_sync CASA_gnome_keyring_find_itemsv_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_create_sync
|
||||
(
|
||||
const char *keyring,
|
||||
CASA_GnomeKeyringItemType_T type,
|
||||
const char *display_name,
|
||||
CASA_GnomeKeyringAttributeList_T *attributes,
|
||||
const char *secret,
|
||||
gboolean update_if_exists,
|
||||
guint32 *item_id
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_create_sync CASA_gnome_keyring_item_create_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_delete_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_delete_sync CASA_gnome_keyring_item_delete_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_get_info_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
CASA_GnomeKeyringItemInfo_T **info
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_get_info_sync CASA_gnome_keyring_item_get_info_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_set_info_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
CASA_GnomeKeyringItemInfo_T *info
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_set_info_sync CASA_gnome_keyring_item_set_info_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_get_attributes_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
CASA_GnomeKeyringAttributeList_T **attributes
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_get_attributes_sync CASA_gnome_keyring_item_get_attributes_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_set_attributes_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
CASA_GnomeKeyringAttributeList_T *attributes
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_set_attributes_sync CASA_gnome_keyring_item_set_attributes_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_item_get_acl
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
CASA_GnomeKeyringOperationGetListCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_get_acl CASA_gnome_keyring_item_get_acl
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_get_acl_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
GList **acl
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_get_acl_sync CASA_gnome_keyring_item_get_acl_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_item_set_acl
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
GList *acl,
|
||||
CASA_GnomeKeyringOperationDoneCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_set_acl CASA_gnome_keyring_item_set_acl
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_item_set_acl_sync
|
||||
(
|
||||
const char *keyring,
|
||||
guint32 id,
|
||||
GList *acl
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_set_acl_sync CASA_gnome_keyring_item_set_acl_sync
|
||||
|
||||
|
||||
CASA_GnomeKeyringItemInfo_T *CASA_gnome_keyring_item_info_copy (CASA_GnomeKeyringItemInfo_T *item_info);
|
||||
#define gnome_keyring_item_info_copy CASA_gnome_keyring_item_info_copy
|
||||
|
||||
void CASA_gnome_keyring_item_info_set_type
|
||||
(
|
||||
CASA_GnomeKeyringItemInfo_T *item_info,
|
||||
CASA_GnomeKeyringItemType_T type
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_info_set_type CASA_gnome_keyring_item_info_set_type
|
||||
|
||||
|
||||
void CASA_gnome_keyring_item_info_set_display_name
|
||||
(
|
||||
CASA_GnomeKeyringItemInfo_T *item_info,
|
||||
const char *value
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_info_set_display_name CASA_gnome_keyring_item_info_set_display_name
|
||||
|
||||
|
||||
CASA_GnomeKeyringApplicationRef_T *CASA_gnome_keyring_application_ref_new (void);
|
||||
#define gnome_keyring_application_ref_new CASA_gnome_keyring_application_ref_new
|
||||
|
||||
CASA_GnomeKeyringApplicationRef_T *CASA_gnome_keyring_application_ref_copy (const CASA_GnomeKeyringApplicationRef_T *app);
|
||||
#define gnome_keyring_application_ref_copy CASA_gnome_keyring_application_ref_copy
|
||||
|
||||
void CASA_gnome_keyring_application_ref_free (CASA_GnomeKeyringApplicationRef_T *app);
|
||||
#define gnome_keyring_application_ref_free CASA_gnome_keyring_application_ref_free
|
||||
|
||||
CASA_GnomeKeyringAccessControl_T *CASA_gnome_keyring_access_control_new
|
||||
(
|
||||
const CASA_GnomeKeyringApplicationRef_T *application,
|
||||
CASA_GnomeKeyringAccessType_T types_allowed
|
||||
);
|
||||
#define gnome_keyring_access_control_new CASA_gnome_keyring_access_control_new
|
||||
|
||||
|
||||
CASA_GnomeKeyringAccessControl_T *CASA_gnome_keyring_access_control_copy (GnomeKeyringAccessControl *ac);
|
||||
#define gnome_keyring_access_control_copy CASA_gnome_keyring_access_control_copy
|
||||
|
||||
|
||||
|
||||
void CASA_gnome_keyring_access_control_free (CASA_GnomeKeyringAccessControl_T *ac);
|
||||
#define gnome_keyring_access_control_free CASA_gnome_keyring_access_control_free
|
||||
|
||||
GList * CASA_gnome_keyring_acl_copy (GList *list);
|
||||
#define gnome_keyring_acl_copy CASA_gnome_keyring_acl_copy
|
||||
|
||||
void CASA_gnome_keyring_acl_free (GList *acl);
|
||||
#define gnome_keyring_acl_free CASA_gnome_keyring_acl_free
|
||||
|
||||
|
||||
char *CASA_gnome_keyring_item_ac_get_display_name (CASA_GnomeKeyringAccessControl_T *ac);
|
||||
#define gnome_keyring_item_ac_get_display_name CASA_gnome_keyring_item_ac_get_display_name
|
||||
|
||||
void CASA_gnome_keyring_item_ac_set_display_name
|
||||
(
|
||||
CASA_GnomeKeyringAccessControl_T *ac,
|
||||
const char *value
|
||||
);
|
||||
#define gnome_keyring_item_ac_set_display_name CASA_gnome_keyring_item_ac_set_display_name
|
||||
|
||||
char *CASA_gnome_keyring_item_ac_get_path_name (CASA_GnomeKeyringAccessControl_T *ac);
|
||||
#define gnome_keyring_item_ac_get_path_name CASA_gnome_keyring_item_ac_get_path_name
|
||||
|
||||
void CASA_gnome_keyring_item_ac_set_path_name
|
||||
(
|
||||
CASA_GnomeKeyringAccessControl_T *ac,
|
||||
const char *value
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_ac_set_path_name CASA_gnome_keyring_item_ac_set_path_name
|
||||
|
||||
|
||||
CASA_GnomeKeyringAccessType_T CASA_gnome_keyring_item_ac_get_access_type (CASA_GnomeKeyringAccessControl_T *ac);
|
||||
#define gnome_keyring_item_ac_get_access_type CASA_gnome_keyring_item_ac_get_access_type
|
||||
|
||||
void CASA_gnome_keyring_item_ac_set_access_type
|
||||
(
|
||||
CASA_GnomeKeyringAccessControl_T *ac,
|
||||
const CASA_GnomeKeyringAccessType_T value
|
||||
);
|
||||
|
||||
#define gnome_keyring_item_ac_set_access_type CASA_gnome_keyring_item_ac_set_access_type
|
||||
|
||||
/* Specialized Helpers for network passwords items */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *keyring;
|
||||
guint32 item_id;
|
||||
char *protocol;
|
||||
char *server;
|
||||
char *object;
|
||||
char *authtype;
|
||||
guint32 port;
|
||||
char *user;
|
||||
char *domain;
|
||||
char *password;
|
||||
} CASA_GnomeKeyringNetworkPasswordData_T;
|
||||
|
||||
#define GnomeKeyringNetworkPasswordData CASA_GnomeKeyringNetworkPasswordData_T
|
||||
|
||||
void CASA_gnome_keyring_network_password_free (CASA_GnomeKeyringNetworkPasswordData_T *data);
|
||||
#define gnome_keyring_network_password_free CASA_gnome_keyring_network_password_free
|
||||
|
||||
void CASA_gnome_keyring_network_password_list_free (GList *list);
|
||||
#define gnome_keyring_network_password_list_free CASA_gnome_keyring_network_password_list_free
|
||||
|
||||
gpointer CASA_gnome_keyring_find_network_password
|
||||
(
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *object,
|
||||
const char *protocol,
|
||||
const char *authtype,
|
||||
guint32 port,
|
||||
CASA_GnomeKeyringOperationGetListCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_network_password CASA_gnome_keyring_find_network_password
|
||||
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_find_network_password_sync
|
||||
(
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *object,
|
||||
const char *protocol,
|
||||
const char *authtype,
|
||||
guint32 port,
|
||||
GList **result
|
||||
);
|
||||
|
||||
#define gnome_keyring_find_network_password_sync CASA_gnome_keyring_find_network_password_sync
|
||||
|
||||
gpointer CASA_gnome_keyring_set_network_password
|
||||
(
|
||||
const char *keyring,
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *object,
|
||||
const char *protocol,
|
||||
const char *authtype,
|
||||
guint32 port,
|
||||
const char *password,
|
||||
CASA_GnomeKeyringOperationGetIntCallback_T callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_data
|
||||
);
|
||||
|
||||
#define gnome_keyring_set_network_password CASA_gnome_keyring_set_network_password
|
||||
|
||||
CASA_GnomeKeyringResult_T CASA_gnome_keyring_set_network_password_sync
|
||||
(
|
||||
const char *keyring,
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *object,
|
||||
const char *protocol,
|
||||
const char *authtype,
|
||||
guint32 port,
|
||||
const char *password,
|
||||
guint32 *item_id
|
||||
);
|
||||
|
||||
#define gnome_keyring_set_network_password_sync CASA_gnome_keyring_set_network_password_sync
|
||||
|
||||
|
||||
#endif /* _CASA_GNOME_KEYRING_H */
|
||||
15
adlib/ad_gk/native/link.lux
Normal file
15
adlib/ad_gk/native/link.lux
Normal file
@@ -0,0 +1,15 @@
|
||||
LINK = $(CPP) \
|
||||
-Wl,-Bsymbolic \
|
||||
-shared \
|
||||
-pthread\
|
||||
-O2 -fno-exceptions -fno-check-new\
|
||||
-Wl,-rpath -Wl,/usr/lib$(ARC) \
|
||||
-L/usr/lib$(ARC) -lpthread -lc -ldl \
|
||||
-L/opt/gnome/lib$(ARC) -lglib-2.0 \
|
||||
-Wl,-soname -Wl,lib$(TARGET).so.$(PROD_NUM) \
|
||||
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
|
||||
-L$(LIBDIR)$(XTRA) \
|
||||
$(OBJDIR)*.$(O)
|
||||
|
||||
|
||||
|
||||
2
adlib/ad_gk/native/objs.lux
Normal file
2
adlib/ad_gk/native/objs.lux
Normal file
@@ -0,0 +1,2 @@
|
||||
OBJS=\
|
||||
ad_gk.$(O)
|
||||
3
adlib/ad_gk/objs.lux
Normal file
3
adlib/ad_gk/objs.lux
Normal file
@@ -0,0 +1,3 @@
|
||||
OBJS=\
|
||||
AssembyInfo\
|
||||
GnomeKeyring
|
||||
3
adlib/ad_gk/src.lux
Normal file
3
adlib/ad_gk/src.lux
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC=\
|
||||
AssemblyInfo.cs\
|
||||
GnomeKeyring.cs
|
||||
80
adlib/ad_kw/AssemblyInfo.cs
Normal file
80
adlib/ad_kw/AssemblyInfo.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Novell.CASA.DataEngines.KWallet.dll")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Novell, Inc")]
|
||||
[assembly: AssemblyProduct("CASA")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.6.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
45
adlib/ad_kw/KWalletEnum.cs
Normal file
45
adlib/ad_kw/KWalletEnum.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Novell.CASA.DataEngines.KWallet
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public class EnumSecretList
|
||||
{
|
||||
|
||||
public IntPtr walletName;
|
||||
public IntPtr folderName;
|
||||
public int entryType;
|
||||
public IntPtr secretVal;
|
||||
public IntPtr next;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
193
adlib/ad_kw/KWalletNative.cs
Normal file
193
adlib/ad_kw/KWalletNative.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Novell.CASA.DataEngines.KWallet
|
||||
{
|
||||
|
||||
public class kwallet
|
||||
{
|
||||
|
||||
//private static int MAX_NAME_LENGTH = 512;
|
||||
private const string CPP_LIB = "casakwallet";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern void MyTest(
|
||||
EnumSecretList enumSecretList
|
||||
);
|
||||
|
||||
*/
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern void Aggregate(
|
||||
EnumSecretList enumSecretList
|
||||
);
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern void FreeList();
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern int SetEntry(string walletName, string folderName, int entryType, string keyName, string value, int valueLen);
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern int SetMapEntry(string walletName, string folderName, string keyName, String[,] value, int eleCount);
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern int RemoveEntry(string walletName, string folderName, string keyName);
|
||||
|
||||
/*
|
||||
public static int Try(EnumSecretList enumSecretList)
|
||||
{
|
||||
MyTest(enumSecretList);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
public static int AggregateKW(EnumSecretList enumSecretList)
|
||||
{
|
||||
Aggregate(enumSecretList);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int FreeResources()
|
||||
{
|
||||
FreeList();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static int SetSecret(string walletName, string folderName, int entryType, string keyName, string value, int valueLen )
|
||||
{
|
||||
return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen ));
|
||||
}
|
||||
|
||||
|
||||
public static int SetSecret(string walletName, string folderName, string keyName, NameValueCollection nvc)
|
||||
{
|
||||
|
||||
String[,] mapele = new String[nvc.Count,2 ];
|
||||
|
||||
for (int i=0; i< nvc.Count; i++)
|
||||
{
|
||||
mapele[i,0] = nvc.GetKey(i);
|
||||
mapele[i,1] = nvc.Get(nvc.GetKey(i));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return(SetMapEntry(walletName, folderName, keyName, mapele, nvc.Count));
|
||||
}
|
||||
|
||||
public static int DeleteSecret(string walletName, string folderName, string keyName)
|
||||
{
|
||||
return(RemoveEntry(walletName, folderName, keyName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TBD: All this for future.
|
||||
/*
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern int ReadSecret
|
||||
(
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String walletName,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String folderName,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String key,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
Byte[] secretVal
|
||||
);
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern int WriteSecret
|
||||
(
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String walletName,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String folderName,
|
||||
int entryType,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
String key,
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
Byte[] secret
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
[DllImport(CPP_LIB)]
|
||||
public static extern void CloseAllWallets();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static int ReadWallet(String walletName, String folderName, String key, Byte[] secretVal)
|
||||
{
|
||||
|
||||
// Read a secret from wallet
|
||||
return (ReadSecret(walletName, folderName, key, secretVal));
|
||||
}
|
||||
|
||||
public static int WriteWallet(String walletName, String folderName,int entryType, String key, Byte[] secretVal)
|
||||
{
|
||||
|
||||
// Write secret to wallet
|
||||
return (WriteSecret( walletName, folderName, entryType, key, secretVal));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void DisconnectApplication()
|
||||
{
|
||||
|
||||
CloseAllWallets();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
107
adlib/ad_kw/Makefile.am
Normal file
107
adlib/ad_kw/Makefile.am
Normal file
@@ -0,0 +1,107 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
CS_EXTRA_FLAGS = $(CSCFLAGS_DEBUG)
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
#SUBDIRS = native
|
||||
#DIST_SUBDIRS = native
|
||||
|
||||
EXTRA_DIST = $(CSFILES)
|
||||
|
||||
CASAROOT = ../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME =Novell.CASA.DataEngines.KWallet
|
||||
MODULE_EXT =dll
|
||||
|
||||
CSFILES = $(srcdir)/AssemblyInfo.cs \
|
||||
$(srcdir)/KWalletEnum.cs \
|
||||
$(srcdir)/KWalletNative.cs
|
||||
|
||||
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
|
||||
CS_FLAGS = $(CSC_LIBFLAG)
|
||||
CS_RESOURCES =
|
||||
CS_LIBS =
|
||||
CS_LIBPATH =
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
#OBJS = $(addprefix $(OBJDIR)/, $(CSFILES:%.dll=%.cs))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
|
||||
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) -out:$@ $(CSFILES_CSC)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
#$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(OBJS)
|
||||
# @echo [======== Linking $@ ========]
|
||||
# $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
# cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
125
adlib/ad_kw/native/Makefile.am
Normal file
125
adlib/ad_kw/native/Makefile.am
Normal file
@@ -0,0 +1,125 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS =
|
||||
DIST_SUBDIRS =
|
||||
|
||||
EXTRA_DIST = $(CXXFILES) $(CXX_MOC_FILES) *.h
|
||||
|
||||
CASAROOT = ../../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
BUILD_VER = 1.1.1
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR =
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
####this needs to be defined in configure.in
|
||||
MOC = /usr/lib/qt3/bin/moc
|
||||
CXX = g++
|
||||
|
||||
MODULE_NAME =libkwallets_rw
|
||||
MODULE_EXT =so
|
||||
|
||||
CXXFILES = $(srcdir)/kwallets_rw.cpp
|
||||
|
||||
CXX_MOC_FILES = kwallets_rw.moc
|
||||
|
||||
CXXFILES_CXX :=
|
||||
INCLUDES = -I. -I.. -I$(CASAROOT)/include \
|
||||
-I/opt/kde3/include -I/usr/lib/qt3/include -I/usr/X11R6/include -I/opt/gnome/include/gnome-keyring-1/
|
||||
CXXFLAGS = $(CPP_LIBFLAG) $(INCLUDES)
|
||||
EXTRA_CXXFLAGS = -fPIC -DPIC -DSSCS_LINUX_PLAT_F -DQT_THREAD_SUPPORT -DQT_CLEAN_NANESPACE \
|
||||
-DQT_NO_ASCII_CAS -O2 -fmessage-length=0 -Wall -g -D_REENTRANT \
|
||||
-DALIGNMENT -DN_PLAT_UNIX -DUNIX -DLINUX -DIAPX386
|
||||
CXX_RESOURCES =
|
||||
LIBS = -lpthread -ldl
|
||||
LDFLAGS = -fno-exception -fno-check-new -Wl,-Bsymbolic -shared -pthread -O2 \
|
||||
-Wl,-soname -Wl,libkwallets_rw.so.1
|
||||
|
||||
EXTRA_LDFLAGS = -L/opt/kde3/$(LIB) -lkwalletclient \
|
||||
-lqt-mt -L/usr/X11R6/$(LIB) -L/usr/lib/qt3/$(LIB) -lqt-mt
|
||||
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/, $(CXXFILES:%.cpp=%.o))
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(CXX_MOC_FILES): kwallets_rw.h
|
||||
$(MOC) $^ -o $@
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
# $(CXX) -c $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $@ $<
|
||||
c++ -c -g $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $@ $<
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER):$(CXX_MOC_FILES) $(OBJDIR) $(OBJS)
|
||||
@echo [======== Linking $@ ========]
|
||||
c++ -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(LIBS)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER)
|
||||
ln -sf $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).$(BUILD_VER) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT).1
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASALIBDIR) ] || mkdir -p $(CASALIBDIR)
|
||||
[ -d $(CASALIBDIR)/$(TARGET_CFG) ] || mkdir -p $(CASALIBDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
if [ -f $(CXX_MOC_FILES) ]; then rm -f $(CXX_MOC_FILES); fi
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
71
adlib/ad_kw/native/casa_dcop.h
Normal file
71
adlib/ad_kw/native/casa_dcop.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
// -*- c++ -*-
|
||||
#ifndef DCOPIFACEDEMO_H
|
||||
#define DCOPIFACEDEMO_H
|
||||
|
||||
|
||||
#include <qvbox.h>
|
||||
|
||||
|
||||
/**
|
||||
* Adding DCOP interface to the Console.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
struct EnumSecretList
|
||||
{
|
||||
// struct SecretInfo *sInfo;
|
||||
char *walletName;
|
||||
char *folderName;
|
||||
int entryType;
|
||||
char *secretVal;
|
||||
struct EnumSecretList *next;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class DCOPDemoWidget : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DCOPDemoWidget();
|
||||
~DCOPDemoWidget();
|
||||
|
||||
public slots:
|
||||
|
||||
int ReadAllWalletSecrets(struct EnumSecretList **);
|
||||
|
||||
private:
|
||||
|
||||
int ReadKey(Wallet *, QString, QByteArray*);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
656
adlib/ad_kw/native/kwallets_rw.cpp
Normal file
656
adlib/ad_kw/native/kwallets_rw.cpp
Normal file
@@ -0,0 +1,656 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include<stdio.h>
|
||||
#include <kapp.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include<kwallet.h>
|
||||
#include <dcopclient.h>
|
||||
#include<iostream.h>
|
||||
|
||||
#define MAX_LENGTH 256
|
||||
|
||||
using namespace KWallet;
|
||||
using namespace std;
|
||||
|
||||
#include "kwallets_rw.h"
|
||||
#include "kwallets_rw.moc"
|
||||
//#include "mytest.h"
|
||||
|
||||
|
||||
// char *applName="dcopifacedemo";
|
||||
char *applName="casaconsole";
|
||||
QStringList walletList;
|
||||
|
||||
DCOPDemoWidget *win = new DCOPDemoWidget();
|
||||
|
||||
DCOPDemoWidget::DCOPDemoWidget()
|
||||
{
|
||||
|
||||
int ret = 0;
|
||||
kapp->dcopClient()->isRegistered() ;
|
||||
if (!ret)
|
||||
{
|
||||
if(kapp->dcopClient()->registerAs( "casaconsole" ).isEmpty())
|
||||
{
|
||||
kapp->startKdeinit();
|
||||
kapp->dcopClient()->isRegistered() ;
|
||||
if (!ret)
|
||||
{
|
||||
if (kapp->dcopClient()->registerAs( "casaconsole" ).isEmpty())
|
||||
{
|
||||
printf("Cannot setup DCOP communication. Start kdeinit manually\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if ( !kapp->dcopClient()->isRegistered() ) {
|
||||
kapp->dcopClient()->registerAs( "casaconsole" );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
DCOPDemoWidget::~DCOPDemoWidget()
|
||||
{
|
||||
|
||||
for ( QStringList::Iterator walletIter = walletList.begin(); walletIter != walletList.end(); ++walletIter )
|
||||
{
|
||||
QString walletName = (*walletIter);
|
||||
Wallet::disconnectApplication(walletName,applName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int DCOPDemoWidget::ReadKey(Wallet *wallet,QString key, QByteArray *secretVal)
|
||||
{
|
||||
|
||||
// Read the secret from the entry
|
||||
QByteArray value;
|
||||
//printf("kwallet: Read Key entered\n");
|
||||
|
||||
if (wallet->readEntry(key, value)==0)
|
||||
{
|
||||
|
||||
if (value)
|
||||
{
|
||||
|
||||
*secretVal = value;
|
||||
QDataStream convert(*secretVal, IO_ReadOnly);
|
||||
|
||||
|
||||
if (wallet->entryType(key) == 1 )
|
||||
{
|
||||
|
||||
//Commented by Austin
|
||||
/* // Convert the ByteArray to QString
|
||||
QString passwd;
|
||||
printf("In read Entry Convert Final before success\n");
|
||||
convert >> passwd;
|
||||
printf("In read Entry Convert Final success\n");
|
||||
*/
|
||||
|
||||
} else if (wallet->entryType(key) == 3)
|
||||
{
|
||||
|
||||
// If the entry is of type "map"
|
||||
// Convert the ByteArray to QMap
|
||||
QMap<QString,QString> mapSecret;
|
||||
convert >> mapSecret;
|
||||
|
||||
// Iterate through each map entry.
|
||||
QMap<QString,QString>::Iterator mapIter;
|
||||
QString tempSecret = QString::fromLatin1("");
|
||||
|
||||
for ( mapIter = mapSecret.begin(); mapIter != mapSecret.end(); ++mapIter )
|
||||
{
|
||||
// This logic has to be improved
|
||||
tempSecret.append(mapIter.key().latin1());
|
||||
tempSecret.append(":");
|
||||
tempSecret.append(mapIter.data().latin1());
|
||||
|
||||
if ((++mapIter) != mapSecret.end())
|
||||
tempSecret.append(";");
|
||||
|
||||
--mapIter;
|
||||
}
|
||||
|
||||
// Convert the QString to QByteArray
|
||||
QDataStream stream(*secretVal, IO_WriteOnly);
|
||||
stream << tempSecret ;
|
||||
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
//printf("Could not read the entry..inner IF\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
//printf("Could not read the entry Inside wallet->readkey\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static struct EnumSecretList *tempEnumSecrets = NULL;
|
||||
|
||||
//void MyTest(struct EnumSecretList *enumWalletSecrets)
|
||||
void Aggregate(struct EnumSecretList *enumWalletSecrets)
|
||||
{
|
||||
|
||||
//printf("inside natiove agg");
|
||||
int retVal = 0;
|
||||
tempEnumSecrets = NULL;
|
||||
retVal = win->ReadAllWalletSecrets(&tempEnumSecrets);
|
||||
|
||||
struct EnumSecretList *iter = tempEnumSecrets;
|
||||
//struct EnumSecretList *head = tempEnumSecrets;
|
||||
/*
|
||||
if (iter == NULL)
|
||||
{
|
||||
|
||||
printf("Native has given NULLLL\n");
|
||||
enumWalletSecrets = NULL;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
while (iter != NULL)
|
||||
{
|
||||
|
||||
/*
|
||||
printf("\n\n**Wallet Name : %s\n",iter->walletName);
|
||||
printf("\t**Folder Name : %s\n",iter->folderName);
|
||||
printf("\t\t**Secret Type : %d\n",iter->entryType);
|
||||
printf("\t\t\t**Secret Value : %s\n",iter->secretVal);
|
||||
*/
|
||||
|
||||
enumWalletSecrets->walletName = iter->walletName;
|
||||
enumWalletSecrets->folderName = iter->folderName;
|
||||
enumWalletSecrets->secretVal = iter->secretVal;
|
||||
enumWalletSecrets->entryType = iter->entryType;
|
||||
enumWalletSecrets->next = iter->next;
|
||||
|
||||
iter = iter->next;
|
||||
if (iter != NULL)
|
||||
{
|
||||
enumWalletSecrets = enumWalletSecrets->next ;
|
||||
}
|
||||
else
|
||||
{
|
||||
enumWalletSecrets = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
// Free the list
|
||||
struct EnumSecretList *temp;
|
||||
while (head != NULL)
|
||||
{
|
||||
free(head->walletName);
|
||||
free(head->folderName);
|
||||
free(head->secretVal);
|
||||
//free(head->entryType);
|
||||
temp = head->next;
|
||||
free(head);
|
||||
head = temp;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
char * GetDefaultWallet()
|
||||
{
|
||||
char *homedir = NULL;
|
||||
char *defaultwallet = NULL;
|
||||
char *str1 = "Default Wallet=";
|
||||
char str[MAX_LENGTH];
|
||||
FILE *fs = NULL;
|
||||
int i,j,k;
|
||||
|
||||
defaultwallet = (char *)malloc(MAX_LENGTH);
|
||||
homedir = (char *)malloc(MAX_LENGTH);
|
||||
|
||||
strcpy(homedir, getenv("HOME"));
|
||||
strcat(homedir, "/.kde/share/config/kwalletrc");
|
||||
strcat(homedir,"\0");
|
||||
|
||||
fs = fopen(homedir,"r");
|
||||
if(fs == NULL)
|
||||
{
|
||||
free (homedir);
|
||||
free (defaultwallet);
|
||||
return "kdewallet";
|
||||
}
|
||||
while(!feof(fs))
|
||||
{
|
||||
fgets(str,MAX_LENGTH,fs);
|
||||
for(i=0; str[i] && str1[i]; i++)
|
||||
{
|
||||
if(str[i] == str1[i])
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if(i==strlen(str1))
|
||||
{
|
||||
for(j=i,k=0;j<strlen(str);j++,k++)
|
||||
defaultwallet[k] = str[j];
|
||||
defaultwallet[k-1] = '\0';
|
||||
free(homedir);
|
||||
return defaultwallet;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
free(homedir);
|
||||
return "kdewallet";
|
||||
}
|
||||
|
||||
int RemoveEntry(char *name, char *foldername, char *keyname)
|
||||
{
|
||||
DCOPDemoWidget kw;
|
||||
return(kw.RemoveEntry(name,foldername,keyname));
|
||||
}
|
||||
int SetEntry(char *name, char *foldername, int entryType, char *keyname, char *value, int valueLen )
|
||||
{
|
||||
char *dwallet = NULL;
|
||||
dwallet = (char *)malloc(MAX_LENGTH);
|
||||
dwallet = GetDefaultWallet(); //function called here
|
||||
DCOPDemoWidget kw;
|
||||
//printf("kwallet : In Set Entry\n");
|
||||
return(kw.SetEntry(dwallet,foldername,entryType,keyname,value,valueLen));
|
||||
}
|
||||
int SetMapEntry(char *name, char *foldername, char *keyname, char **value, int eleCount )
|
||||
{
|
||||
char *dwallet = NULL;
|
||||
dwallet = (char *)malloc(MAX_LENGTH);
|
||||
dwallet = GetDefaultWallet(); //function called here
|
||||
DCOPDemoWidget kw;
|
||||
//printf("kwallet: SetMapEntry\n");
|
||||
return(kw.SetMap(dwallet,foldername,keyname,value,eleCount));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void FreeList()
|
||||
{
|
||||
|
||||
struct EnumSecretList *head = tempEnumSecrets;
|
||||
|
||||
// Free the list
|
||||
struct EnumSecretList *temp;
|
||||
while (head != NULL)
|
||||
{
|
||||
free(head->walletName);
|
||||
free(head->folderName);
|
||||
free(head->secretVal);
|
||||
//free(head->entryType);
|
||||
temp = head->next;
|
||||
free(head);
|
||||
head = temp;
|
||||
}
|
||||
tempEnumSecrets = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int DCOPDemoWidget::ReadAllWalletSecrets(struct EnumSecretList **enumWalletSecrets)
|
||||
{
|
||||
|
||||
walletList = Wallet::walletList();
|
||||
for ( QStringList::Iterator walletIter = walletList.begin(); walletIter != walletList.end(); ++walletIter )
|
||||
{
|
||||
QString walletName = (*walletIter);
|
||||
// printf("The wallet name is %s\n",(*walletIter).latin1());
|
||||
|
||||
|
||||
// Open the wallet
|
||||
Wallet *wallet = NULL;
|
||||
wallet = Wallet::openWallet(walletName,0,Wallet::Synchronous);
|
||||
|
||||
if (wallet == NULL)
|
||||
{
|
||||
//printf("Could not open the wallet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the folder list of the wallet
|
||||
QStringList folderList = wallet->folderList();
|
||||
|
||||
for ( QStringList::Iterator folderIter = folderList.begin(); folderIter != folderList.end(); ++folderIter)
|
||||
{
|
||||
|
||||
// printf("\t%s\n",(*folderIter).latin1());
|
||||
QString folderName = (*folderIter);
|
||||
|
||||
// Set the current folder
|
||||
if (!(wallet->setFolder(folderName)))
|
||||
{
|
||||
//printf("Could not set the folder\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the list of entries in the folder
|
||||
QStringList entryList = wallet->entryList();
|
||||
|
||||
for ( QStringList::Iterator entryIter = entryList.begin(); entryIter != entryList.end(); ++entryIter)
|
||||
{
|
||||
//printf("Entry Name : \t\t%s\n",(*entryIter).latin1());
|
||||
|
||||
// Read the secret from the entry
|
||||
QString key = (*entryIter);
|
||||
|
||||
QByteArray *secretVal = new QByteArray();
|
||||
if (ReadKey(wallet,key,secretVal) != 0)
|
||||
{
|
||||
//printf("Could not read \"%s\"\n",key.latin1());
|
||||
break;
|
||||
//FIXME
|
||||
}
|
||||
|
||||
struct EnumSecretList *tempWalletSecrets = (struct EnumSecretList*)malloc(sizeof(struct EnumSecretList));
|
||||
|
||||
if (tempWalletSecrets == NULL) {
|
||||
//printf("Memory Allocation failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tempWalletSecrets->walletName = (char*)malloc(512);
|
||||
|
||||
if (tempWalletSecrets->walletName == NULL)
|
||||
{
|
||||
//printf("Memory Allocation failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//printf("Wallet Name is %s\n",walletName.latin1());
|
||||
strcpy(tempWalletSecrets->walletName, walletName.latin1());
|
||||
tempWalletSecrets->folderName = (char*)malloc(512);
|
||||
|
||||
if (tempWalletSecrets->folderName == NULL)
|
||||
{
|
||||
//printf("Memory Allocation failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// printf("Folder Name is %s\n",folderName.latin1());
|
||||
|
||||
strcpy(tempWalletSecrets->folderName, folderName.latin1());
|
||||
tempWalletSecrets->entryType = wallet->entryType(key);
|
||||
// printf("EntryType is %d\n",wallet->entryType(key));
|
||||
|
||||
|
||||
if (*enumWalletSecrets == NULL)
|
||||
{
|
||||
*enumWalletSecrets = tempWalletSecrets;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct EnumSecretList *iter;
|
||||
for(iter=*enumWalletSecrets; iter->next!=NULL; iter=iter->next);
|
||||
iter->next = tempWalletSecrets;
|
||||
}
|
||||
|
||||
tempWalletSecrets->next = NULL;
|
||||
|
||||
|
||||
|
||||
//Commented by Austin
|
||||
QDataStream convert(*secretVal, IO_ReadOnly);
|
||||
QString passwd;
|
||||
convert >> passwd;
|
||||
//QString passwd(*secretVal);
|
||||
//printf("kwallet : ReadAll key %s value %s \n",key.latin1(), passwd.latin1());
|
||||
tempWalletSecrets->secretVal = (char*)malloc(512);
|
||||
|
||||
if (tempWalletSecrets->secretVal == NULL)
|
||||
{
|
||||
//printf("Memory Allocation failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(tempWalletSecrets->secretVal,key.latin1());
|
||||
//printf("After strcpy - 1 - key is %s\n",key.latin1());
|
||||
strcat(tempWalletSecrets->secretVal,"=");
|
||||
//printf("After strcat = \n");
|
||||
if(passwd)
|
||||
{
|
||||
//printf("Passwd is %s\n",passwd.latin1());
|
||||
strcat(tempWalletSecrets->secretVal,passwd.latin1());
|
||||
}
|
||||
|
||||
// Free memory
|
||||
free(secretVal);
|
||||
// printf("After free\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Print all the secrets
|
||||
/*
|
||||
struct EnumSecretList *iter = *enumWalletSecrets;
|
||||
while (iter != NULL)
|
||||
{
|
||||
printf("\n\nWallet Name : %s\n",iter->walletName);
|
||||
printf("\tFolder Name : %s\n",iter->folderName);
|
||||
printf("\t\tSecret Type : %d\n",iter->entryType);
|
||||
printf("\t\t\t Secret Value : %s\n",iter->secretVal);
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
int DCOPDemoWidget::SetEntry(char *name, char *foldername, int entryType, char *keyname, char *value, int valueLen )
|
||||
{
|
||||
|
||||
QString qWalletName(name);
|
||||
QString qKey(keyname);
|
||||
QString qFolderName(foldername);
|
||||
|
||||
QString &refQKey = qKey;
|
||||
|
||||
// Open the wallet
|
||||
Wallet *wallet = NULL;
|
||||
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
|
||||
if (wallet == NULL)
|
||||
{
|
||||
//printf("Could not open the wallet %s \n", qWalletName.latin1());
|
||||
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
|
||||
}
|
||||
if (wallet->setFolder(qFolderName) == false)
|
||||
{
|
||||
//printf("Could not open the folder %s \n", qFolderName.latin1());
|
||||
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
|
||||
}
|
||||
QString unicodeValue = tr(value);
|
||||
// Read the secret from the entry
|
||||
//QByteArray secretVal(valueLen *2 );
|
||||
|
||||
QByteArray secretVal;
|
||||
QDataStream ds(secretVal, IO_WriteOnly);
|
||||
ds << unicodeValue;
|
||||
|
||||
/*for(int i=0; i< valueLen; i++)
|
||||
{
|
||||
secretVal[i] = 0;
|
||||
secretVal[i+1] = value[i];
|
||||
}
|
||||
*/
|
||||
//secretVal[valueLen] = '\0';
|
||||
|
||||
// secretVal.fill('a');
|
||||
//secretVal.setRawData(value,valueLen);
|
||||
QByteArray &refSecretVal = secretVal;
|
||||
|
||||
//QDataStream convert( secretVal, IO_WriteOnly );
|
||||
//convert.readBytes( value, (uint)valueLen);
|
||||
// Wallet::EntryType MyEntryType = 3;
|
||||
if (wallet->entryType(qKey) != 3)
|
||||
{
|
||||
//printf("kwallet : SetEntry : Before setting Entry key %s value = %s EntryType =%d \n" , qKey.latin1() , value, entryType );
|
||||
if (wallet->writeEntry(refQKey, refSecretVal , (Wallet::EntryType) entryType ) != 0)
|
||||
{
|
||||
return KWALLET_RESULT_CANNOT_WRITE_ENTRY;
|
||||
}
|
||||
}
|
||||
// Free memory
|
||||
wallet->sync();
|
||||
return KWALLET_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
int DCOPDemoWidget::SetMap(char *name, char *foldername, char *keyname, char **value, int numOfKeys )
|
||||
{
|
||||
QString qWalletName(name);
|
||||
QString qKey(keyname);
|
||||
QString qFolderName(foldername);
|
||||
//printf("kwallet : SetMap : Wallet %s Folder %s Key =%s\n", name, foldername, keyname);
|
||||
|
||||
|
||||
// Open the wallet
|
||||
Wallet *wallet = NULL;
|
||||
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
|
||||
if (wallet == NULL)
|
||||
{
|
||||
//printf("Could not open the wallet\n");
|
||||
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
|
||||
}
|
||||
|
||||
|
||||
if (wallet->hasFolder(qFolderName) == false)
|
||||
{
|
||||
if(wallet->createFolder(qFolderName) == false)
|
||||
{
|
||||
return KWALLET_RESULT_CANNOT_CREATE_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
if (wallet->setFolder(qFolderName) == false)
|
||||
{
|
||||
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
|
||||
}
|
||||
|
||||
QMap<QString,QString> mapSecret;
|
||||
for (int i=0; i < numOfKeys * 2; i+=2)
|
||||
{
|
||||
QString mapelekey((char *)value[i]);
|
||||
QString mapelevalue((char *)value[i+1]);
|
||||
mapSecret.insert(mapelekey,mapelevalue);
|
||||
}
|
||||
if (wallet->writeMap(qKey,mapSecret) != 0 )
|
||||
{
|
||||
return KWALLET_RESULT_CANNOT_WRITE_ENTRY;
|
||||
}
|
||||
wallet->sync();
|
||||
return KWALLET_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DCOPDemoWidget::RemoveEntry(char *name, char *foldername, char *keyname )
|
||||
{
|
||||
|
||||
QString qWalletName(name);
|
||||
QString qKey(keyname);
|
||||
QString qFolderName(foldername);
|
||||
//printf("In DCOPDemoWidget:RemoveEntry\n");
|
||||
//printf("In DCOPDemoWidget:False %d\n",false);
|
||||
//printf("In DCOPDemoWidget:False %d\n",FALSE);
|
||||
|
||||
// Open the wallet
|
||||
Wallet *wallet = NULL;
|
||||
wallet = Wallet::openWallet(qWalletName,0,Wallet::Synchronous);
|
||||
if (wallet == NULL)
|
||||
{
|
||||
//printf("Could not open the wallet %s \n", qWalletName.latin1());
|
||||
return KWALLET_RESULT_CANNOT_OPEN_WALLET;
|
||||
}
|
||||
if (wallet->setFolder(qFolderName) == false)
|
||||
{
|
||||
//printf("Could not set the folder %s \n", qFolderName.latin1());
|
||||
return KWALLET_RESULT_CANNOT_OPEN_FOLDER;
|
||||
}
|
||||
if (wallet->removeEntry(qKey) != 0)
|
||||
{
|
||||
//printf("Could not remove Entry %s \n", qKey.latin1());
|
||||
return KWALLET_RESULT_CANNOT_REMOVE_ENTRY;
|
||||
}
|
||||
wallet->sync();
|
||||
//printf("In DCOPDemoWidget:RemoveEntry Exit\n");
|
||||
return KWALLET_RESULT_OK;
|
||||
}
|
||||
|
||||
97
adlib/ad_kw/native/kwallets_rw.h
Normal file
97
adlib/ad_kw/native/kwallets_rw.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
// -*- c++ -*-
|
||||
#ifndef DCOPIFACEDEMO_H
|
||||
#define DCOPIFACEDEMO_H
|
||||
#include <qvbox.h>
|
||||
|
||||
|
||||
enum KWalletResult
|
||||
{ KWALLET_RESULT_OK,
|
||||
|
||||
KWALLET_RESULT_CANNOT_OPEN_WALLET,
|
||||
KWALLET_RESULT_CANNOT_OPEN_FOLDER,
|
||||
KWALLET_RESULT_CANNOT_WRITE_ENTRY,
|
||||
KWALLET_RESULT_MALFORMED_XML,
|
||||
KWALLET_RESULT_CANNOT_CREATE_FOLDER,
|
||||
KWALLET_RESULT_CANNOT_CREATE_WALLET,
|
||||
KWALLET_RESULT_CANNOT_REMOVE_ENTRY,
|
||||
KWALLET_RESULT_UNKNOWN_ERROR
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adding DCOP interface to an app.
|
||||
*/
|
||||
|
||||
|
||||
struct EnumSecretList
|
||||
{
|
||||
char *walletName;
|
||||
char *folderName;
|
||||
int entryType;
|
||||
char *secretVal;
|
||||
struct EnumSecretList *next;
|
||||
};
|
||||
|
||||
|
||||
struct TryEnumSecretList
|
||||
{
|
||||
char *name;
|
||||
struct TryEnumSecretList *next;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class DCOPDemoWidget : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DCOPDemoWidget();
|
||||
~DCOPDemoWidget();
|
||||
|
||||
public slots:
|
||||
|
||||
// void dump();
|
||||
int ReadAllWalletSecrets(struct EnumSecretList **);
|
||||
// int ReadWalletSecret(QString, QString, QString, QByteArray*);
|
||||
// int WriteWalletSecret(QString, QString, QString, QByteArray , int);
|
||||
int SetEntry(char *, char *, int , char *, char *, int);
|
||||
int SetMap(char *, char *, char *, char** , int );
|
||||
int RemoveEntry(char *, char *, char *);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int ReadKey(Wallet*, QString, QByteArray*);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
14
adlib/ad_kw/native/link.lux
Normal file
14
adlib/ad_kw/native/link.lux
Normal file
@@ -0,0 +1,14 @@
|
||||
LINK = $(CPP) \
|
||||
-Wl,-Bsymbolic \
|
||||
-shared \
|
||||
-pthread \
|
||||
-O2 -fno-exceptions -fno-check-new \
|
||||
-Wl,-rpath -Wl,/usr/lib$(ARC) \
|
||||
-L/usr/lib$(ARC) -lpthread -lc -ldl \
|
||||
-L/opt/kde3/lib$(ARC) -lkwalletclient -lqt-mt \
|
||||
-L/usr/X11R6/lib$(ARC) \
|
||||
-L/usr/lib/qt3/lib$(ARC) -lqt-mt \
|
||||
-Wl,-soname -Wl,lib$(TARGET).so.$(PROD_NUM) \
|
||||
-o $(LIBDIR)$(XTRA)/lib$(TARGET).so.$(BLD_VER) \
|
||||
-L$(LIBDIR)$(XTRA) \
|
||||
$(OBJDIR)*.$(O)
|
||||
2
adlib/ad_kw/native/objs.lux
Normal file
2
adlib/ad_kw/native/objs.lux
Normal file
@@ -0,0 +1,2 @@
|
||||
OBJS=\
|
||||
kwallets_rw.$(O)
|
||||
4
adlib/ad_kw/objs.lux
Normal file
4
adlib/ad_kw/objs.lux
Normal file
@@ -0,0 +1,4 @@
|
||||
OBJS=\
|
||||
AssemblyInfo\
|
||||
KWalletEnum\
|
||||
KWalletNative
|
||||
4
adlib/ad_kw/src.lux
Normal file
4
adlib/ad_kw/src.lux
Normal file
@@ -0,0 +1,4 @@
|
||||
SRC=\
|
||||
AssemblyInfo.cs\
|
||||
KWalletEnum.cs\
|
||||
KWalletNative.cs
|
||||
408
adlib/miCASAEngine.cs
Normal file
408
adlib/miCASAEngine.cs
Normal file
@@ -0,0 +1,408 @@
|
||||
/***********************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Novell.CASA;
|
||||
using System.Collections.Specialized;
|
||||
using Novell.CASA.DataEngines.Common;
|
||||
|
||||
|
||||
|
||||
namespace Novell.CASA.DataEngines
|
||||
{
|
||||
|
||||
/*
|
||||
* This class is implementation of Data engine for miCASA.
|
||||
*/
|
||||
|
||||
//TBD: Generally we need to find out if fault is in parameter or miCASA or not available
|
||||
|
||||
class miCASAEngine : DataEngine
|
||||
{
|
||||
|
||||
public SecretStore store = null;
|
||||
|
||||
public miCASAEngine()
|
||||
{
|
||||
|
||||
//TBD: What happens here at miCASA end ?
|
||||
store = SecretStore.getInstance();
|
||||
}
|
||||
|
||||
public XmlNode Aggregate()
|
||||
{
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlElement key1;
|
||||
XmlAttribute Atr;
|
||||
XmlElement value1;
|
||||
XmlElement mi_secret;
|
||||
XmlAttribute synchAttr;
|
||||
XmlAttribute secidAttr;
|
||||
String sKey, sValue;
|
||||
|
||||
|
||||
//Adding miCASA Top Node
|
||||
XmlElement elem = doc.CreateElement(ConstStrings.miCASA);
|
||||
doc.AppendChild(elem);
|
||||
|
||||
|
||||
StringCollection sc = store.enumerateSecretIDs();
|
||||
if (sc != null)
|
||||
{
|
||||
// Adding Keychain
|
||||
XmlElement keychain = doc.CreateElement(ConstStrings.CCF_KEYCHAIN);
|
||||
XmlAttribute id_attr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
id_attr.Value = ConstStrings.CCF_KEYCHAINNAME;
|
||||
keychain.SetAttributeNode(id_attr);
|
||||
elem.AppendChild(keychain);
|
||||
|
||||
|
||||
StringEnumerator se = sc.GetEnumerator();
|
||||
se.Reset();
|
||||
|
||||
while (se.MoveNext())
|
||||
{
|
||||
|
||||
Secret secret = store.getSecret(se.Current);
|
||||
NameValueCollection nvc = secret.getKeyValueCollection();
|
||||
|
||||
mi_secret = doc.CreateElement(ConstStrings.CCF_SECRET);
|
||||
synchAttr = doc.CreateAttribute(ConstStrings.CCF_SYNCH);
|
||||
//TBD:
|
||||
synchAttr.Value = "Persistent Secret" ;
|
||||
secidAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
secidAttr.Value = se.Current;
|
||||
mi_secret.SetAttributeNode(secidAttr);
|
||||
mi_secret.SetAttributeNode(synchAttr);
|
||||
|
||||
|
||||
for (int i = 0; i < nvc.Count; i++)
|
||||
{
|
||||
|
||||
sKey = nvc.GetKey(i);
|
||||
sValue = nvc.Get(sKey);
|
||||
|
||||
//Key
|
||||
key1 = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
Atr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
|
||||
Atr.Value = sKey;
|
||||
key1.SetAttributeNode(Atr);
|
||||
|
||||
//Value
|
||||
value1 = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
value1.InnerText = sValue;
|
||||
|
||||
key1.AppendChild(value1);
|
||||
|
||||
mi_secret.AppendChild(key1);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
//Time
|
||||
XmlElement Time1 = doc.CreateElement(ConstStrings.CCF_TIME);
|
||||
|
||||
XmlElement zone1 = doc.CreateElement(ConstStrings.CCF_ZONE);
|
||||
zone1.InnerText = "IST";
|
||||
|
||||
XmlElement cr1 = doc.CreateElement(ConstStrings.CCF_CRTIME);
|
||||
cr1.InnerText = null;
|
||||
|
||||
XmlElement mod1 = doc.CreateElement(ConstStrings.CCF_MDTIME);
|
||||
mod1.InnerText = null;
|
||||
|
||||
XmlElement acc1 = doc.CreateElement(ConstStrings.CCF_ACTIME);
|
||||
acc1.InnerText = null;
|
||||
|
||||
Time1.AppendChild(zone1);
|
||||
Time1.AppendChild(cr1);
|
||||
Time1.AppendChild(mod1);
|
||||
Time1.AppendChild(acc1);
|
||||
|
||||
mi_secret.AppendChild(Time1);
|
||||
*/
|
||||
|
||||
//Finally Add Secret to Elem
|
||||
keychain.AppendChild(mi_secret);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return doc.ChildNodes[0];
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal bool KeyInNewList(NameValueCollection nvc, string key)
|
||||
{
|
||||
if (nvc != null)
|
||||
{
|
||||
for (int i = 0; i < nvc.Count; i++)
|
||||
{
|
||||
string sKey = nvc.GetKey(i);
|
||||
if( key == sKey )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
return SetSecret(secret);
|
||||
|
||||
}
|
||||
|
||||
public int SetSecret(XmlNode secret)
|
||||
{
|
||||
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
Secret secretVal = store.getSecret(secretid);
|
||||
|
||||
NameValueCollection nvc = secretVal.getKeyValueCollection();
|
||||
ArrayList existingKeyList;
|
||||
|
||||
if (nvc.Count == 0)
|
||||
{
|
||||
existingKeyList = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingKeyList = new ArrayList();
|
||||
}
|
||||
|
||||
for(int i = 0; i < nvc.Count; i++ )
|
||||
{
|
||||
existingKeyList.Add(nvc.GetKey(i));
|
||||
}
|
||||
|
||||
XmlNodeList keylist = secret.SelectNodes("descendant::Key");
|
||||
|
||||
NameValueCollection newNVC = new System.Collections.Specialized.NameValueCollection();
|
||||
|
||||
foreach (XmlNode tuple in keylist)
|
||||
{
|
||||
//Get the Key
|
||||
XmlAttributeCollection at = tuple.Attributes;
|
||||
String keyname = (at["ID"]).InnerText;
|
||||
newNVC.Add(keyname, tuple.ChildNodes[0].InnerText);
|
||||
}
|
||||
|
||||
if(null != existingKeyList)
|
||||
{
|
||||
IEnumerator etor = existingKeyList.GetEnumerator();
|
||||
while( etor.MoveNext() )
|
||||
{
|
||||
string key = (string)etor.Current;
|
||||
if(KeyInNewList(newNVC,key) == false)
|
||||
{
|
||||
secretVal.removeKey(key,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0 ; i < newNVC.Count ; i++)
|
||||
{
|
||||
string key = newNVC.GetKey(i);
|
||||
secretVal.setKeyValuePair(key,newNVC.Get(key));
|
||||
}
|
||||
|
||||
// TBD: Return Value ??
|
||||
store.setSecret(0, secretVal, Secret.SS_CREDSET);
|
||||
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public int GetSecret(XmlNode secret)
|
||||
{
|
||||
XmlDocument doc;
|
||||
XmlElement key1;
|
||||
XmlAttribute Atr;
|
||||
XmlElement value1;
|
||||
XmlElement mi_secret;
|
||||
XmlAttribute synchAttr;
|
||||
XmlAttribute secidAttr;
|
||||
String sKey, sValue;
|
||||
|
||||
|
||||
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
|
||||
Secret secretVal = store.getSecret(secretid);
|
||||
NameValueCollection nvc = secretVal.getKeyValueCollection();
|
||||
|
||||
if (nvc.Count == 0)
|
||||
{
|
||||
//Console.WriteLine("Secret got deleted, ID is " + secretid) ;
|
||||
return ConstStrings.CASA_DATA_UNAVAILABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("Got the secret from miCASA.");
|
||||
doc = secret.OwnerDocument;
|
||||
XmlNode root = secret.ParentNode;
|
||||
XmlNode keychain = secret.ParentNode;
|
||||
|
||||
// Delete the Secret Node.
|
||||
root.RemoveChild(secret);
|
||||
|
||||
mi_secret = doc.CreateElement(ConstStrings.CCF_SECRET);
|
||||
synchAttr = doc.CreateAttribute("Synch");
|
||||
synchAttr.Value = "Persistent Secret";
|
||||
secidAttr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
secidAttr.Value = secretid;
|
||||
mi_secret.SetAttributeNode(secidAttr);
|
||||
mi_secret.SetAttributeNode(synchAttr);
|
||||
|
||||
for (int i = 0; i < nvc.Count; i++)
|
||||
{
|
||||
|
||||
sKey = nvc.GetKey(i);
|
||||
sValue = nvc.Get(sKey);
|
||||
|
||||
//Key
|
||||
key1 = doc.CreateElement(ConstStrings.CCF_KEY);
|
||||
Atr = doc.CreateAttribute(ConstStrings.CCF_ID);
|
||||
Atr.Value = sKey;
|
||||
key1.SetAttributeNode(Atr);
|
||||
|
||||
//Value
|
||||
value1 = doc.CreateElement(ConstStrings.CCF_VALUE);
|
||||
value1.InnerText = sValue;
|
||||
|
||||
key1.AppendChild(value1);
|
||||
|
||||
mi_secret.AppendChild(key1);
|
||||
|
||||
//Console.WriteLine(sKey + " = " + sValue);
|
||||
}
|
||||
|
||||
|
||||
//Time
|
||||
XmlElement Time1 = doc.CreateElement(ConstStrings.CCF_TIME);
|
||||
|
||||
XmlElement zone1 = doc.CreateElement(ConstStrings.CCF_ZONE);
|
||||
zone1.InnerText = "IST";
|
||||
|
||||
XmlElement cr1 = doc.CreateElement(ConstStrings.CCF_CRTIME);
|
||||
cr1.InnerText = null;
|
||||
|
||||
XmlElement mod1 = doc.CreateElement(ConstStrings.CCF_MDTIME);
|
||||
mod1.InnerText = null;
|
||||
|
||||
XmlElement acc1 = doc.CreateElement(ConstStrings.CCF_ACTIME);
|
||||
acc1.InnerText = null;
|
||||
|
||||
Time1.AppendChild(zone1);
|
||||
Time1.AppendChild(cr1);
|
||||
Time1.AppendChild(mod1);
|
||||
Time1.AppendChild(acc1);
|
||||
|
||||
mi_secret.AppendChild(Time1);
|
||||
|
||||
//Finally Add Secret to Elem
|
||||
keychain.AppendChild(mi_secret);
|
||||
|
||||
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
|
||||
XmlAttributeCollection atcol = secret.Attributes;
|
||||
String secretid = atcol["ID"].InnerXml;
|
||||
|
||||
//TBD: Why no other overloaded API
|
||||
store.removeSecret(secretid.Substring(secretid.IndexOf(":")+1), Secret.SS_CREDSET);
|
||||
|
||||
|
||||
XmlNode root = secret.ParentNode;
|
||||
root.RemoveChild(secret);
|
||||
|
||||
return ConstStrings.CASA_SUCCESS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
adlib/objs.lux
Normal file
11
adlib/objs.lux
Normal file
@@ -0,0 +1,11 @@
|
||||
OBJS=\
|
||||
AssemblyInfo\
|
||||
Common\
|
||||
IDataEngine\
|
||||
miCASAEngine\
|
||||
AD_Facade\
|
||||
KWalletEngine\
|
||||
GKEngine \
|
||||
FFEngine \
|
||||
../c_gui/Logger
|
||||
|
||||
7
adlib/objs.w32
Normal file
7
adlib/objs.w32
Normal file
@@ -0,0 +1,7 @@
|
||||
OBJS=\
|
||||
Common\
|
||||
IDataEngine\
|
||||
miCASAEngine\
|
||||
AD_Facade\
|
||||
..\\c_gui\\Logger.cs
|
||||
|
||||
10
adlib/src.lux
Normal file
10
adlib/src.lux
Normal file
@@ -0,0 +1,10 @@
|
||||
SRC=\
|
||||
AssemblyInfo.cs\
|
||||
Common.cs\
|
||||
IDataEngine.cs\
|
||||
miCASAEngine.cs\
|
||||
AD_Facade.cs\
|
||||
KWalletEngine.cs\
|
||||
GKEngine.cs \
|
||||
FFEngine.cs \
|
||||
../c_gui/Logger.cs
|
||||
6
adlib/src.w32
Normal file
6
adlib/src.w32
Normal file
@@ -0,0 +1,6 @@
|
||||
SRC=\
|
||||
Common.cs\
|
||||
IDataEngine.cs\
|
||||
miCASAEngine.cs\
|
||||
AD_Facade.cs\
|
||||
..\\c_gui\\Logger.cs
|
||||
Reference in New Issue
Block a user