Bug 193933. Fix Desktop capture problem.
This commit is contained in:
parent
65b1bbbfc4
commit
8f19a3798b
7
CASA/micasad/cache/SecretStore.cs
vendored
7
CASA/micasad/cache/SecretStore.cs
vendored
@ -89,7 +89,12 @@ namespace sscs.cache
|
|||||||
// start a MPFileWatcher if necessary
|
// start a MPFileWatcher if necessary
|
||||||
if (mpWatcher == null)
|
if (mpWatcher == null)
|
||||||
{
|
{
|
||||||
mpWatcher = new MPFileWatcher(GetUserHomeDirectory(), ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE);
|
// make sure HomeDirectory exists
|
||||||
|
String sHomeDir = GetUserHomeDirectory();
|
||||||
|
if (sHomeDir != null && sHomeDir.Length > 0)
|
||||||
|
{
|
||||||
|
mpWatcher = new MPFileWatcher(GetUserHomeDirectory(), ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace sscs.init
|
|||||||
string sCredMgrPath = GetCredMgrPath();
|
string sCredMgrPath = GetCredMgrPath();
|
||||||
if (sCredMgrPath != null)
|
if (sCredMgrPath != null)
|
||||||
{
|
{
|
||||||
RunProcess(sExePath, "/i /n /s " + "\"" + sCredMgrPath + "\"");
|
RunProcess(sExePath, "/i /n /s " + "\"" + sCredMgrPath + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,6 +71,7 @@ namespace sscs.init
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine("Running: " + sProcess + " " + sArgs);
|
||||||
Process myProcess = new Process();
|
Process myProcess = new Process();
|
||||||
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess);
|
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess);
|
||||||
|
|
||||||
|
@ -38,77 +38,77 @@ using Novell.CASA.MiCasa.Common;
|
|||||||
|
|
||||||
namespace sscs.lss
|
namespace sscs.lss
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/*
|
/*
|
||||||
* This class is a service to store data persistently.
|
* This class is a service to store data persistently.
|
||||||
* How it does this is determined by implementation within the
|
* How it does this is determined by implementation within the
|
||||||
* private methods (File system using file(s), database, etc)
|
* private methods (File system using file(s), database, etc)
|
||||||
* The MasterPasscode can be used to generate the key for
|
* The MasterPasscode can be used to generate the key for
|
||||||
* encyption and decryption.
|
* encyption and decryption.
|
||||||
* If encrpytion is used, the private methods will also manage
|
* If encrpytion is used, the private methods will also manage
|
||||||
* how the encyption key is to be stored and retrieved.
|
* how the encyption key is to be stored and retrieved.
|
||||||
* Each piece of data is located by a DataID.
|
* Each piece of data is located by a DataID.
|
||||||
* This might be an individual credentail or
|
* This might be an individual credentail or
|
||||||
* a complete store.
|
* a complete store.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* We might not need this as a separate class.
|
/* We might not need this as a separate class.
|
||||||
* Depending on the db changes, we can change this later.
|
* Depending on the db changes, we can change this later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LocalStorage
|
public class LocalStorage
|
||||||
{
|
{
|
||||||
private byte[] m_baGeneratedKey = null;
|
private byte[] m_baGeneratedKey = null;
|
||||||
private SecretStore userStore = null;
|
private SecretStore userStore = null;
|
||||||
|
|
||||||
private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30;
|
private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30;
|
||||||
private Thread persistThread = null;
|
private Thread persistThread = null;
|
||||||
|
|
||||||
#if LINUX
|
#if LINUX
|
||||||
Mono.Unix.UnixFileSystemInfo sockFileInfo;
|
Mono.Unix.UnixFileSystemInfo sockFileInfo;
|
||||||
Mono.Unix.UnixUserInfo sockFileOwner;
|
Mono.Unix.UnixUserInfo sockFileOwner;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static string LINUXID = "Unix";
|
private static string LINUXID = "Unix";
|
||||||
|
|
||||||
internal LocalStorage(SecretStore store,byte[] baMasterPasscode)
|
internal LocalStorage(SecretStore store,byte[] baMasterPasscode)
|
||||||
{
|
{
|
||||||
userStore = store;
|
userStore = store;
|
||||||
m_baGeneratedKey = baMasterPasscode;
|
m_baGeneratedKey = baMasterPasscode;
|
||||||
LoadPersistentStore();
|
LoadPersistentStore();
|
||||||
userStore.DumpSecretstore();
|
userStore.DumpSecretstore();
|
||||||
}
|
}
|
||||||
~LocalStorage()
|
~LocalStorage()
|
||||||
{
|
{
|
||||||
if(persistThread != null)
|
if(persistThread != null)
|
||||||
{
|
{
|
||||||
persistThread.Abort();
|
persistThread.Abort();
|
||||||
persistThread.Join();
|
persistThread.Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allowing a user to choose the storage location is not approved yet
|
// allowing a user to choose the storage location is not approved yet
|
||||||
private LocalStorage(SecretStore store,
|
private LocalStorage(SecretStore store,
|
||||||
byte[] baMasterPasscode, string sStorageDirectory)
|
byte[] baMasterPasscode, string sStorageDirectory)
|
||||||
{
|
{
|
||||||
userStore = store;
|
userStore = store;
|
||||||
m_baGeneratedKey = baMasterPasscode;
|
m_baGeneratedKey = baMasterPasscode;
|
||||||
LoadPersistentStore();
|
LoadPersistentStore();
|
||||||
userStore.DumpSecretstore();
|
userStore.DumpSecretstore();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StorePersistentData(string sDataID, byte[] baData)
|
private void StorePersistentData(string sDataID, byte[] baData)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] RetrievePersistentData(string sDataID)
|
private byte[] RetrievePersistentData(string sDataID)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PersistStoreWithDelay()
|
public void PersistStoreWithDelay()
|
||||||
{
|
{
|
||||||
@ -144,10 +144,10 @@ namespace sscs.lss
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string GetDecryptedXml()
|
private string GetDecryptedXml()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string fileName = userStore.GetPersistenceFilePath();
|
string fileName = userStore.GetPersistenceFilePath();
|
||||||
string tempFile = fileName;
|
string tempFile = fileName;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -192,145 +192,145 @@ namespace sscs.lss
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
byte[] key = CASACrypto.GetKeySetFromFile(baPasscode,userStore.GetKeyFilePath());
|
byte[] key = CASACrypto.GetKeySetFromFile(baPasscode,userStore.GetKeyFilePath());
|
||||||
if( null == key )
|
if( null == key )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key,fileName);
|
byte[] decryptedBuffer = CASACrypto.ReadFileAndDecryptData(key,fileName);
|
||||||
|
|
||||||
if( null == decryptedBuffer )
|
if( null == decryptedBuffer )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length);
|
string temp = Encoding.UTF8.GetString(decryptedBuffer, 0, decryptedBuffer.Length);
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
CSSSLogger.ExpLog(e.ToString());
|
CSSSLogger.ExpLog(e.ToString());
|
||||||
CSSSLogger.DbgLog("Unable to get persistent store");
|
CSSSLogger.DbgLog("Unable to get persistent store");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* This method, uses the key to decrypt the persistent store
|
/* This method, uses the key to decrypt the persistent store
|
||||||
* and populates userStore with the persistent data.
|
* and populates userStore with the persistent data.
|
||||||
*/
|
*/
|
||||||
private bool LoadPersistentStore()
|
private bool LoadPersistentStore()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string xpath = "";
|
string xpath = "";
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
|
|
||||||
string xmlToLoad = GetDecryptedXml();
|
string xmlToLoad = GetDecryptedXml();
|
||||||
if(xmlToLoad != null)
|
if(xmlToLoad != null)
|
||||||
{
|
{
|
||||||
doc.LoadXml(xmlToLoad);
|
doc.LoadXml(xmlToLoad);
|
||||||
|
|
||||||
#if false
|
#if false
|
||||||
XmlTextWriter writer = new XmlTextWriter("/home/poorna/.miCASA.xml",null);
|
XmlTextWriter writer = new XmlTextWriter("d:/persist.xml",null);
|
||||||
writer.Formatting = Formatting.Indented;
|
writer.Formatting = Formatting.Indented;
|
||||||
doc.Save(writer);
|
doc.Save(writer);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
xpath = "//" + XmlConsts.miCASANode;
|
xpath = "//" + XmlConsts.miCASANode;
|
||||||
XmlNode miCASANode = doc.SelectSingleNode(xpath);
|
XmlNode miCASANode = doc.SelectSingleNode(xpath);
|
||||||
if(miCASANode != null)
|
if(miCASANode != null)
|
||||||
{
|
{
|
||||||
xpath = "descendant::" + XmlConsts.keyChainNode;
|
xpath = "descendant::" + XmlConsts.keyChainNode;
|
||||||
XmlNodeList keyChainNodeList = miCASANode.SelectNodes(xpath);
|
XmlNodeList keyChainNodeList = miCASANode.SelectNodes(xpath);
|
||||||
foreach(XmlNode node in keyChainNodeList)
|
foreach(XmlNode node in keyChainNodeList)
|
||||||
{
|
{
|
||||||
XmlAttributeCollection attrColl = node.Attributes;
|
XmlAttributeCollection attrColl = node.Attributes;
|
||||||
string keyChainId = (attrColl[XmlConsts.idAttr]).Value + "\0";
|
string keyChainId = (attrColl[XmlConsts.idAttr]).Value + "\0";
|
||||||
KeyChain keyChain = null;
|
KeyChain keyChain = null;
|
||||||
|
|
||||||
if( userStore.CheckIfKeyChainExists(keyChainId) == false )
|
if( userStore.CheckIfKeyChainExists(keyChainId) == false )
|
||||||
{
|
{
|
||||||
keyChain = new KeyChain(keyChainId);
|
keyChain = new KeyChain(keyChainId);
|
||||||
userStore.AddKeyChain(keyChain);
|
userStore.AddKeyChain(keyChain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
keyChain = userStore.GetKeyChain(keyChainId);
|
keyChain = userStore.GetKeyChain(keyChainId);
|
||||||
}
|
}
|
||||||
xpath = "descendant::" + XmlConsts.secretNode;
|
xpath = "descendant::" + XmlConsts.secretNode;
|
||||||
XmlNodeList secretNodeList = node.SelectNodes(xpath);
|
XmlNodeList secretNodeList = node.SelectNodes(xpath);
|
||||||
foreach(XmlNode secretNode in secretNodeList)
|
foreach(XmlNode secretNode in secretNodeList)
|
||||||
{
|
{
|
||||||
attrColl = secretNode.Attributes;
|
attrColl = secretNode.Attributes;
|
||||||
string secretId = (attrColl[XmlConsts.idAttr]).Value + "\0";
|
string secretId = (attrColl[XmlConsts.idAttr]).Value + "\0";
|
||||||
xpath = "descendant::" + XmlConsts.valueNode;
|
xpath = "descendant::" + XmlConsts.valueNode;
|
||||||
Secret secret = new Secret(secretId);
|
Secret secret = new Secret(secretId);
|
||||||
if( keyChain.CheckIfSecretExists(secretId) == false)
|
if( keyChain.CheckIfSecretExists(secretId) == false)
|
||||||
{
|
{
|
||||||
keyChain.AddSecret(secret);
|
keyChain.AddSecret(secret);
|
||||||
XmlNode secretValNode = (secretNode.SelectSingleNode(xpath));
|
XmlNode secretValNode = (secretNode.SelectSingleNode(xpath));
|
||||||
xpath = "descendant::" + XmlConsts.keyNode;
|
xpath = "descendant::" + XmlConsts.keyNode;
|
||||||
|
|
||||||
XmlNodeList keyNodeList = secretValNode.SelectNodes(xpath);
|
XmlNodeList keyNodeList = secretValNode.SelectNodes(xpath);
|
||||||
|
|
||||||
secret = keyChain.GetSecret(secretId);
|
secret = keyChain.GetSecret(secretId);
|
||||||
foreach(XmlNode keyNode in keyNodeList)
|
foreach(XmlNode keyNode in keyNodeList)
|
||||||
{
|
{
|
||||||
attrColl = keyNode.Attributes;
|
attrColl = keyNode.Attributes;
|
||||||
string key;
|
string key;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
key = (attrColl[XmlConsts.idAttr]).Value;
|
key = (attrColl[XmlConsts.idAttr]).Value;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// LinkedKey node, continue
|
// LinkedKey node, continue
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xpath = "descendant::" + XmlConsts.keyValueNode;
|
xpath = "descendant::" + XmlConsts.keyValueNode;
|
||||||
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
|
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
|
||||||
string keyValue = keyValNode.InnerText;
|
string keyValue = keyValNode.InnerText;
|
||||||
secret.SetKeyValue(key,keyValue);
|
secret.SetKeyValue(key,keyValue);
|
||||||
|
|
||||||
|
|
||||||
// add linked keys
|
// add linked keys
|
||||||
xpath = "descendant::" + XmlConsts.linkedKeyNode;
|
xpath = "descendant::" + XmlConsts.linkedKeyNode;
|
||||||
XmlNodeList linkNodeList = keyNode.SelectNodes(xpath);
|
XmlNodeList linkNodeList = keyNode.SelectNodes(xpath);
|
||||||
foreach(XmlNode linkNode in linkNodeList)
|
foreach(XmlNode linkNode in linkNodeList)
|
||||||
{
|
{
|
||||||
// get TargetSecretID
|
// get TargetSecretID
|
||||||
xpath = "descendant::" + XmlConsts.linkedTargetSecretNode;
|
xpath = "descendant::" + XmlConsts.linkedTargetSecretNode;
|
||||||
XmlNode targetSecretNode = linkNode.SelectSingleNode(xpath);
|
XmlNode targetSecretNode = linkNode.SelectSingleNode(xpath);
|
||||||
string sSecretID = targetSecretNode.InnerText + "\0";
|
string sSecretID = targetSecretNode.InnerText + "\0";
|
||||||
|
|
||||||
// get TargetSecretKey
|
// get TargetSecretKey
|
||||||
xpath = "descendant::" + XmlConsts.linkedTargetKeyNode;
|
xpath = "descendant::" + XmlConsts.linkedTargetKeyNode;
|
||||||
XmlNode targetKeyNode = linkNode.SelectSingleNode(xpath);
|
XmlNode targetKeyNode = linkNode.SelectSingleNode(xpath);
|
||||||
string sKeyID = targetKeyNode.InnerText;
|
string sKeyID = targetKeyNode.InnerText;
|
||||||
|
|
||||||
LinkedKeyInfo lki = new LinkedKeyInfo(sSecretID, sKeyID, true);
|
LinkedKeyInfo lki = new LinkedKeyInfo(sSecretID, sKeyID, true);
|
||||||
KeyValue kv = secret.GetKeyValue(key);
|
KeyValue kv = secret.GetKeyValue(key);
|
||||||
kv.AddLink(lki);
|
kv.AddLink(lki);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}//if ends
|
}//if ends
|
||||||
}
|
}
|
||||||
|
|
||||||
}//end of traversing keyChainNodeList
|
}//end of traversing keyChainNodeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
CSSSLogger.ExpLog(e.ToString());
|
CSSSLogger.ExpLog(e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect now to remove old data from memory
|
// collect now to remove old data from memory
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PersistStoreDelayThreadFn()
|
private void PersistStoreDelayThreadFn()
|
||||||
{
|
{
|
||||||
@ -339,139 +339,26 @@ namespace sscs.lss
|
|||||||
persistThread = null;
|
persistThread = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PersistStoreThreadFn()
|
private void PersistStoreThreadFn()
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
Thread.Sleep(persistThreadSleepTime);
|
Thread.Sleep(persistThreadSleepTime);
|
||||||
PersistStore();
|
PersistStore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Persists the store to an xml file.
|
/* Persists the store to an xml file.
|
||||||
* TBD : Would we require any form of encoding?
|
* TBD : Would we require any form of encoding?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
internal void PersistStore()
|
internal void PersistStore()
|
||||||
{
|
{
|
||||||
// userStore.DumpSecretstore();
|
//userStore.DumpSecretstore();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
MemoryStream ms1 = GetSecretsAsXMLStream();
|
||||||
MemoryStream ms1 = new MemoryStream();
|
//byte[] key = CASACrypto.GetKeySetFromFile(CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()),userStore.GetKeyFilePath());
|
||||||
XmlTextWriter writer = new XmlTextWriter(ms1,null);
|
|
||||||
writer.Formatting = Formatting.Indented;
|
|
||||||
|
|
||||||
writer.WriteStartDocument();
|
|
||||||
writer.WriteStartElement(XmlConsts.miCASANode);
|
|
||||||
writer.WriteAttributeString(XmlConsts.versionAttr,"1.5");
|
|
||||||
|
|
||||||
{
|
|
||||||
IDictionaryEnumerator iter = (IDictionaryEnumerator)userStore.GetKeyChainEnumerator();
|
|
||||||
char [] tmpId;
|
|
||||||
string sTmpId;
|
|
||||||
while( iter.MoveNext() )
|
|
||||||
{
|
|
||||||
KeyChain kc = (KeyChain)iter.Value;
|
|
||||||
writer.WriteStartElement(XmlConsts.keyChainNode);
|
|
||||||
string kcId = kc.GetKey();
|
|
||||||
tmpId = new char[kcId.Length-1];
|
|
||||||
for(int i = 0; i < kcId.Length-1; i++ )
|
|
||||||
tmpId[i] = kcId[i];
|
|
||||||
sTmpId = new string(tmpId);
|
|
||||||
|
|
||||||
writer.WriteAttributeString(XmlConsts.idAttr,sTmpId);
|
|
||||||
/* If we need to store time
|
|
||||||
writer.WriteStartElement(XmlConsts.timeNode);
|
|
||||||
writer.WriteAttributeString(XmlConsts.createdTimeNode,kc.CreatedTime.ToString());
|
|
||||||
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,kc.ModifiedTime.ToString());
|
|
||||||
writer.WriteEndElement();
|
|
||||||
*/
|
|
||||||
|
|
||||||
IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kc.GetAllSecrets());
|
|
||||||
while(secIter.MoveNext())
|
|
||||||
{
|
|
||||||
Secret secret = (Secret)secIter.Value;
|
|
||||||
writer.WriteStartElement(XmlConsts.secretNode);
|
|
||||||
string secretId = secret.GetKey();
|
|
||||||
tmpId = new char[secretId.Length-1];
|
|
||||||
for(int i = 0; i < secretId.Length-1; i++ )
|
|
||||||
tmpId[i] = secretId[i];
|
|
||||||
sTmpId = new string(tmpId);
|
|
||||||
|
|
||||||
writer.WriteAttributeString(XmlConsts.idAttr,sTmpId);
|
|
||||||
/* If we need to store time
|
|
||||||
writer.WriteStartElement(XmlConsts.timeNode);
|
|
||||||
writer.WriteAttributeString(XmlConsts.createdTimeNode,secret.CreatedTime.ToString());
|
|
||||||
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,secret.ModifiedTime.ToString());
|
|
||||||
writer.WriteEndElement();
|
|
||||||
*/
|
|
||||||
|
|
||||||
writer.WriteStartElement(XmlConsts.valueNode);
|
|
||||||
// byte[] byteArr = secret.GetValue();
|
|
||||||
|
|
||||||
IDictionaryEnumerator etor = (IDictionaryEnumerator)secret.GetKeyValueEnumerator();
|
|
||||||
while(etor.MoveNext())
|
|
||||||
{
|
|
||||||
string sKey = (string)etor.Key;
|
|
||||||
string value = secret.GetKeyValue(sKey).GetValue();
|
|
||||||
writer.WriteStartElement(XmlConsts.keyNode);
|
|
||||||
writer.WriteAttributeString(XmlConsts.idAttr, sKey);
|
|
||||||
writer.WriteStartElement(XmlConsts.keyValueNode);
|
|
||||||
writer.WriteString(value);
|
|
||||||
writer.WriteEndElement();
|
|
||||||
/* If we need to store time
|
|
||||||
writer.WriteStartElement(XmlConsts.timeNode);
|
|
||||||
writer.WriteAttributeString(XmlConsts.createdTimeNode,(secret.GetKeyValueCreatedTime(sKey)).ToString());
|
|
||||||
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,(secret.GetKeyValueModifiedTime(sKey)).ToString());
|
|
||||||
writer.WriteEndElement();
|
|
||||||
*/
|
|
||||||
// write all LinkKeys
|
|
||||||
Hashtable htLinkedKeys = secret.GetLinkedKeys(sKey);
|
|
||||||
if (htLinkedKeys != null)
|
|
||||||
{
|
|
||||||
IDictionaryEnumerator etorLinked = (IDictionaryEnumerator)htLinkedKeys.GetEnumerator();
|
|
||||||
while(etorLinked.MoveNext())
|
|
||||||
{
|
|
||||||
LinkedKeyInfo lki = (LinkedKeyInfo)etorLinked.Value;
|
|
||||||
writer.WriteStartElement(XmlConsts.linkedKeyNode);
|
|
||||||
|
|
||||||
writer.WriteStartElement(XmlConsts.linkedTargetSecretNode);
|
|
||||||
writer.WriteString(lki.GetLinkedSecretID().Substring(0, lki.GetLinkedSecretID().Length-1));
|
|
||||||
writer.WriteEndElement();
|
|
||||||
|
|
||||||
writer.WriteStartElement(XmlConsts.linkedTargetKeyNode);
|
|
||||||
writer.WriteString(lki.GetLinkedKeyID());
|
|
||||||
writer.WriteEndElement();
|
|
||||||
|
|
||||||
writer.WriteEndElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.WriteEndElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
char[] chArr = new char[byteArr.Length];
|
|
||||||
for(int z = 0; z < byteArr.Length; z++)
|
|
||||||
chArr[z] = (char)byteArr[z];
|
|
||||||
|
|
||||||
string stringToStore = new string(chArr);
|
|
||||||
writer.WriteString(stringToStore);
|
|
||||||
*/
|
|
||||||
|
|
||||||
writer.WriteEndElement(); //end of value node
|
|
||||||
writer.WriteEndElement();
|
|
||||||
}
|
|
||||||
writer.WriteEndElement(); //keychain
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writer.WriteEndElement(); //miCASA node
|
|
||||||
writer.WriteEndDocument();
|
|
||||||
writer.Flush();
|
|
||||||
writer.Close();
|
|
||||||
|
|
||||||
//byte[] key = CASACrypto.GetKeySetFromFile(CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()),userStore.GetKeyFilePath());
|
|
||||||
byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath());
|
byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath());
|
||||||
|
|
||||||
string fileName = userStore.GetPersistenceFilePath();
|
string fileName = userStore.GetPersistenceFilePath();
|
||||||
@ -515,6 +402,129 @@ namespace sscs.lss
|
|||||||
{
|
{
|
||||||
CSSSLogger.ExpLog(e.ToString());
|
CSSSLogger.ExpLog(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
internal MemoryStream GetSecretsAsXMLStream()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MemoryStream ms1 = new MemoryStream();
|
||||||
|
XmlTextWriter writer = new XmlTextWriter(ms1,null);
|
||||||
|
writer.Formatting = Formatting.Indented;
|
||||||
|
|
||||||
|
writer.WriteStartDocument();
|
||||||
|
writer.WriteStartElement(XmlConsts.miCASANode);
|
||||||
|
writer.WriteAttributeString(XmlConsts.versionAttr,"1.5");
|
||||||
|
|
||||||
|
IDictionaryEnumerator iter = (IDictionaryEnumerator)userStore.GetKeyChainEnumerator();
|
||||||
|
char [] tmpId;
|
||||||
|
string sTmpId;
|
||||||
|
while( iter.MoveNext() )
|
||||||
|
{
|
||||||
|
KeyChain kc = (KeyChain)iter.Value;
|
||||||
|
writer.WriteStartElement(XmlConsts.keyChainNode);
|
||||||
|
string kcId = kc.GetKey();
|
||||||
|
tmpId = new char[kcId.Length-1];
|
||||||
|
for(int i = 0; i < kcId.Length-1; i++ )
|
||||||
|
tmpId[i] = kcId[i];
|
||||||
|
sTmpId = new string(tmpId);
|
||||||
|
|
||||||
|
writer.WriteAttributeString(XmlConsts.idAttr,sTmpId);
|
||||||
|
/* If we need to store time
|
||||||
|
writer.WriteStartElement(XmlConsts.timeNode);
|
||||||
|
writer.WriteAttributeString(XmlConsts.createdTimeNode,kc.CreatedTime.ToString());
|
||||||
|
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,kc.ModifiedTime.ToString());
|
||||||
|
writer.WriteEndElement();
|
||||||
|
*/
|
||||||
|
|
||||||
|
IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kc.GetAllSecrets());
|
||||||
|
while(secIter.MoveNext())
|
||||||
|
{
|
||||||
|
Secret secret = (Secret)secIter.Value;
|
||||||
|
writer.WriteStartElement(XmlConsts.secretNode);
|
||||||
|
string secretId = secret.GetKey();
|
||||||
|
tmpId = new char[secretId.Length-1];
|
||||||
|
for(int i = 0; i < secretId.Length-1; i++ )
|
||||||
|
tmpId[i] = secretId[i];
|
||||||
|
sTmpId = new string(tmpId);
|
||||||
|
|
||||||
|
writer.WriteAttributeString(XmlConsts.idAttr,sTmpId);
|
||||||
|
/* If we need to store time
|
||||||
|
writer.WriteStartElement(XmlConsts.timeNode);
|
||||||
|
writer.WriteAttributeString(XmlConsts.createdTimeNode,secret.CreatedTime.ToString());
|
||||||
|
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,secret.ModifiedTime.ToString());
|
||||||
|
writer.WriteEndElement();
|
||||||
|
*/
|
||||||
|
|
||||||
|
writer.WriteStartElement(XmlConsts.valueNode);
|
||||||
|
// byte[] byteArr = secret.GetValue();
|
||||||
|
|
||||||
|
IDictionaryEnumerator etor = (IDictionaryEnumerator)secret.GetKeyValueEnumerator();
|
||||||
|
while(etor.MoveNext())
|
||||||
|
{
|
||||||
|
string sKey = (string)etor.Key;
|
||||||
|
string value = secret.GetKeyValue(sKey).GetValue();
|
||||||
|
writer.WriteStartElement(XmlConsts.keyNode);
|
||||||
|
writer.WriteAttributeString(XmlConsts.idAttr, sKey);
|
||||||
|
writer.WriteStartElement(XmlConsts.keyValueNode);
|
||||||
|
writer.WriteString(value);
|
||||||
|
writer.WriteEndElement();
|
||||||
|
/* If we need to store time
|
||||||
|
writer.WriteStartElement(XmlConsts.timeNode);
|
||||||
|
writer.WriteAttributeString(XmlConsts.createdTimeNode,(secret.GetKeyValueCreatedTime(sKey)).ToString());
|
||||||
|
writer.WriteAttributeString(XmlConsts.modifiedTimeNode,(secret.GetKeyValueModifiedTime(sKey)).ToString());
|
||||||
|
writer.WriteEndElement();
|
||||||
|
*/
|
||||||
|
// write all LinkKeys
|
||||||
|
Hashtable htLinkedKeys = secret.GetLinkedKeys(sKey);
|
||||||
|
if (htLinkedKeys != null)
|
||||||
|
{
|
||||||
|
IDictionaryEnumerator etorLinked = (IDictionaryEnumerator)htLinkedKeys.GetEnumerator();
|
||||||
|
while(etorLinked.MoveNext())
|
||||||
|
{
|
||||||
|
LinkedKeyInfo lki = (LinkedKeyInfo)etorLinked.Value;
|
||||||
|
writer.WriteStartElement(XmlConsts.linkedKeyNode);
|
||||||
|
|
||||||
|
writer.WriteStartElement(XmlConsts.linkedTargetSecretNode);
|
||||||
|
writer.WriteString(lki.GetLinkedSecretID().Substring(0, lki.GetLinkedSecretID().Length-1));
|
||||||
|
writer.WriteEndElement();
|
||||||
|
|
||||||
|
writer.WriteStartElement(XmlConsts.linkedTargetKeyNode);
|
||||||
|
writer.WriteString(lki.GetLinkedKeyID());
|
||||||
|
writer.WriteEndElement();
|
||||||
|
|
||||||
|
writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
char[] chArr = new char[byteArr.Length];
|
||||||
|
for(int z = 0; z < byteArr.Length; z++)
|
||||||
|
chArr[z] = (char)byteArr[z];
|
||||||
|
|
||||||
|
string stringToStore = new string(chArr);
|
||||||
|
writer.WriteString(stringToStore);
|
||||||
|
*/
|
||||||
|
|
||||||
|
writer.WriteEndElement(); //end of value node
|
||||||
|
writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
writer.WriteEndElement(); //keychain
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.WriteEndElement(); //miCASA node
|
||||||
|
writer.WriteEndDocument();
|
||||||
|
writer.Flush();
|
||||||
|
writer.Close();
|
||||||
|
return ms1;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user