- Added support for ADD/MODIFY/DELETE functionalities for Keyring and Kwallet
stores in the GUI. - Updated the Glade file with version info. ............................................................
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
/// Abstracts the back-end and acts as an interface
|
||||
/// to the GUI.
|
||||
/// AUTHORS : Manohar, CSL.Manojna
|
||||
/// UPDATED ON : 24 Sept, 2005
|
||||
/// UPDATED ON : 03 Jan, 06
|
||||
///#################################################################
|
||||
|
||||
|
||||
@@ -22,14 +22,13 @@ namespace Novell.CASA.GUI {
|
||||
using Gtk;
|
||||
using Novell.CASA.DataEngines;
|
||||
|
||||
|
||||
public class StoreDataInterface
|
||||
{
|
||||
|
||||
private static XmlDocument ccfDoc;
|
||||
private static AD ad;
|
||||
|
||||
private static string CCFXML_ELEMENT_MICASA_KEYCHAIN = "Keychain",
|
||||
private const string CCFXML_ELEMENT_MICASA_KEYCHAIN = "Keychain",
|
||||
CCFXML_ELEMENT_GKEYRING_KEYRING = "Keyring",
|
||||
CCFXML_ELEMENT_KWALLET_WALLET = "Wallet",
|
||||
CCFXML_ELEMENT_SECRET = "Secret",
|
||||
@@ -45,7 +44,8 @@ namespace Novell.CASA.GUI {
|
||||
CCFXML_ELEMENT_TIME_ACCESSED = "Accessed",
|
||||
CCFXML_ATTRIBUTE_ID = "ID",
|
||||
CCFXML_ATTRIBUTE_MICASA_SYNCH = "Synch",
|
||||
CCFXML_ATTRIBUTE_GKEYRING_TYPE = "Type";
|
||||
CCFXML_ATTRIBUTE_GKEYRING_TYPE = "Type",
|
||||
CCFXML_ATTRIBUTE_WALLETLASTACCESSEDTIME="LastAcctime";
|
||||
|
||||
|
||||
|
||||
@@ -62,8 +62,11 @@ namespace Novell.CASA.GUI {
|
||||
try
|
||||
{
|
||||
ccfDoc = new XmlDocument();
|
||||
ad = new AD();
|
||||
}
|
||||
ad = new AD();
|
||||
|
||||
//Init CCF from a XML Document -FIXME: -Remove this
|
||||
//ccfDoc.Load("ccfv3.xml");
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.Init() - EXCEPTION" + exp.ToString());
|
||||
@@ -94,9 +97,8 @@ namespace Novell.CASA.GUI {
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.AggregateStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
return( Common.STATUS_STORE_AGGREGATEFAILED );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +120,6 @@ namespace Novell.CASA.GUI {
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.RefreshAllStores() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog(exp);
|
||||
return( Common.STATUS_STORE_AGGREGATEFAILED );
|
||||
}
|
||||
Logger.DbgLog("GUI:StoreDataInterface.RefreshAllStores() - END");
|
||||
@@ -376,7 +377,6 @@ namespace Novell.CASA.GUI {
|
||||
catch(Exception exp)
|
||||
{
|
||||
Logger.DbgLog("GUI:StoreDataInterface.ReadStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog( exp );
|
||||
return( Common.STATUS_STORE_READFAILED );
|
||||
}
|
||||
ShowDocOnConsole("READ STORE:");
|
||||
@@ -396,15 +396,17 @@ namespace Novell.CASA.GUI {
|
||||
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore()");
|
||||
|
||||
//TreeStore row elements
|
||||
string storeChainKey = null;
|
||||
string SecretID = null;
|
||||
string keyChainID = null;
|
||||
string[] strKeyArray = new string[Common.MAX_ARRAY_ELEMENTS];
|
||||
string[] strValueArray = new string[Common.MAX_ARRAY_ELEMENTS];
|
||||
string[] strNativeValueArray = new string[Common.MAX_NATIVE_ELEMENTS];
|
||||
|
||||
|
||||
//XPATH query strings
|
||||
string ccfKeyChainPath = null;
|
||||
string ccfSecretPath = null;
|
||||
string ccfRootStorePath = null;
|
||||
string ccfKeyChainPath = null;
|
||||
string ccfSecretPath = null;
|
||||
|
||||
//Intialization of New Secret\Key elements
|
||||
XmlElement newKeychainElement = ccfDoc.CreateElement(CCFXML_ELEMENT_MICASA_KEYCHAIN);
|
||||
@@ -417,7 +419,8 @@ namespace Novell.CASA.GUI {
|
||||
strKeyArray = (string[]) model.GetValue (iter, 1);
|
||||
strValueArray = (string[]) model.GetValue (iter, 2);
|
||||
keyChainID = (string) model.GetValue (iter, 3);
|
||||
|
||||
strNativeValueArray = (string[]) model.GetValue (iter, 5);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
@@ -425,20 +428,21 @@ namespace Novell.CASA.GUI {
|
||||
//Form the query to reach to an element for modify\delete\add
|
||||
if( Common.STORE_MICASA == storeIDentifier )
|
||||
{
|
||||
storeChainKey = CCFXML_ELEMENT_MICASA_KEYCHAIN;
|
||||
ccfRootStorePath = "//CCF/miCASA";
|
||||
if( Common.OPERATION_MODIFY_KEY == operation || Common.OPERATION_DELETE_KEY == operation )
|
||||
{
|
||||
ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
{
|
||||
//ccfSecretPath="//CCF/miCASA/Keychain[@ID='"+keyChainID+"']/Secret[@ID='"+SecretID+"']";
|
||||
ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']";
|
||||
ccfSecretPath = "Secret[@ID='" + SecretID + "']";
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']";
|
||||
ccfSecretPath = "";
|
||||
ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
|
||||
//Create the Secret element
|
||||
newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
|
||||
@@ -471,6 +475,10 @@ namespace Novell.CASA.GUI {
|
||||
newAccessedTime.InnerText = "9012";
|
||||
newTime.AppendChild(newAccessedTime);
|
||||
newSecretElement.AppendChild(newTime);
|
||||
//Create the keychain element
|
||||
newKeychainElement = ccfDoc.CreateElement(storeChainKey);
|
||||
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
|
||||
newKeychainElement.AppendChild(newSecretElement);
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
@@ -478,7 +486,6 @@ namespace Novell.CASA.GUI {
|
||||
ccfSecretPath = "";
|
||||
|
||||
//Create the Key element
|
||||
//strKeyArray[0]-[n] -If Support needed for multiple keys at once
|
||||
newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
@@ -486,10 +493,127 @@ namespace Novell.CASA.GUI {
|
||||
newKeyElement.AppendChild(newValue);
|
||||
}
|
||||
}
|
||||
else if( Common.STORE_GNOMEKEYRING == storeIDentifier )
|
||||
{
|
||||
storeChainKey = CCFXML_ELEMENT_GKEYRING_KEYRING;
|
||||
ccfRootStorePath = "//CCF/GK";
|
||||
if( Common.OPERATION_MODIFY_KEY == operation || Common.OPERATION_DELETE_KEY == operation )
|
||||
{
|
||||
ccfSecretPath = "//CCF/GK/Keyring[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
|
||||
//Console.WriteLine("OPERATION_MODIFY_KEY-OR-OPERATION_DELETE_KEY:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/GK/Keyring[@ID='" + keyChainID + "']";
|
||||
ccfSecretPath = "Secret[@ID='" + SecretID + "']";
|
||||
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
|
||||
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
string typeID = strNativeValueArray[Common.INDEX_NATIVEINFO_TYPEID];
|
||||
string walletLastAccessedTime = strNativeValueArray[Common.INDEX_NATIVEINFO_WALLETLASTACCESSEDTIME];
|
||||
ccfKeyChainPath = "//CCF/GK/Keyring[@ID='" + keyChainID + "']";//Default keyChainID:CASAKeyring
|
||||
ccfSecretPath = "//CCF/GK/Keyring[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
//Console.WriteLine("OPERATION_ADD_SECRET:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
|
||||
//Console.WriteLine("OPERATION_ADD_SECRET:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
|
||||
//Create the Secret element
|
||||
newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
|
||||
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_ID,SecretID);
|
||||
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_GKEYRING_TYPE,typeID); //Default typeID:Password
|
||||
|
||||
//Add all keys from strKeyArray to the new secret
|
||||
for( int i=0; i< strKeyArray.Length; i++)
|
||||
{
|
||||
XmlElement newKey = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKey.SetAttribute(CCFXML_ATTRIBUTE_ID,strKeyArray[i]);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = strValueArray[i];
|
||||
newKey.AppendChild(newValue);
|
||||
newSecretElement.AppendChild(newKey);
|
||||
}
|
||||
|
||||
//Create the keychain element
|
||||
newKeychainElement = ccfDoc.CreateElement(storeChainKey);
|
||||
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
|
||||
//newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_WALLETLASTACCESSEDTIME,walletLastAccessedTime);
|
||||
newKeychainElement.AppendChild(newSecretElement);
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/GK/Keyring[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
ccfSecretPath = "";
|
||||
|
||||
//Create the Key element
|
||||
newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = valueToBeModfied;
|
||||
newKeyElement.AppendChild(newValue);
|
||||
}
|
||||
}
|
||||
else if( Common.STORE_KDEWALLET == storeIDentifier )
|
||||
{
|
||||
string folderName = strNativeValueArray[Common.INDEX_NATIVEINFO_FOLDERNAME];
|
||||
string typeID = strNativeValueArray[Common.INDEX_NATIVEINFO_TYPEID];
|
||||
storeChainKey = CCFXML_ELEMENT_KWALLET_WALLET;
|
||||
ccfRootStorePath = "//CCF/KWallet";
|
||||
|
||||
if( Common.OPERATION_MODIFY_KEY == operation || Common.OPERATION_DELETE_KEY == operation )
|
||||
{
|
||||
ccfSecretPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
|
||||
//Console.WriteLine("OPERATION_MODIFY_KEY-OR-OPERATION_DELETE_KEY:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']";
|
||||
ccfSecretPath = "Secret[@ID='" + SecretID + "']";
|
||||
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
|
||||
//Console.WriteLine("OPERATION_DELETE_SECRET:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']";
|
||||
ccfSecretPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']/Secret[@ID='" + SecretID + "']";
|
||||
//Console.WriteLine("OPERATION_ADD_SECRET:ccfKeyChainPath:"+ccfKeyChainPath);//FIXME:Remove this line
|
||||
//Console.WriteLine("OPERATION_ADD_SECRET:ccfSecretPath:"+ccfSecretPath);//FIXME:Remove this line
|
||||
|
||||
//Create the Secret element
|
||||
newSecretElement = ccfDoc.CreateElement(CCFXML_ELEMENT_SECRET);
|
||||
newSecretElement.SetAttribute(CCFXML_ATTRIBUTE_ID,SecretID);
|
||||
|
||||
//Add all keys from strKeyArray to the new secret
|
||||
for( int i=0; i< strKeyArray.Length; i++)
|
||||
{
|
||||
XmlElement newKey = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKey.SetAttribute(CCFXML_ATTRIBUTE_ID,strKeyArray[i]);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = strValueArray[i];
|
||||
newKey.AppendChild(newValue);
|
||||
newSecretElement.AppendChild(newKey);
|
||||
}
|
||||
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']/Secret[@ID='" + SecretID + "']";
|
||||
ccfSecretPath = "";
|
||||
|
||||
//Create the Key element
|
||||
newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyID);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = valueToBeModfied;
|
||||
newKeyElement.AppendChild(newValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
return( Common.STATUS_STORE_UNSUPPORTEDOPERATION );
|
||||
|
||||
//Execute the query for modify\delete\add
|
||||
|
||||
|
||||
//Execution of the query's
|
||||
if( Common.OPERATION_MODIFY_KEY == operation )
|
||||
{
|
||||
//For Modify operation get to the Node in the tree which needs to be modified
|
||||
@@ -498,7 +622,8 @@ namespace Novell.CASA.GUI {
|
||||
foreach ( XmlNode key in keylist )
|
||||
{
|
||||
key.ChildNodes[0].InnerText=valueToBeModfied ;
|
||||
ad.SetSecret(key.ParentNode,storeIDentifier);
|
||||
//Console.WriteLine("EXECUTING OPERATION_MODIFY_KEY:Modifying"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.SetSecret(key.ParentNode,operation,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_DELETE_SECRET == operation )
|
||||
@@ -512,6 +637,7 @@ namespace Novell.CASA.GUI {
|
||||
XmlNodeList secretNodelist = keychain.SelectNodes(ccfSecretPath);
|
||||
foreach ( XmlNode secret in secretNodelist )
|
||||
{
|
||||
//Console.WriteLine("EXECUTING OPERATION_DELETE_SECRET:Deleting"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.Remove(secret,storeIDentifier);
|
||||
}
|
||||
}
|
||||
@@ -524,69 +650,169 @@ namespace Novell.CASA.GUI {
|
||||
|
||||
foreach ( XmlNode key in keylist )
|
||||
{
|
||||
//key.ChildNodes[0].InnerText=valueToBeModfied ;
|
||||
XmlNode keyParentNode = key.ParentNode;
|
||||
key.ParentNode.RemoveChild(key);
|
||||
//Console.WriteLine("EXECUTING OPERATION_DELETE_KEY:Deleting"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.SetSecret(keyParentNode,storeIDentifier);
|
||||
}
|
||||
}
|
||||
else if( Common.OPERATION_ADD_SECRET == operation )
|
||||
{
|
||||
//Add a new secret to the keychain
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
//ShowDocOnConsole("BEFORE CALL TO SETSECRET");//FIXME:Remove this
|
||||
|
||||
if(( Common.STORE_MICASA == storeIDentifier )||( Common.STORE_GNOMEKEYRING == storeIDentifier ))
|
||||
{
|
||||
//Add a new secret to the keychain
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
//Console.WriteLine("ADD_SECRET:ccfKeyChainPath="+ccfKeyChainPath);//FIXME:Remove this line
|
||||
|
||||
if( (null == keychainNodeList) || (0 == keychainNodeList.Count) )
|
||||
{
|
||||
newKeychainElement = ccfDoc.CreateElement(CCFXML_ELEMENT_MICASA_KEYCHAIN);
|
||||
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
|
||||
ccfKeyChainPath = "//CCF/miCASA";
|
||||
keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode miCASANode = keychainNodeList.Item(0);
|
||||
if( (null == keychainNodeList) || (0 == keychainNodeList.Count) )
|
||||
{//No root keychain path for this wallet. Hence New Keychain to be created
|
||||
//Expected path to be existing in CCF is eg://CCF/miCASA
|
||||
keychainNodeList = root.SelectNodes(ccfRootStorePath);
|
||||
XmlNode miCASANode = keychainNodeList.Item(0);
|
||||
|
||||
if( null != miCASANode )
|
||||
{
|
||||
miCASANode.AppendChild(newKeychainElement);
|
||||
newKeychainElement.AppendChild(newSecretElement);
|
||||
ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']";
|
||||
keychainNodeList = root.SelectNodes(ccfSecretPath);
|
||||
XmlNode SecretNode = keychainNodeList.Item(0);
|
||||
ad.SetSecret(SecretNode,storeIDentifier);
|
||||
if( null != miCASANode )
|
||||
{
|
||||
//Console.WriteLine("ADD_SECRET:Appending to ccfRootStorePath="+ccfRootStorePath);//FIXME:Remove this line
|
||||
miCASANode.AppendChild(newKeychainElement);
|
||||
//ShowDocOnConsole("AFTER APENDING TO miCASANode");//FIXME:Remove this
|
||||
//Console.WriteLine("ADD_SECRET:ccfSecretPath="+ccfSecretPath);//FIXME:Remove this line
|
||||
keychainNodeList = root.SelectNodes(ccfSecretPath);
|
||||
XmlNode SecretNode = keychainNodeList.Item(0);
|
||||
//Console.WriteLine("EXECUTING OPERATION_ADD_SECRET:Adding"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.SetSecret(SecretNode,operation,storeIDentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Root keychain path exists for this wallet
|
||||
//Console.WriteLine("ADD_SECRET:Appending to ccfKeyChainPath="+ccfKeyChainPath);//FIXME:Remove this line
|
||||
XmlNode keychain = keychainNodeList.Item(0);
|
||||
keychain.AppendChild(newSecretElement);
|
||||
XmlNode lastChild = keychain.LastChild;
|
||||
//ShowDocOnConsole("BEFORE CALL TO SETSECRET");//FIXME:Remove this
|
||||
//Console.WriteLine("EXECUTING OPERATION_ADD_SECRET:Adding Secret to existing keychain");//FIXME:Remove this line
|
||||
int errCode=ad.SetSecret(lastChild,operation,storeIDentifier);
|
||||
//Console.WriteLine("OPERATION_ADD_SECRET Returned:errCode"+errCode);//FIXME:Remove this line
|
||||
}
|
||||
}//Common.STORE_MICASA \ STORE_GNOMEKEYRING
|
||||
else
|
||||
if( Common.STORE_KDEWALLET == storeIDentifier )
|
||||
{
|
||||
XmlNode keychain = keychainNodeList.Item(0);
|
||||
keychain.AppendChild(newSecretElement);
|
||||
XmlNode lastChild = keychain.LastChild;
|
||||
ad.SetSecret(lastChild,storeIDentifier);
|
||||
}
|
||||
string folderName = strNativeValueArray[Common.INDEX_NATIVEINFO_FOLDERNAME];
|
||||
string typeID = strNativeValueArray[Common.INDEX_NATIVEINFO_TYPEID];
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']"; //CASAwallet
|
||||
XmlNodeList keychainNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
if( (null == keychainNodeList) || (0 == keychainNodeList.Count) )
|
||||
{//Wallet:CASAwallet does not exist. Hence create all
|
||||
XmlElement folder;
|
||||
XmlElement type;
|
||||
newKeychainElement = ccfDoc.CreateElement(storeChainKey);//Wallet
|
||||
newKeychainElement.SetAttribute(CCFXML_ATTRIBUTE_ID,keyChainID);
|
||||
folder = ccfDoc.CreateElement(CCFXML_ELEMENT_FOLDER);
|
||||
folder.SetAttribute(CCFXML_ATTRIBUTE_FOLDERNAME,folderName);
|
||||
type = ccfDoc.CreateElement(CCFXML_ELEMENT_TYPE);
|
||||
type.SetAttribute(CCFXML_ATTRIBUTE_ID,typeID);
|
||||
|
||||
//Join all of them
|
||||
type.AppendChild(newSecretElement);
|
||||
folder.AppendChild(type);
|
||||
newKeychainElement.AppendChild(folder);
|
||||
//Append the keychain to the root
|
||||
keychainNodeList = root.SelectNodes(ccfRootStorePath);
|
||||
XmlNode rootNode = keychainNodeList.Item(0);
|
||||
if( null != rootNode )
|
||||
rootNode.AppendChild(newKeychainElement);
|
||||
|
||||
}
|
||||
else
|
||||
{//Wallet:CASAwallet exists. Hence check for folder
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']"; //Password
|
||||
XmlNodeList keychainFolderNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
if( (null == keychainFolderNodeList) || (0 == keychainFolderNodeList.Count) )
|
||||
{//folderName:Password does not exist. Hence create folder & type
|
||||
XmlElement folder;
|
||||
XmlElement type;
|
||||
folder = ccfDoc.CreateElement(CCFXML_ELEMENT_FOLDER);
|
||||
folder.SetAttribute(CCFXML_ATTRIBUTE_FOLDERNAME,folderName);
|
||||
type = ccfDoc.CreateElement(CCFXML_ELEMENT_TYPE);
|
||||
type.SetAttribute(CCFXML_ATTRIBUTE_ID,typeID);
|
||||
|
||||
//Append secret to type
|
||||
type.AppendChild(newSecretElement);
|
||||
//Append type to folder
|
||||
folder.AppendChild(type);
|
||||
//Append folder to the existing keychainNodeList
|
||||
XmlNode keychainNode = keychainNodeList.Item(0);
|
||||
if( null != keychainNode )
|
||||
keychainNode.AppendChild(folder);
|
||||
}
|
||||
else
|
||||
{//Wallet:CASAwallet & folder exists. Hence check for type
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']"; //Maps
|
||||
XmlNodeList keychainTypeNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
if( (null == keychainTypeNodeList) || (0 == keychainTypeNodeList.Count) )
|
||||
{//type:Maps does not exist. Hence create folder & type
|
||||
XmlElement type;
|
||||
type = ccfDoc.CreateElement(CCFXML_ELEMENT_TYPE);
|
||||
type.SetAttribute(CCFXML_ATTRIBUTE_ID,typeID);
|
||||
//Append Secret to type
|
||||
type.AppendChild(newSecretElement);
|
||||
//Append type to the existing keychainFolderNodeList
|
||||
XmlNode keychainFolderNode = keychainFolderNodeList.Item(0);
|
||||
if( null != keychainFolderNode )
|
||||
keychainFolderNode.AppendChild(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Invoke setsecret
|
||||
//ShowDocOnConsole("AFTER ADD to CCF");//FIXME:Remove this
|
||||
ccfKeyChainPath = "//CCF/KWallet/Wallet[@ID='" + keyChainID + "']/Folder[@Name='" + folderName + "']/Type[@ID='" + typeID + "']";
|
||||
root = ccfDoc.DocumentElement;
|
||||
//Console.WriteLine("ADD_SECRET:ccfSecretPath="+ccfSecretPath);//FIXME:Remove this line
|
||||
//Console.WriteLine("ADD_SECRET:ccfKeyChainPath="+ccfKeyChainPath);//FIXME:Remove this line
|
||||
XmlNodeList secretNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode SecretNode = secretNodeList.Item(0);
|
||||
XmlNode lastChild = SecretNode.LastChild; //The newly added secret
|
||||
if(lastChild!=null)
|
||||
{
|
||||
//Console.WriteLine("EXECUTING OPERATION_ADD_SECRET:Adding"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.SetSecret(lastChild,operation,storeIDentifier);
|
||||
}
|
||||
}//STORE_KDEWALLET
|
||||
|
||||
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
//Add a new KN\KV to the keychain-Secret
|
||||
//Console.WriteLine("EXECUTING OPERATION_ADD_KEY:Adding"+ccfKeyChainPath);//FIXME:Remove this line
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keyNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode keyNode=keyNodeList.Item(0);
|
||||
XmlNode lastChild = keyNode.LastChild;
|
||||
keyNode.InsertBefore(newKeyElement,lastChild);
|
||||
ad.SetSecret(keyNode,storeIDentifier);
|
||||
//ShowDocOnConsole("JUST BEFORE CALL TO SETSECRET-ADDKEY");//FIXME:Remove this
|
||||
int errcode=ad.SetSecret(keyNode,Common.OPERATION_ADD_SECRET,storeIDentifier);
|
||||
//ShowDocOnConsole("SetSecret returned errcode="+errcode);//FIXME:Remove this
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
//Console.WriteLine("Exception"+exp.ToString());//FIXME:Remove this line
|
||||
Logger.DbgLog("GUI:StoreDataInterface.UpdateStore() - EXCEPTION" + exp.ToString());
|
||||
//Common.ShowErrorDialog( exp );
|
||||
return( Common.STATUS_STORE_UPDATEFAILED );
|
||||
}
|
||||
|
||||
ShowDocOnConsole("UPDATE STORE:");
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// DUMP THE XML CCF ON CONSOLE
|
||||
|
||||
@@ -603,8 +829,9 @@ namespace Novell.CASA.GUI {
|
||||
Console.WriteLine("\n#######################################################");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
///###########################################################################
|
||||
/// END OF FILE
|
||||
///###########################################################################
|
||||
///###########################################################################
|
||||
|
||||
Reference in New Issue
Block a user