- Added Modify and Delete functionalities for Firefox Password
Manager Secrets into CASAManager.
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Novell.CASA.DataEngines
|
||||
//for firefox below.
|
||||
kwEngine = new KWalletEngine();
|
||||
gkEngine = new GKEngine();
|
||||
//ffEngine = new FFEngine();
|
||||
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
|
||||
@@ -245,6 +245,8 @@ namespace Novell.CASA.DataEngines
|
||||
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
|
||||
{
|
||||
@@ -355,6 +357,8 @@ namespace Novell.CASA.DataEngines
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -76,10 +76,12 @@ namespace Novell.CASA.DataEngines.Common
|
||||
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_FFPROFILE = "Profile";
|
||||
public static string CCF_PASSWDSTATUS = "PasswordStatus";
|
||||
|
||||
//Add Operation Types on CCF
|
||||
public static int OPERATION_ADD_SECRET = 0;
|
||||
public static int OPERATION_ADD_SECRET = 0;
|
||||
public static int OPERATION_DELETE_SECRET = 1;
|
||||
public static int OPERATION_MODIFY_SECRET = 2;
|
||||
|
||||
|
||||
|
||||
@@ -130,7 +130,52 @@ namespace Novell.CASA.DataEngines
|
||||
|
||||
public int SetSecret(XmlNode secret, int opnType)
|
||||
{
|
||||
return (int)FireFoxResultExtended.FIREFOX_RESULT_ERROR_UNKNOWN;
|
||||
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)
|
||||
@@ -140,7 +185,11 @@ namespace Novell.CASA.DataEngines
|
||||
|
||||
public int Remove(XmlNode secret)
|
||||
{
|
||||
return (int)FireFoxResultExtended.FIREFOX_RESULT_ERROR_UNKNOWN;
|
||||
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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -253,6 +302,7 @@ namespace Novell.CASA.DataEngines
|
||||
|
||||
XmlElement xmlKeyElement = null;
|
||||
XmlAttribute keyIdAttr = null;
|
||||
XmlAttribute keyPasswdStatusAttr = null;
|
||||
XmlElement xmlValueElement = null;
|
||||
|
||||
name = (String)Marshal.PtrToStringAnsi(hostElementList.name);
|
||||
@@ -267,6 +317,13 @@ namespace Novell.CASA.DataEngines
|
||||
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>
|
||||
@@ -326,6 +383,33 @@ namespace Novell.CASA.DataEngines
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -167,16 +167,34 @@ public class HostElement
|
||||
//Signon functions
|
||||
[DllImport("libad_ff.so.1.1.1")]
|
||||
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh);
|
||||
|
||||
[DllImport("libad_ff.so.1.1.1")]
|
||||
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
|
||||
|
||||
[DllImport("libad_ff.so.1.1.1")]
|
||||
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)
|
||||
//int FPM_ModifyHost(char *profileName, struct Host *host, int doUpdate)
|
||||
//int FPM_RemoveHost(char *profileName, char *hostname, 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
|
||||
|
||||
Reference in New Issue
Block a user