public override object Load(string sectionName, string fileName) { XmlDocument document = new XmlDocument(); document.Load(fileName); // add EncryptedData to new document XmlNode node = document.SelectSingleNode("//EncryptedData"); if ( node != null ) { // decrypt EncryptXml decrypt = new EncryptXml(document); decrypt.AddKeyNameMapping("db", ReadServerEncryptionKey()); decrypt.DecryptDocument(); // create object (desearilize) AccountMessageSerializer serializer = new AccountMessageSerializer(); AccountDatabase database = (AccountDatabase)Create(document); return database; } else { return base.Load (sectionName, fileName); } }
/// <summary> /// Decrypts the body object. /// </summary> /// <param name="envelope"> The SoapEnvelope.</param> /// <returns> The XmlDocument with the decrypted Soap Body object.</returns> private XmlDocument DecryptBodyObject(SoapEnvelope envelope) { // add to new document XmlNode node = envelope.SelectSingleNode("//EncryptedData"); XmlDocument document = new XmlDocument(); document.AppendChild(document.ImportNode(node,true)); // decrypt EcyXmlEncryption.EncryptXml decrypt = new EcyXmlEncryption.EncryptXml(document); decrypt.AddKeyNameMapping("accountMessage", ReadTransportKey()); decrypt.DecryptDocument(); return document; }
/// <summary> /// Decrypts a XmlDocument representing a secure login credentials. /// </summary> /// <param name="encryptedDocument"> A XmlDocument type.</param> /// <returns> A decrypted secure login credentials.</returns> public static SecureLoginCredentials Load() { XmlDocument encryptedDocument = new XmlDocument(); encryptedDocument.Load(location); // add to new document XmlNode node = encryptedDocument.SelectSingleNode("//EncryptedData"); SecureLoginCredentials sec = null; SecureLoginCredentialsSerializer serializer = new SecureLoginCredentialsSerializer(); if ( node != null ) { XmlDocument document = new XmlDocument(); document.AppendChild(document.ImportNode(node,true)); // decrypt EncryptXml decrypt = new EncryptXml(document); decrypt.AddKeyNameMapping("slcreds", decrypt.GetMachineStoreKey("Ecyware.SecLogCreds")); decrypt.DecryptDocument(); sec = (SecureLoginCredentials)serializer.Create(document.DocumentElement.OuterXml); } return sec; }
/// <summary> /// Decrypts the body object. /// </summary> /// <param name="envelope"> The SoapEnvelope.</param> /// <returns> The XmlDocument with the decrypted Soap Body object.</returns> private XmlDocument Decrypt(XmlDocument encryptedDocument) { // add to new document XmlNode node = encryptedDocument.SelectSingleNode("//EncryptedData"); XmlDocument document = new XmlDocument(); document.AppendChild(document.ImportNode(node,true)); // decrypt EcyXmlEncryption.EncryptXml decrypt = new EcyXmlEncryption.EncryptXml(document); decrypt.AddKeyNameMapping("scriptingApplication", decrypt.GetMachineStoreKey("Ecyware.ScrAppEncryption")); decrypt.DecryptDocument(); return document; }
/// <summary> /// Decrypts a XmlDocument representing a scripting application. /// </summary> /// <param name="encryptedDocument"> A XmlDocument type.</param> /// <returns> A decrypted Scripting Application.</returns> public static ScriptingApplication Decrypt(XmlDocument encryptedDocument) { // add to new document XmlNode node = encryptedDocument.SelectSingleNode("//EncryptedData"); ScriptingApplication scrapp = null; ScriptingApplicationSerializer serializer = new ScriptingApplicationSerializer(); if ( node != null ) { XmlDocument document = new XmlDocument(); document.AppendChild(document.ImportNode(node,true)); // decrypt EncryptXml decrypt = new EncryptXml(document); decrypt.AddKeyNameMapping("scriptingApplication", decrypt.GetMachineStoreKey("Ecyware.ScrAppEncryption")); decrypt.DecryptDocument(); scrapp = (ScriptingApplication)serializer.Create(document.DocumentElement.OuterXml); } else { scrapp = (ScriptingApplication)serializer.Create(encryptedDocument.DocumentElement.OuterXml); } return scrapp; }