diff --git a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/ValidateXmlSchemas.cs b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/ValidateXmlSchemas.cs new file mode 100644 index 000000000..c0818b866 --- /dev/null +++ b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/ValidateXmlSchemas.cs @@ -0,0 +1,96 @@ +using System; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Xml; +using System.Xml.Schema; +using mRemoteNG.Config.Serializers.Xml; +using mRemoteNG.Security; +using mRemoteNG.Security.SymmetricEncryption; +using mRemoteNG.Tree; +using mRemoteNG.Tree.Root; +using mRemoteNGTests.TestHelpers; +using NUnit.Framework; + +namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml +{ + public class ValidateXmlSchemas + { + private XmlConnectionsSerializer _serializer; + private ConnectionTreeModel _connectionTreeModel; + private ICryptographyProvider _cryptographyProvider; + private XmlReaderSettings _xmlReaderSettings; + + [SetUp] + public void Setup() + { + _connectionTreeModel = new ConnectionTreeModelBuilder().Build(); + _cryptographyProvider = new AeadCryptographyProvider(); + var connectionNodeSerializer = new XmlConnectionNodeSerializer26( + _cryptographyProvider, + _connectionTreeModel.RootNodes.OfType().First().PasswordString.ConvertToSecureString(), + new SaveFilter()); + _serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer); + _xmlReaderSettings = new XmlReaderSettings + { + ValidationType = ValidationType.Schema, + ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | + XmlSchemaValidationFlags.ProcessSchemaLocation | + XmlSchemaValidationFlags.ReportValidationWarnings + }; + } + + [Test] + public void ValidateSchema() + { + var sb = new StringBuilder(); + var xml = _serializer.Serialize(_connectionTreeModel); + + var schemaFile = GetTargetPath("mremoteng_confcons_v2_6.xsd"); + _xmlReaderSettings.Schemas.Add("http://mremoteng.org", schemaFile); + _xmlReaderSettings.ValidationEventHandler += (sender, args) => + { + sb.AppendLine($"{args.Severity}: {args.Message}"); + }; + + using (var stream = GenerateStreamFromString(xml)) + { + var reader = XmlReader.Create(stream, _xmlReaderSettings); + while (reader.Read()) ; + } + + Assert.That(sb.ToString(), Is.Empty); + } + + public string GetTargetPath(string fileName, [CallerFilePath] string sourceFilePath = "") + { + const string debugOrRelease = +#if DEBUG + "Debug"; +#else + "Release"; +#endif + + const string normalOrPortable = +#if PORTABLE + " Portable"; +#else + ""; +#endif + var path = Path.GetDirectoryName(sourceFilePath); + var filePath = $@"{path}\..\..\..\..\bin\{debugOrRelease}{normalOrPortable}\Schemas\{fileName}"; + return filePath; + } + + private Stream GenerateStreamFromString(string s) + { + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; + } + } +} diff --git a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs index e4b661088..a3b3310ad 100644 --- a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs +++ b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs @@ -56,7 +56,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml [TestCase("Username", "")] [TestCase("Domain", "")] [TestCase("Password", "")] - [TestCase("InheritAutomaticResize", "False")] + [TestCase("InheritAutomaticResize", "false")] public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue) { var connectionNodeSerializer = new XmlConnectionNodeSerializer26( diff --git a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializerTests.cs b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializerTests.cs index 07c8e92f4..8a04af9d2 100644 --- a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializerTests.cs +++ b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializerTests.cs @@ -76,7 +76,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml { var element = _rootNodeSerializer.SerializeRootNodeInfo(_rootNodeInfo, _cryptographyProvider, fullFileEncryption); var attributeValue = element.Attribute(XName.Get("FullFileEncryption"))?.Value; - Assert.That(attributeValue, Is.EqualTo(fullFileEncryption.ToString())); + Assert.That(bool.Parse(attributeValue), Is.EqualTo(fullFileEncryption)); } [TestCase("", "ThisIsNotProtected")] diff --git a/mRemoteNGTests/mRemoteNGTests.csproj b/mRemoteNGTests/mRemoteNGTests.csproj index 05c021f45..b8f75cbf9 100644 --- a/mRemoteNGTests/mRemoteNGTests.csproj +++ b/mRemoteNGTests/mRemoteNGTests.csproj @@ -114,6 +114,7 @@ + diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer26.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer26.cs index a39792cd2..f46028874 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer26.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer26.cs @@ -42,7 +42,7 @@ namespace mRemoteNG.Config.Serializers.Xml element.Add(new XAttribute("Name", connectionInfo.Name)); element.Add(new XAttribute("Type", connectionInfo.GetTreeNodeType().ToString())); if (nodeAsContainer != null) - element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString())); + element.Add(new XAttribute("Expanded", nodeAsContainer.IsExpanded.ToString().ToLowerInvariant())); element.Add(new XAttribute("Descr", connectionInfo.Description)); element.Add(new XAttribute("Icon", connectionInfo.Icon)); element.Add(new XAttribute("Panel", connectionInfo.Panel)); @@ -65,30 +65,30 @@ namespace mRemoteNG.Config.Serializers.Xml element.Add(new XAttribute("Protocol", connectionInfo.Protocol)); element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession)); element.Add(new XAttribute("Port", connectionInfo.Port)); - element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString())); - element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString())); + element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant())); + element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant())); element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine)); element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength)); element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel)); element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout)); - element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout)); + element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant())); element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo)); element.Add(new XAttribute("Colors", connectionInfo.Colors)); element.Add(new XAttribute("Resolution", connectionInfo.Resolution)); - element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString())); - element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString())); - element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString())); - element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString())); - element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString())); - element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString())); - element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString())); - element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString())); - element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString())); - element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString())); - element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString())); + element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant())); + element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant())); + element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant())); + element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant())); + element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant())); + element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant())); + element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant())); + element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant())); + element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant())); + element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant())); + element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString().ToLowerInvariant())); element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString())); - element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString())); - element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString())); + element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant())); + element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant())); element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp)); element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp)); element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress)); @@ -112,7 +112,7 @@ namespace mRemoteNG.Config.Serializers.Xml element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors)); element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode)); - element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString())); + element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant())); element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod)); element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname)); element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials)); @@ -135,117 +135,118 @@ namespace mRemoteNG.Config.Serializers.Xml { if (_saveFilter.SaveInheritance) { - element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString())); - element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString())); - element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString())); - element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString())); - element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString())); - element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString())); - element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString())); - element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString())); - element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString())); - element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString())); - element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString())); - element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString())); - element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString())); - element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString())); - element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString())); - element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString())); - element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString())); - element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString())); - element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString())); - element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString())); - element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString())); - element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString())); - element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString())); - element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString())); - element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString())); - element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString())); - element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString())); - element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString())); - element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString())); - element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString())); - element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString())); - element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString())); - element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString())); - element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString())); - element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString())); - element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString())); - element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString())); - element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString())); - element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString())); - element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString())); - element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString())); - element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString())); - element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString())); - element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString())); - element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString())); - element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString())); - element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString())); - element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString())); - element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString())); - element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString())); - element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString())); - element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString())); - element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString())); - element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString())); + element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant())); + element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant())); } else { - element.Add(new XAttribute("InheritCacheBitmaps", false.ToString())); - element.Add(new XAttribute("InheritColors", false.ToString())); - element.Add(new XAttribute("InheritDescription", false.ToString())); - element.Add(new XAttribute("InheritDisplayThemes", false.ToString())); - element.Add(new XAttribute("InheritDisplayWallpaper", false.ToString())); - element.Add(new XAttribute("InheritEnableFontSmoothing", false.ToString())); - element.Add(new XAttribute("InheritEnableDesktopComposition", false.ToString())); - element.Add(new XAttribute("InheritDomain", false.ToString())); - element.Add(new XAttribute("InheritIcon", false.ToString())); - element.Add(new XAttribute("InheritPanel", false.ToString())); - element.Add(new XAttribute("InheritPassword", false.ToString())); - element.Add(new XAttribute("InheritPort", false.ToString())); - element.Add(new XAttribute("InheritProtocol", false.ToString())); - element.Add(new XAttribute("InheritPuttySession", false.ToString())); - element.Add(new XAttribute("InheritRedirectDiskDrives", false.ToString())); - element.Add(new XAttribute("InheritRedirectKeys", false.ToString())); - element.Add(new XAttribute("InheritRedirectPorts", false.ToString())); - element.Add(new XAttribute("InheritRedirectPrinters", false.ToString())); - element.Add(new XAttribute("InheritRedirectSmartCards", false.ToString())); - element.Add(new XAttribute("InheritRedirectSound", false.ToString())); - element.Add(new XAttribute("InheritSoundQuality", false.ToString())); - element.Add(new XAttribute("InheritResolution", false.ToString())); - element.Add(new XAttribute("InheritAutomaticResize", false.ToString())); - element.Add(new XAttribute("InheritUseConsoleSession", false.ToString())); - element.Add(new XAttribute("InheritUseCredSsp", false.ToString())); - element.Add(new XAttribute("InheritRenderingEngine", false.ToString())); - element.Add(new XAttribute("InheritUsername", false.ToString())); - element.Add(new XAttribute("InheritICAEncryptionStrength", false.ToString())); - element.Add(new XAttribute("InheritRDPAuthenticationLevel", false.ToString())); - element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", false.ToString())); - element.Add(new XAttribute("InheritRDPAlertIdleTimeout", false.ToString())); - element.Add(new XAttribute("InheritLoadBalanceInfo", false.ToString())); - element.Add(new XAttribute("InheritPreExtApp", false.ToString())); - element.Add(new XAttribute("InheritPostExtApp", false.ToString())); - element.Add(new XAttribute("InheritMacAddress", false.ToString())); - element.Add(new XAttribute("InheritUserField", false.ToString())); - element.Add(new XAttribute("InheritExtApp", false.ToString())); - element.Add(new XAttribute("InheritVNCCompression", false.ToString())); - element.Add(new XAttribute("InheritVNCEncoding", false.ToString())); - element.Add(new XAttribute("InheritVNCAuthMode", false.ToString())); - element.Add(new XAttribute("InheritVNCProxyType", false.ToString())); - element.Add(new XAttribute("InheritVNCProxyIP", false.ToString())); - element.Add(new XAttribute("InheritVNCProxyPort", false.ToString())); - element.Add(new XAttribute("InheritVNCProxyUsername", false.ToString())); - element.Add(new XAttribute("InheritVNCProxyPassword", false.ToString())); - element.Add(new XAttribute("InheritVNCColors", false.ToString())); - element.Add(new XAttribute("InheritVNCSmartSizeMode", false.ToString())); - element.Add(new XAttribute("InheritVNCViewOnly", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayUsageMethod", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayHostname", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayUsername", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayPassword", false.ToString())); - element.Add(new XAttribute("InheritRDGatewayDomain", false.ToString())); + var falseString = false.ToString().ToLowerInvariant(); + element.Add(new XAttribute("InheritCacheBitmaps", falseString)); + element.Add(new XAttribute("InheritColors", falseString)); + element.Add(new XAttribute("InheritDescription", falseString)); + element.Add(new XAttribute("InheritDisplayThemes", falseString)); + element.Add(new XAttribute("InheritDisplayWallpaper", falseString)); + element.Add(new XAttribute("InheritEnableFontSmoothing", falseString)); + element.Add(new XAttribute("InheritEnableDesktopComposition", falseString)); + element.Add(new XAttribute("InheritDomain", falseString)); + element.Add(new XAttribute("InheritIcon", falseString)); + element.Add(new XAttribute("InheritPanel", falseString)); + element.Add(new XAttribute("InheritPassword", falseString)); + element.Add(new XAttribute("InheritPort", falseString)); + element.Add(new XAttribute("InheritProtocol", falseString)); + element.Add(new XAttribute("InheritPuttySession", falseString)); + element.Add(new XAttribute("InheritRedirectDiskDrives", falseString)); + element.Add(new XAttribute("InheritRedirectKeys", falseString)); + element.Add(new XAttribute("InheritRedirectPorts", falseString)); + element.Add(new XAttribute("InheritRedirectPrinters", falseString)); + element.Add(new XAttribute("InheritRedirectSmartCards", falseString)); + element.Add(new XAttribute("InheritRedirectSound", falseString)); + element.Add(new XAttribute("InheritSoundQuality", falseString)); + element.Add(new XAttribute("InheritResolution", falseString)); + element.Add(new XAttribute("InheritAutomaticResize", falseString)); + element.Add(new XAttribute("InheritUseConsoleSession", falseString)); + element.Add(new XAttribute("InheritUseCredSsp", falseString)); + element.Add(new XAttribute("InheritRenderingEngine", falseString)); + element.Add(new XAttribute("InheritUsername", falseString)); + element.Add(new XAttribute("InheritICAEncryptionStrength", falseString)); + element.Add(new XAttribute("InheritRDPAuthenticationLevel", falseString)); + element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", falseString)); + element.Add(new XAttribute("InheritRDPAlertIdleTimeout", falseString)); + element.Add(new XAttribute("InheritLoadBalanceInfo", falseString)); + element.Add(new XAttribute("InheritPreExtApp", falseString)); + element.Add(new XAttribute("InheritPostExtApp", falseString)); + element.Add(new XAttribute("InheritMacAddress", falseString)); + element.Add(new XAttribute("InheritUserField", falseString)); + element.Add(new XAttribute("InheritExtApp", falseString)); + element.Add(new XAttribute("InheritVNCCompression", falseString)); + element.Add(new XAttribute("InheritVNCEncoding", falseString)); + element.Add(new XAttribute("InheritVNCAuthMode", falseString)); + element.Add(new XAttribute("InheritVNCProxyType", falseString)); + element.Add(new XAttribute("InheritVNCProxyIP", falseString)); + element.Add(new XAttribute("InheritVNCProxyPort", falseString)); + element.Add(new XAttribute("InheritVNCProxyUsername", falseString)); + element.Add(new XAttribute("InheritVNCProxyPassword", falseString)); + element.Add(new XAttribute("InheritVNCColors", falseString)); + element.Add(new XAttribute("InheritVNCSmartSizeMode", falseString)); + element.Add(new XAttribute("InheritVNCViewOnly", falseString)); + element.Add(new XAttribute("InheritRDGatewayUsageMethod", falseString)); + element.Add(new XAttribute("InheritRDGatewayHostname", falseString)); + element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", falseString)); + element.Add(new XAttribute("InheritRDGatewayUsername", falseString)); + element.Add(new XAttribute("InheritRDGatewayPassword", falseString)); + element.Add(new XAttribute("InheritRDGatewayDomain", falseString)); } } } diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs index 61ae2aae6..5f08d2c78 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs @@ -71,7 +71,8 @@ namespace mRemoteNG.Config.Serializers.Xml if (_confVersion >= 2.6) { - if (rootXmlElement?.Attributes["FullFileEncryption"].Value == "True") + var fullFileEncryptionValue = rootXmlElement?.Attributes["FullFileEncryption"].Value ?? ""; + if (bool.Parse(fullFileEncryptionValue)) { var decryptedContent = _decryptor.Decrypt(rootXmlElement.InnerText); rootXmlElement.InnerXml = decryptedContent; diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializer.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializer.cs index 26a1e3d85..7dc2b3d13 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializer.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlRootNodeSerializer.cs @@ -8,12 +8,14 @@ namespace mRemoteNG.Config.Serializers.Xml { public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider, bool fullFileEncryption = false) { - var element = new XElement("Connections"); + XNamespace xmlNamespace = "http://mremoteng.org"; + var element = new XElement(xmlNamespace + "Connections"); + element.Add(new XAttribute(XNamespace.Xmlns+"mrng", xmlNamespace)); element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name)); element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine)); element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode)); element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations)); - element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString())); + element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant())); element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider)); element.Add(new XAttribute(XName.Get("ConfVersion"), "2.6")); return element; diff --git a/mRemoteV1/Schemas/mremoteng_confcons_v2_6.xsd b/mRemoteV1/Schemas/mremoteng_confcons_v2_6.xsd index 8f2b79160..485af1c34 100644 --- a/mRemoteV1/Schemas/mremoteng_confcons_v2_6.xsd +++ b/mRemoteV1/Schemas/mremoteng_confcons_v2_6.xsd @@ -1,20 +1,19 @@  - + - @@ -31,6 +30,7 @@ + diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index da0ca989b..c0f0bf527 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -964,9 +964,10 @@ Designer - + Designer - + Always + Designer