private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer<string> serializer; switch (saveFormat) { case ConnectionsSaver.Format.mRXML: var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = Settings.Default.EncryptionKeyDerivationIterations; serializer = new XmlConnectionsSerializer(cryptographyProvider); ((XmlConnectionsSerializer) serializer).SaveFilter = saveFilter; break; case ConnectionsSaver.Format.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat(); ((CsvConnectionsSerializerMremotengFormat)serializer).SaveFilter = saveFilter; break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.RemoteConnectionsSyncronizer?.Enable(); } }
public void Save(ConnectionTreeModel connectionTreeModel, string propertyNameTrigger = "") { try { var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build(); var connectionNodeSerializer = new XmlConnectionNodeSerializer27( cryptographyProvider, connectionTreeModel .RootNodes.OfType <RootNodeInfo>() .First().PasswordString .ConvertToSecureString(), _saveFilter); var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer) { UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile }; var xml = xmlConnectionsSerializer.Serialize(connectionTreeModel); var fileDataProvider = new FileDataProviderWithRollingBackup(_connectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector?.AddExceptionStackTrace("SaveToXml failed", ex); } }
public void Setup() { var encryptor = new AeadCryptographyProvider(); _serializer = new XmlConnectionsSerializer(encryptor); _connectionTreeModel = SetupConnectionTreeModel(); }
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer <string> serializer; switch (saveFormat) { case ConnectionsSaver.Format.mRXML: serializer = new XmlConnectionsSerializer(); ((XmlConnectionsSerializer)serializer).SaveFilter = saveFilter; break; case ConnectionsSaver.Format.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat(); ((CsvConnectionsSerializerMremotengFormat)serializer).SaveFilter = saveFilter; break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.RemoteConnectionsSyncronizer?.Enable(); } }
public void Setup() { _connectionTreeModel = SetupConnectionTreeModel(); _cryptographyProvider = new AeadCryptographyProvider(); var connectionNodeSerializer = new XmlConnectionNodeSerializer27( _cryptographyProvider, _connectionTreeModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter()); _serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer); }
public void Setup() { _originalModel = SetupConnectionTreeModel(); var cryptoProvider = _cryptoFactory.Build(); var nodeSerializer = new XmlConnectionNodeSerializer27( cryptoProvider, _originalModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter()); _serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer); _deserializer = new XmlConnectionsDeserializer(); }
public void SerializeAndDeserializeWithCustomKdfIterationsValue() { var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM); cryptoProvider.KeyDerivationIterations = 5000; _serializer = new XmlConnectionsSerializer(cryptoProvider); var originalModel = SetupConnectionTreeModel(); var serializedContent = _serializer.Serialize(originalModel); _deserializer = new XmlConnectionsDeserializer(serializedContent); var deserializedModel = _deserializer.Deserialize(); var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name); var nodeNamesFromOriginalModel = originalModel.GetRecursiveChildList().Select(node => node.Name); Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel)); }
private XDocument CreateTestData(ConnectionInfo connectionInfo) { var rootNode = new RootNodeInfo(RootNodeType.Connection) { PasswordString = _key.ConvertToUnsecureString() }; rootNode.AddChild(connectionInfo); var nodeSerializer = new XmlConnectionNodeSerializer27(_cryptographyProvider, _key, new SaveFilter()); var serializer = new XmlConnectionsSerializer(_cryptographyProvider, nodeSerializer); var serializedData = serializer.Serialize(rootNode); return(XDocument.Parse(serializedData)); }
public void SerializeAndDeserializeWithCustomKdfIterationsValue() { var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM); cryptoProvider.KeyDerivationIterations = 5000; _serializer = new XmlConnectionsSerializer(cryptoProvider); var originalModel = SetupConnectionTreeModel(); var serializedContent = _serializer.Serialize(originalModel); _deserializer = new XmlConnectionsDeserializer(serializedContent); var deserializedModel = _deserializer.Deserialize(); var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name); var nodeNamesFromOriginalModel = originalModel.GetRecursiveChildList().Select(node => node.Name); Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel)); }
private static void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer <ConnectionInfo, string> serializer; switch (saveFormat) { case SaveFormat.mRXML: var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build(); var rootNode = exportTarget.GetRootParent() as RootNodeInfo; var connectionNodeSerializer = new XmlConnectionNodeSerializer27( cryptographyProvider, rootNode?.PasswordString .ConvertToSecureString() ?? new RootNodeInfo(RootNodeType .Connection) .PasswordString .ConvertToSecureString(), saveFilter); serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer); break; case SaveFormat.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog); break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable(); } }
public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue) { var connectionNodeSerializer = new XmlConnectionNodeSerializer27( _cryptographyProvider, _connectionTreeModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter(true)); var serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer); var connectionInfo = new ConnectionInfo { Name = "myConnection", Inheritance = { AutomaticResize = true } }; var serializedConnections = serializer.Serialize(connectionInfo); var xdoc = XDocument.Parse(serializedConnections); var attributeValue = xdoc.Root?.Element("Node")?.Attribute(attributeName)?.Value; Assert.That(attributeValue, Is.EqualTo(expectedValue)); }
public void Setup() { _connectionTreeModel = new ConnectionTreeModelBuilder().Build(); _cryptographyProvider = new AeadCryptographyProvider(); var connectionNodeSerializer = new XmlConnectionNodeSerializer26( _cryptographyProvider, _connectionTreeModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter()); _serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer); _xmlReaderSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema, ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings }; }
public void SerializeAndDeserializeWithCustomKdfIterationsValue() { var cryptoProvider = _cryptoFactory.Build(); cryptoProvider.KeyDerivationIterations = 5000; var nodeSerializer = new XmlConnectionNodeSerializer27( cryptoProvider, _originalModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter()); _serializer = new XmlConnectionsSerializer(cryptoProvider, nodeSerializer); var serializedContent = _serializer.Serialize(_originalModel); var deserializedModel = _deserializer.Deserialize(serializedContent); var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name); var nodeNamesFromOriginalModel = _originalModel.GetRecursiveChildList().Select(node => node.Name); Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel)); }
private void SaveToXml() { try { var xmlConnectionsSerializer = new XmlConnectionsSerializer() { Export = Export, SaveSecurity = SaveSecurity }; var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel); var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex); } }
private void SaveToXml() { try { var xmlConnectionsSerializer = new XmlConnectionsSerializer() { Export = Export, SaveFilter = SaveFilter, UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile }; var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel); var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex); } }
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer <string> serializer; switch (saveFormat) { case ConnectionsSaver.Format.mRXML: var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = Settings.Default.EncryptionKeyDerivationIterations; serializer = new XmlConnectionsSerializer(cryptographyProvider) { Export = true, SaveFilter = saveFilter }; break; case ConnectionsSaver.Format.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat { SaveFilter = saveFilter }; break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.RemoteConnectionsSyncronizer?.Enable(); } }
private void SaveToXml() { try { var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations; var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider) { Export = Export, SaveFilter = SaveFilter, UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile }; var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel); var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex); } }
public void Setup() { var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM); _serializer = new XmlConnectionsSerializer(cryptoProvider); }
public void Setup() { var encryptor = new AeadCryptographyProvider(); _serializer = new XmlConnectionsSerializer(encryptor); _connectionTreeModel = SetupConnectionTreeModel(); }
public void Teardown() { _serializer = null; _deserializer = null; }
public void Setup() { var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM); _serializer = new XmlConnectionsSerializer(cryptoProvider); }
public void Teardown() { _serializer = null; _deserializer = null; }
private void SaveToXml() { try { var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations; var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider) { Export = Export, SaveFilter = SaveFilter, UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile }; var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel); var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex); } }