diff --git a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs index aead6d324..ad51a69b8 100644 --- a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs +++ b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsSerializerTests.cs @@ -52,7 +52,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Xml Assert.That(connectionNode, Is.Not.Null); } - [TestCase("CredentialRecordId", "")] + [TestCase("CredentialId", "")] [TestCase("InheritAutomaticResize", "false")] public void SerializerRespectsSaveFilterSettings(string attributeName, string expectedValue) { diff --git a/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs b/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs index 1bf631285..05142365a 100644 --- a/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs +++ b/mRemoteNGTests/Connection/DefaultConnectionInfoTests.cs @@ -50,7 +50,7 @@ namespace mRemoteNGTests.Connection DefaultConnectionInfo.Instance.SaveTo(saveTarget); var valueInSource = property.GetValue(DefaultConnectionInfo.Instance).ToString(); - var valueInDestination = saveTarget.GetType().GetProperty(property.Name).GetValue(saveTarget).ToString(); + var valueInDestination = saveTarget.GetType().GetProperty(property.Name)?.GetValue(saveTarget).ToString(); Assert.That(valueInDestination, Is.EqualTo(valueInSource)); } diff --git a/mRemoteNGTests/Connection/DefaultConnectionInheritanceTests.cs b/mRemoteNGTests/Connection/DefaultConnectionInheritanceTests.cs index b86f15de7..bd778bc29 100644 --- a/mRemoteNGTests/Connection/DefaultConnectionInheritanceTests.cs +++ b/mRemoteNGTests/Connection/DefaultConnectionInheritanceTests.cs @@ -39,9 +39,9 @@ namespace mRemoteNGTests.Connection [Test] public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues() { - DefaultConnectionInheritance.Instance.Domain = true; + DefaultConnectionInheritance.Instance.Description = true; var inheritanceInstance = new ConnectionInfoInheritance(new object()); - Assert.That(inheritanceInstance.Domain, Is.True); + Assert.That(inheritanceInstance.Description, Is.True); } [TestCaseSource(nameof(GetInheritanceProperties))] diff --git a/mRemoteNGTests/Container/RootNodeInfoTests.cs b/mRemoteNGTests/Container/RootNodeInfoTests.cs index fbd5894ec..617816d40 100644 --- a/mRemoteNGTests/Container/RootNodeInfoTests.cs +++ b/mRemoteNGTests/Container/RootNodeInfoTests.cs @@ -10,9 +10,9 @@ namespace mRemoteNGTests.Container public void InheritanceIsDisabledForNodesDirectlyUnderRootNode() { var rootNode = new RootNodeInfo(RootNodeType.Connection); - var con1 = new ConnectionInfo { Inheritance = { Password = true } }; + var con1 = new ConnectionInfo { Inheritance = { Colors = true } }; rootNode.AddChild(con1); - Assert.That(con1.Inheritance.Password, Is.False); + Assert.That(con1.Inheritance.Colors, Is.False); } } } diff --git a/mRemoteNGTests/Credential/CompositeRepositoryUnlockerTests.cs b/mRemoteNGTests/Credential/CompositeRepositoryUnlockerTests.cs index fd1a9c5fe..c66f992ae 100644 --- a/mRemoteNGTests/Credential/CompositeRepositoryUnlockerTests.cs +++ b/mRemoteNGTests/Credential/CompositeRepositoryUnlockerTests.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Security; using mRemoteNG.Credential; using mRemoteNG.Credential.Repositories; +using mRemoteNG.Tools; using NSubstitute; using NUnit.Framework; @@ -29,7 +30,7 @@ namespace mRemoteNGTests.Credential [Test] public void TheFirstRepoIsInitiallySelected() { - Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[0])); + Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[0].ToOptional())); } [Test] @@ -45,7 +46,7 @@ namespace mRemoteNGTests.Credential { _repos[1].IsLoaded.Returns(true); _repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[2])); + Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[2].ToOptional())); } [Test] @@ -54,7 +55,7 @@ namespace mRemoteNGTests.Credential var repos = BuildRepos(1); var repositoryUnlocker = new CompositeRepositoryUnlocker(repos); repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(repositoryUnlocker.SelectedRepository, Is.EqualTo(repos[0])); + Assert.That(repositoryUnlocker.SelectedRepository, Is.EqualTo(repos[0].ToOptional())); } [Test] @@ -63,7 +64,7 @@ namespace mRemoteNGTests.Credential foreach(var repo in _repos) repo.IsLoaded.Returns(true); _repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(_repositoryUnlocker.SelectedRepository, Is.Null); + Assert.That(_repositoryUnlocker.SelectedRepository, Is.Empty); } [Test] @@ -73,7 +74,7 @@ namespace mRemoteNGTests.Credential repo.IsLoaded.Returns(true); _repos[0].IsLoaded.Returns(false); _repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[0])); + Assert.That(_repositoryUnlocker.SelectedRepository, Is.EqualTo(_repos[0].ToOptional())); } [Test] @@ -81,7 +82,7 @@ namespace mRemoteNGTests.Credential { var repositoryUnlocker = new CompositeRepositoryUnlocker(new ICredentialRepository[0]); repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(repositoryUnlocker.SelectedRepository, Is.Null); + Assert.That(repositoryUnlocker.SelectedRepository, Is.Empty); } [Test] @@ -91,7 +92,7 @@ namespace mRemoteNGTests.Credential repo[0].IsLoaded.Returns(false); var repositoryUnlocker = new CompositeRepositoryUnlocker(repo); repositoryUnlocker.SelectNextLockedRepository(); - Assert.That(repositoryUnlocker.SelectedRepository, Is.EqualTo(repo[0])); + Assert.That(repositoryUnlocker.SelectedRepository, Is.EqualTo(repo[0].ToOptional())); } private IList BuildRepos(int count) diff --git a/mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs b/mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs index 81e8eb511..8e2d8179c 100644 --- a/mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs +++ b/mRemoteNGTests/TestHelpers/ConnectionInfoHelpers.cs @@ -24,13 +24,15 @@ namespace mRemoteNGTests.TestHelpers Name = RandomString(), Hostname = RandomString(), Description = RandomString(), + CredentialRecordId = Guid.NewGuid(), + Username = RandomString(), Domain = RandomString(), + Password = RandomString(), ExtApp = RandomString(), Icon = RandomString(), LoadBalanceInfo = RandomString(), MacAddress = RandomString(), Panel = RandomString(), - Password = RandomString(), PostExtApp = RandomString(), PreExtApp = RandomString(), PuttySession = RandomString(), @@ -39,7 +41,6 @@ namespace mRemoteNGTests.TestHelpers RDGatewayDomain = RandomString(), RDGatewayPassword = RandomString(), UserField = RandomString(), - Username = RandomString(), VNCProxyIP = RandomString(), VNCProxyPassword = RandomString(), VNCProxyUsername = RandomString(), diff --git a/mRemoteNGTests/TestHelpers/Randomizer.cs b/mRemoteNGTests/TestHelpers/Randomizer.cs index 7286dee3b..a9b841589 100644 --- a/mRemoteNGTests/TestHelpers/Randomizer.cs +++ b/mRemoteNGTests/TestHelpers/Randomizer.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using mRemoteNG.Credential; using Enum = System.Enum; namespace mRemoteNGTests.TestHelpers @@ -86,6 +87,7 @@ namespace mRemoteNGTests.TestHelpers { typeof(string), (p, c) => p.SetValue(c, RandomString((string)p.GetValue(c))) }, { typeof(DateTime), (p, c) => p.SetValue(c, RandomDateTime((DateTime)p.GetValue(c))) }, { typeof(Enum), (p, c) => p.SetValue(c, RandomEnum(p.PropertyType, p.GetValue(c))) }, + { typeof(ICredentialRecord), (p, c) => {} }, }; var settableProperties = con diff --git a/mRemoteNGTests/TestHelpers/SerializableConnectionInfoAllPropertiesOfType.cs b/mRemoteNGTests/TestHelpers/SerializableConnectionInfoAllPropertiesOfType.cs index de17b756a..eaf162322 100644 --- a/mRemoteNGTests/TestHelpers/SerializableConnectionInfoAllPropertiesOfType.cs +++ b/mRemoteNGTests/TestHelpers/SerializableConnectionInfoAllPropertiesOfType.cs @@ -9,9 +9,7 @@ public TType Description { get; set; } public TType Icon { get; set; } public TType Panel { get; set; } - public TType Username { get; set; } - public TType Password { get; set; } - public TType Domain { get; set; } + public TType CredentialRecordId { get; set; } public TType Protocol { get; set; } public TType ExtApp { get; set; } public TType PuttySession { get; set; } diff --git a/mRemoteNGTests/Tools/OptionalTests.cs b/mRemoteNGTests/Tools/OptionalTests.cs index 222d08a7f..9e0f9bbc2 100644 --- a/mRemoteNGTests/Tools/OptionalTests.cs +++ b/mRemoteNGTests/Tools/OptionalTests.cs @@ -23,7 +23,7 @@ namespace mRemoteNGTests.Tools [Test] public void MaybeExtensionOfNullObjectIsntNull() { - var sut = ((object) null).Maybe(); + var sut = ((object) null).ToOptional(); Assert.That(sut, Is.Not.Null); } } diff --git a/mRemoteV1/App/Initialization/CredsAndConsSetup.cs b/mRemoteV1/App/Initialization/CredsAndConsSetup.cs index a281e183d..ea49e3555 100644 --- a/mRemoteV1/App/Initialization/CredsAndConsSetup.cs +++ b/mRemoteV1/App/Initialization/CredsAndConsSetup.cs @@ -29,7 +29,7 @@ namespace mRemoteNG.App.Initialization .Where(record => record.Id.Equals(defaultCredId)) .ToArray(); - DefaultConnectionInfo.Instance.CredentialRecordId = matchedCredentials.FirstOrDefault()?.Id.Maybe(); + DefaultConnectionInfo.Instance.CredentialRecordId = matchedCredentials.FirstOrDefault()?.Id.ToOptional(); } } } \ No newline at end of file diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormat.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormat.cs index 0bef17557..b1229a36b 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormat.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormat.cs @@ -111,612 +111,531 @@ namespace mRemoteNG.Config.Serializers.Csv if (headers.Contains("Protocol")) { - ProtocolType protocolType; - if (Enum.TryParse(connectionCsv[headers.IndexOf("Protocol")], out protocolType)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("Protocol")], out ProtocolType protocolType)) connectionRecord.Protocol = protocolType; } if (headers.Contains("Port")) { - int port; - if (int.TryParse(connectionCsv[headers.IndexOf("Port")], out port)) + if (int.TryParse(connectionCsv[headers.IndexOf("Port")], out int port)) connectionRecord.Port = port; } if (headers.Contains("ConnectToConsole")) { - bool useConsoleSession; - if (bool.TryParse(connectionCsv[headers.IndexOf("ConnectToConsole")], out useConsoleSession)) + if (bool.TryParse(connectionCsv[headers.IndexOf("ConnectToConsole")], out bool useConsoleSession)) connectionRecord.UseConsoleSession = useConsoleSession; } if (headers.Contains("UseCredSsp")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("UseCredSsp")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("UseCredSsp")], out bool value)) connectionRecord.UseCredSsp = value; } if (headers.Contains("RenderingEngine")) { - HTTPBase.RenderingEngine value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("RenderingEngine")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("RenderingEngine")], out HTTPBase.RenderingEngine value)) connectionRecord.RenderingEngine = value; } if (headers.Contains("ICAEncryptionStrength")) { - IcaProtocol.EncryptionStrength value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("ICAEncryptionStrength")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("ICAEncryptionStrength")], out IcaProtocol.EncryptionStrength value)) connectionRecord.ICAEncryptionStrength = value; } if (headers.Contains("RDPAuthenticationLevel")) { - RdpProtocol.AuthenticationLevel value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("RDPAuthenticationLevel")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("RDPAuthenticationLevel")], out RdpProtocol.AuthenticationLevel value)) connectionRecord.RDPAuthenticationLevel = value; } if (headers.Contains("Colors")) { - RdpProtocol.RDPColors value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("Colors")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("Colors")], out RdpProtocol.RDPColors value)) connectionRecord.Colors = value; } if (headers.Contains("Resolution")) { - RdpProtocol.RDPResolutions value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("Resolution")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("Resolution")], out RdpProtocol.RDPResolutions value)) connectionRecord.Resolution = value; } if (headers.Contains("AutomaticResize")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("AutomaticResize")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("AutomaticResize")], out bool value)) connectionRecord.AutomaticResize = value; } if (headers.Contains("DisplayWallpaper")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayWallpaper")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayWallpaper")], out bool value)) connectionRecord.DisplayWallpaper = value; } if (headers.Contains("DisplayThemes")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayThemes")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("DisplayThemes")], out bool value)) connectionRecord.DisplayThemes = value; } if (headers.Contains("EnableFontSmoothing")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("EnableFontSmoothing")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("EnableFontSmoothing")], out bool value)) connectionRecord.EnableFontSmoothing = value; } if (headers.Contains("EnableDesktopComposition")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("EnableDesktopComposition")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("EnableDesktopComposition")], out bool value)) connectionRecord.EnableDesktopComposition = value; } if (headers.Contains("CacheBitmaps")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("CacheBitmaps")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("CacheBitmaps")], out bool value)) connectionRecord.CacheBitmaps = value; } if (headers.Contains("RedirectDiskDrives")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectDiskDrives")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectDiskDrives")], out bool value)) connectionRecord.RedirectDiskDrives = value; } if (headers.Contains("RedirectPorts")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPorts")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPorts")], out bool value)) connectionRecord.RedirectPorts = value; } if (headers.Contains("RedirectPrinters")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out bool value)) connectionRecord.RedirectPrinters = value; } if (headers.Contains("RedirectClipboard")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectClipboard")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectClipboard")], out bool value)) connectionRecord.RedirectClipboard = value; } if (headers.Contains("RedirectSmartCards")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectSmartCards")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectSmartCards")], out bool value)) connectionRecord.RedirectSmartCards = value; } if (headers.Contains("RedirectSound")) { - RdpProtocol.RDPSounds value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("RedirectSound")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("RedirectSound")], out RdpProtocol.RDPSounds value)) connectionRecord.RedirectSound = value; } if (headers.Contains("RedirectKeys")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectKeys")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectKeys")], out bool value)) connectionRecord.RedirectKeys = value; } if (headers.Contains("VNCCompression")) { - ProtocolVNC.Compression value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCCompression")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCCompression")], out ProtocolVNC.Compression value)) connectionRecord.VNCCompression = value; } if (headers.Contains("VNCEncoding")) { - ProtocolVNC.Encoding value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCEncoding")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCEncoding")], out ProtocolVNC.Encoding value)) connectionRecord.VNCEncoding = value; } if (headers.Contains("VNCAuthMode")) { - ProtocolVNC.AuthMode value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCAuthMode")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCAuthMode")], out ProtocolVNC.AuthMode value)) connectionRecord.VNCAuthMode = value; } if (headers.Contains("VNCProxyType")) { - ProtocolVNC.ProxyType value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCProxyType")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCProxyType")], out ProtocolVNC.ProxyType value)) connectionRecord.VNCProxyType = value; } if (headers.Contains("VNCProxyPort")) { - int value; - if (int.TryParse(connectionCsv[headers.IndexOf("VNCProxyPort")], out value)) + if (int.TryParse(connectionCsv[headers.IndexOf("VNCProxyPort")], out int value)) connectionRecord.VNCProxyPort = value; } if (headers.Contains("VNCColors")) { - ProtocolVNC.Colors value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCColors")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCColors")], out ProtocolVNC.Colors value)) connectionRecord.VNCColors = value; } if (headers.Contains("VNCSmartSizeMode")) { - ProtocolVNC.SmartSizeMode value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCSmartSizeMode")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("VNCSmartSizeMode")], out ProtocolVNC.SmartSizeMode value)) connectionRecord.VNCSmartSizeMode = value; } if (headers.Contains("VNCViewOnly")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("VNCViewOnly")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("VNCViewOnly")], out bool value)) connectionRecord.VNCViewOnly = value; } if (headers.Contains("RDGatewayUsageMethod")) { - RdpProtocol.RDGatewayUsageMethod value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUsageMethod")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUsageMethod")], out RdpProtocol.RDGatewayUsageMethod value)) connectionRecord.RDGatewayUsageMethod = value; } if (headers.Contains("RDGatewayUseConnectionCredentials")) { - RdpProtocol.RDGatewayUseConnectionCredentials value; - if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUseConnectionCredentials")], out value)) + if (Enum.TryParse(connectionCsv[headers.IndexOf("RDGatewayUseConnectionCredentials")], out RdpProtocol.RDGatewayUseConnectionCredentials value)) connectionRecord.RDGatewayUseConnectionCredentials = value; } #region Inheritance if (headers.Contains("InheritCacheBitmaps")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCacheBitmaps")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCacheBitmaps")], out bool value)) connectionRecord.Inheritance.CacheBitmaps = value; } if (headers.Contains("InheritColors")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritColors")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritColors")], out bool value)) connectionRecord.Inheritance.Colors = value; } if (headers.Contains("InheritDescription")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDescription")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDescription")], out bool value)) connectionRecord.Inheritance.Description = value; } if (headers.Contains("InheritDisplayThemes")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayThemes")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayThemes")], out bool value)) connectionRecord.Inheritance.DisplayThemes = value; } if (headers.Contains("InheritDisplayWallpaper")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayWallpaper")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDisplayWallpaper")], out bool value)) connectionRecord.Inheritance.DisplayWallpaper = value; } if (headers.Contains("InheritEnableFontSmoothing")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableFontSmoothing")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableFontSmoothing")], out bool value)) connectionRecord.Inheritance.EnableFontSmoothing = value; } if (headers.Contains("InheritEnableDesktopComposition")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableDesktopComposition")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritEnableDesktopComposition")], out bool value)) connectionRecord.Inheritance.EnableDesktopComposition = value; } if (headers.Contains("InheritDomain")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDomain")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritDomain")], out bool value)) connectionRecord.Inheritance.Domain = value; } if (headers.Contains("InheritIcon")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritIcon")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritIcon")], out bool value)) connectionRecord.Inheritance.Icon = value; } if (headers.Contains("InheritPanel")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPanel")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPanel")], out bool value)) connectionRecord.Inheritance.Panel = value; } if (headers.Contains("InheritPassword")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPassword")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPassword")], out bool value)) connectionRecord.Inheritance.Password = value; } if (headers.Contains("InheritPort")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPort")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPort")], out bool value)) connectionRecord.Inheritance.Port = value; } if (headers.Contains("InheritProtocol")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritProtocol")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritProtocol")], out bool value)) connectionRecord.Inheritance.Protocol = value; } if (headers.Contains("InheritPuttySession")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPuttySession")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPuttySession")], out bool value)) connectionRecord.Inheritance.PuttySession = value; } if (headers.Contains("InheritRedirectDiskDrives")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectDiskDrives")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectDiskDrives")], out bool value)) connectionRecord.Inheritance.RedirectDiskDrives = value; } if (headers.Contains("InheritRedirectKeys")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectKeys")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectKeys")], out bool value)) connectionRecord.Inheritance.RedirectKeys = value; } if (headers.Contains("InheritRedirectPorts")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPorts")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPorts")], out bool value)) connectionRecord.Inheritance.RedirectPorts = value; } if (headers.Contains("InheritRedirectPrinters")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPrinters")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectPrinters")], out bool value)) connectionRecord.Inheritance.RedirectPrinters = value; } if (headers.Contains("InheritRedirectClipboard")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectClipboard")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectClipboard")], out bool value)) connectionRecord.Inheritance.RedirectClipboard = value; } if (headers.Contains("InheritRedirectSmartCards")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSmartCards")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSmartCards")], out bool value)) connectionRecord.Inheritance.RedirectSmartCards = value; } if (headers.Contains("InheritRedirectSound")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSound")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRedirectSound")], out bool value)) connectionRecord.Inheritance.RedirectSound = value; } if (headers.Contains("InheritResolution")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritResolution")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritResolution")], out bool value)) connectionRecord.Inheritance.Resolution = value; } if (headers.Contains("InheritAutomaticResize")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritAutomaticResize")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritAutomaticResize")], out bool value)) connectionRecord.Inheritance.AutomaticResize = value; } if (headers.Contains("InheritUseConsoleSession")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseConsoleSession")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseConsoleSession")], out bool value)) connectionRecord.Inheritance.UseConsoleSession = value; } if (headers.Contains("InheritUseCredSsp")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseCredSsp")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUseCredSsp")], out bool value)) connectionRecord.Inheritance.UseCredSsp = value; } if (headers.Contains("InheritRenderingEngine")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRenderingEngine")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRenderingEngine")], out bool value)) connectionRecord.Inheritance.RenderingEngine = value; } if (headers.Contains("InheritUsername")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUsername")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUsername")], out bool value)) connectionRecord.Inheritance.Username = value; } if (headers.Contains("InheritICAEncryptionStrength")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritICAEncryptionStrength")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritICAEncryptionStrength")], out bool value)) connectionRecord.Inheritance.ICAEncryptionStrength = value; } if (headers.Contains("InheritRDPAuthenticationLevel")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAuthenticationLevel")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAuthenticationLevel")], out bool value)) connectionRecord.Inheritance.RDPAuthenticationLevel = value; } if (headers.Contains("InheritLoadBalanceInfo")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritLoadBalanceInfo")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritLoadBalanceInfo")], out bool value)) connectionRecord.Inheritance.LoadBalanceInfo = value; } if (headers.Contains("InheritPreExtApp")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPreExtApp")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPreExtApp")], out bool value)) connectionRecord.Inheritance.PreExtApp = value; } if (headers.Contains("InheritPostExtApp")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPostExtApp")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritPostExtApp")], out bool value)) connectionRecord.Inheritance.PostExtApp = value; } if (headers.Contains("InheritMacAddress")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritMacAddress")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritMacAddress")], out bool value)) connectionRecord.Inheritance.MacAddress = value; } if (headers.Contains("InheritUserField")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUserField")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritUserField")], out bool value)) connectionRecord.Inheritance.UserField = value; } if (headers.Contains("InheritExtApp")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritExtApp")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritExtApp")], out bool value)) connectionRecord.Inheritance.ExtApp = value; } if (headers.Contains("InheritVNCCompression")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCCompression")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCCompression")], out bool value)) connectionRecord.Inheritance.VNCCompression = value; } if (headers.Contains("InheritVNCEncoding")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCEncoding")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCEncoding")], out bool value)) connectionRecord.Inheritance.VNCEncoding = value; } if (headers.Contains("InheritVNCAuthMode")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCAuthMode")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCAuthMode")], out bool value)) connectionRecord.Inheritance.VNCAuthMode = value; } if (headers.Contains("InheritVNCProxyType")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyType")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyType")], out bool value)) connectionRecord.Inheritance.VNCProxyType = value; } if (headers.Contains("InheritVNCProxyIP")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyIP")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyIP")], out bool value)) connectionRecord.Inheritance.VNCProxyIP = value; } if (headers.Contains("InheritVNCProxyPort")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPort")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPort")], out bool value)) connectionRecord.Inheritance.VNCProxyPort = value; } if (headers.Contains("InheritVNCProxyUsername")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyUsername")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyUsername")], out bool value)) connectionRecord.Inheritance.VNCProxyUsername = value; } if (headers.Contains("InheritVNCProxyPassword")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPassword")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCProxyPassword")], out bool value)) connectionRecord.Inheritance.VNCProxyPassword = value; } if (headers.Contains("InheritVNCColors")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCColors")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCColors")], out bool value)) connectionRecord.Inheritance.VNCColors = value; } if (headers.Contains("InheritVNCSmartSizeMode")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCSmartSizeMode")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCSmartSizeMode")], out bool value)) connectionRecord.Inheritance.VNCSmartSizeMode = value; } if (headers.Contains("InheritVNCViewOnly")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCViewOnly")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritVNCViewOnly")], out bool value)) connectionRecord.Inheritance.VNCViewOnly = value; } if (headers.Contains("InheritRDGatewayUsageMethod")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsageMethod")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsageMethod")], out bool value)) connectionRecord.Inheritance.RDGatewayUsageMethod = value; } if (headers.Contains("InheritRDGatewayHostname")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayHostname")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayHostname")], out bool value)) connectionRecord.Inheritance.RDGatewayHostname = value; } if (headers.Contains("InheritRDGatewayUseConnectionCredentials")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out bool value)) connectionRecord.Inheritance.RDGatewayUseConnectionCredentials = value; } if (headers.Contains("InheritRDGatewayUsername")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsername")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUsername")], out bool value)) connectionRecord.Inheritance.RDGatewayUsername = value; } if (headers.Contains("InheritRDGatewayPassword")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayPassword")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayPassword")], out bool value)) connectionRecord.Inheritance.RDGatewayPassword = value; } if (headers.Contains("InheritRDGatewayDomain")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayDomain")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayDomain")], out bool value)) connectionRecord.Inheritance.RDGatewayDomain = value; } if (headers.Contains("InheritRDPAlertIdleTimeout")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAlertIdleTimeout")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPAlertIdleTimeout")], out bool value)) connectionRecord.Inheritance.RDPAlertIdleTimeout = value; } if (headers.Contains("InheritRDPMinutesToIdleTimeout")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPMinutesToIdleTimeout")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDPMinutesToIdleTimeout")], out bool value)) connectionRecord.Inheritance.RDPMinutesToIdleTimeout = value; } if (headers.Contains("InheritSoundQuality")) { - bool value; - if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSoundQuality")], out value)) + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSoundQuality")], out bool value)) connectionRecord.Inheritance.SoundQuality = value; } + + if (headers.Contains("InheritCredentialRecord")) + { + if (bool.TryParse(connectionCsv[headers.IndexOf("InheritCredentialRecord")], out bool value)) + connectionRecord.Inheritance.CredentialId = value; + } #endregion return connectionRecord; diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsSerializerMremotengFormat.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsSerializerMremotengFormat.cs index bd0a6f296..606012b73 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsSerializerMremotengFormat.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsSerializerMremotengFormat.cs @@ -56,7 +56,7 @@ namespace mRemoteNG.Config.Serializers.Csv sb.Append("Domain;"); sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectClipboard;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;"); if (_saveFilter.SaveInheritance) - sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectClipboard;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality"); + sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectClipboard;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality;InheritCredentialRecord"); } private void SerializeNodesRecursive(ConnectionInfo node, StringBuilder sb) @@ -203,7 +203,8 @@ namespace mRemoteNG.Config.Serializers.Csv .Append(FormatForCsv(con.Inheritance.RDGatewayDomain)) .Append(FormatForCsv(con.Inheritance.RDPAlertIdleTimeout)) .Append(FormatForCsv(con.Inheritance.RDPMinutesToIdleTimeout)) - .Append(FormatForCsv(con.Inheritance.SoundQuality)); + .Append(FormatForCsv(con.Inheritance.SoundQuality)) + .Append(FormatForCsv(con.Inheritance.CredentialId)); } private string FormatForCsv(object value) diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs index 34aa57bba..9b2ba7bee 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionNodeSerializer27.cs @@ -5,6 +5,7 @@ using mRemoteNG.Security; using System; using System.Security; using System.Xml.Linq; +using mRemoteNG.Tools; namespace mRemoteNG.Config.Serializers.Xml { @@ -19,16 +20,9 @@ namespace mRemoteNG.Config.Serializers.Xml public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter) { - if (cryptographyProvider == null) - throw new ArgumentNullException(nameof(cryptographyProvider)); - if (encryptionKey == null) - throw new ArgumentNullException(nameof(encryptionKey)); - if (saveFilter == null) - throw new ArgumentNullException(nameof(saveFilter)); - - _cryptographyProvider = cryptographyProvider; - _encryptionKey = encryptionKey; - _saveFilter = saveFilter; + _cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider)); + _encryptionKey = encryptionKey.ThrowIfNull(nameof(encryptionKey)); + _saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter)); } public XElement Serialize(ConnectionInfo connectionInfo) @@ -153,10 +147,9 @@ namespace mRemoteNG.Config.Serializers.Xml 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("InheritCredentialId", connectionInfo.Inheritance.CredentialId.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())); @@ -173,7 +166,6 @@ namespace mRemoteNG.Config.Serializers.Xml 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())); @@ -212,10 +204,9 @@ namespace mRemoteNG.Config.Serializers.Xml 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("InheritCredentialRecord", 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)); @@ -232,7 +223,6 @@ namespace mRemoteNG.Config.Serializers.Xml 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)); diff --git a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs index 37dcc5b79..a15ea9aa8 100644 --- a/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs +++ b/mRemoteV1/Config/Serializers/ConnectionSerializers/Xml/XmlConnectionsDeserializer.cs @@ -516,6 +516,12 @@ namespace mRemoteNG.Config.Serializers.Xml { connectionInfo.RedirectClipboard = bool.Parse(xmlnode.Attributes["RedirectClipboard"].Value); connectionInfo.Inheritance.RedirectClipboard = bool.Parse(xmlnode.Attributes["InheritRedirectClipboard"].Value); + + connectionInfo.CredentialRecordId = Guid.TryParse(xmlnode.Attributes["CredentialId"]?.Value, out var credId) + ? credId + : Optional.Empty; + + connectionInfo.Inheritance.CredentialId = bool.TryParse(xmlnode.Attributes["InheritCredentialId"]?.Value, out var inheritCreds) && inheritCreds; } } catch (Exception ex) diff --git a/mRemoteV1/Config/Serializers/Versioning/XmlCredentialManagerUpgrader.cs b/mRemoteV1/Config/Serializers/Versioning/XmlCredentialManagerUpgrader.cs index 717e5048d..26959175f 100644 --- a/mRemoteV1/Config/Serializers/Versioning/XmlCredentialManagerUpgrader.cs +++ b/mRemoteV1/Config/Serializers/Versioning/XmlCredentialManagerUpgrader.cs @@ -133,7 +133,7 @@ namespace mRemoteNG.Config.Serializers.Versioning { Guid.TryParse(connectionInfo.ConstantID, out var id); if (map.ContainsKey(id)) - connectionInfo.CredentialRecordId = map[id].Id.Maybe(); + connectionInfo.CredentialRecordId = map[id].Id.ToOptional(); } } } diff --git a/mRemoteV1/Connection/ConnectionInfo.cs b/mRemoteV1/Connection/ConnectionInfo.cs index 46fe5ff87..4f007de7a 100644 --- a/mRemoteV1/Connection/ConnectionInfo.cs +++ b/mRemoteV1/Connection/ConnectionInfo.cs @@ -129,8 +129,13 @@ namespace mRemoteNG.Connection public virtual IEnumerable GetSerializableProperties() { - var excludedProperties = new[] { "Parent", "Name", "Hostname", "Port", "Inheritance", "OpenConnections", - "IsContainer", "IsDefault", "PositionID", "ConstantID", "TreeNode", "IsQuickConnect", "PleaseConnect" }; + var excludedProperties = new[] { + nameof(Parent), nameof(Name), nameof(Hostname), nameof(Port), + nameof(Username), nameof(Domain), nameof(Password), + nameof(Inheritance), nameof(OpenConnections), + nameof(IsContainer), nameof(IsDefault), nameof(ConstantID), + nameof(IsQuickConnect), nameof(PleaseConnect), nameof(CredentialRecord) + }; return GetProperties(excludedProperties); } diff --git a/mRemoteV1/Connection/ConnectionInfoInheritance.cs b/mRemoteV1/Connection/ConnectionInfoInheritance.cs index 63eb937b7..7d7e212cf 100644 --- a/mRemoteV1/Connection/ConnectionInfoInheritance.cs +++ b/mRemoteV1/Connection/ConnectionInfoInheritance.cs @@ -44,7 +44,7 @@ namespace mRemoteNG.Connection LocalizedAttributes.LocalizedDisplayNameInherit(nameof(Language.strCategoryCredentials)), LocalizedAttributes.LocalizedDescriptionInherit(nameof(Language.strPropertyDescriptionCredential)), TypeConverter(typeof(MiscTools.YesNoTypeConverter))] - public bool CredentialRecord { get; set; } + public bool CredentialId { get; set; } [LocalizedAttributes.LocalizedCategory("strCategoryConnection", 3), LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameUsername"), @@ -69,8 +69,6 @@ namespace mRemoteNG.Connection [Browsable(false)] [Obsolete("Use the ConnectionRecord property")] public bool Domain { get; set; } - - #endregion #region Protocol [LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 4), @@ -401,7 +399,11 @@ namespace mRemoteNG.Connection private bool FilterProperty(PropertyInfo propertyInfo) { - var exclusions = new[] { "EverythingInherited", "Parent" }; + var exclusions = new[] + { + nameof(EverythingInherited), nameof(Parent), + nameof(Username), nameof(Domain), nameof(Password) + }; var valueShouldNotBeFiltered = !exclusions.Contains(propertyInfo.Name); return valueShouldNotBeFiltered; } diff --git a/mRemoteV1/Connection/DefaultConnectionInfo.cs b/mRemoteV1/Connection/DefaultConnectionInfo.cs index 9a4df225c..820903935 100644 --- a/mRemoteV1/Connection/DefaultConnectionInfo.cs +++ b/mRemoteV1/Connection/DefaultConnectionInfo.cs @@ -65,7 +65,9 @@ namespace mRemoteNG.Connection throw new SettingsPropertyNotFoundException($"No property with name '{expectedPropertyName}' found."); // ensure value is of correct type - var value = Convert.ChangeType(property.GetValue(Instance, null), propertyFromDestination.PropertyType); + var value = propertyFromDestination.PropertyType == typeof(string) + ? property.GetValue(Instance, null).ToString() + : Convert.ChangeType(property.GetValue(Instance, null), propertyFromDestination.PropertyType); propertyFromDestination.SetValue(destinationInstance, value, null); } diff --git a/mRemoteV1/Schemas/mremoteng_confcons_v2_7.xsd b/mRemoteV1/Schemas/mremoteng_confcons_v2_7.xsd index 602463f71..ad155709a 100644 --- a/mRemoteV1/Schemas/mremoteng_confcons_v2_7.xsd +++ b/mRemoteV1/Schemas/mremoteng_confcons_v2_7.xsd @@ -98,10 +98,9 @@ - + - @@ -118,7 +117,6 @@ - diff --git a/mRemoteV1/Tools/Extensions.cs b/mRemoteV1/Tools/Extensions.cs index ad4eb66b2..d1e1d5a06 100644 --- a/mRemoteV1/Tools/Extensions.cs +++ b/mRemoteV1/Tools/Extensions.cs @@ -7,7 +7,7 @@ namespace mRemoteNG.Tools { public static class Extensions { - public static Optional Maybe(this T value) + public static Optional ToOptional(this T value) { return new Optional(value); } diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index 0e2b97f89..73c62cb8d 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -809,7 +809,6 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); strHide.Add("RDGatewayDomain"); @@ -848,7 +847,6 @@ namespace mRemoteNG.UI.Window strHide.Add("Icon"); strHide.Add("Panel"); strHide.Add("Hostname"); - strHide.Add("Username"); strHide.Add("Protocol"); strHide.Add("Port"); strHide.Add("PuttySession"); @@ -858,7 +856,7 @@ namespace mRemoteNG.UI.Window strHide.Add("UserField"); strHide.Add("Description"); strHide.Add("SoundQuality"); - strHide.Add("CredentialRecord"); + strHide.Add(nameof(AbstractConnectionRecord.CredentialRecord)); } else if (_pGrid.SelectedObject is ConnectionInfo) { @@ -962,7 +960,6 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); strHide.Add("RDGatewayDomain"); @@ -1007,7 +1004,6 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); strHide.Add("RDGatewayDomain"); @@ -1052,10 +1048,8 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); - strHide.Add("Password"); strHide.Add("RDGatewayDomain"); strHide.Add("RDGatewayHostname"); strHide.Add("RDGatewayPassword"); @@ -1078,7 +1072,6 @@ namespace mRemoteNG.UI.Window strHide.Add("AutomaticResize"); strHide.Add("UseConsoleSession"); strHide.Add("UseCredSsp"); - strHide.Add("Username"); strHide.Add("VNCAuthMode"); strHide.Add("VNCColors"); strHide.Add("VNCCompression"); @@ -1091,6 +1084,7 @@ namespace mRemoteNG.UI.Window strHide.Add("VNCSmartSizeMode"); strHide.Add("VNCViewOnly"); strHide.Add("SoundQuality"); + strHide.Add(nameof(AbstractConnectionRecord.CredentialRecord)); break; case ProtocolType.Rlogin: strHide.Add("CacheBitmaps"); @@ -1099,10 +1093,8 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); - strHide.Add("Password"); strHide.Add("RDGatewayDomain"); strHide.Add("RDGatewayHostname"); strHide.Add("RDGatewayPassword"); @@ -1125,7 +1117,6 @@ namespace mRemoteNG.UI.Window strHide.Add("AutomaticResize"); strHide.Add("UseConsoleSession"); strHide.Add("UseCredSsp"); - strHide.Add("Username"); strHide.Add("VNCAuthMode"); strHide.Add("VNCColors"); strHide.Add("VNCCompression"); @@ -1138,6 +1129,7 @@ namespace mRemoteNG.UI.Window strHide.Add("VNCSmartSizeMode"); strHide.Add("VNCViewOnly"); strHide.Add("SoundQuality"); + strHide.Add(nameof(AbstractConnectionRecord.CredentialRecord)); break; case ProtocolType.RAW: strHide.Add("CacheBitmaps"); @@ -1146,10 +1138,8 @@ namespace mRemoteNG.UI.Window strHide.Add("DisplayWallpaper"); strHide.Add("EnableFontSmoothing"); strHide.Add("EnableDesktopComposition"); - strHide.Add("Domain"); strHide.Add("ExtApp"); strHide.Add("ICAEncryptionStrength"); - strHide.Add("Password"); strHide.Add("RDGatewayDomain"); strHide.Add("RDGatewayHostname"); strHide.Add("RDGatewayPassword"); @@ -1172,7 +1162,6 @@ namespace mRemoteNG.UI.Window strHide.Add("AutomaticResize"); strHide.Add("UseConsoleSession"); strHide.Add("UseCredSsp"); - strHide.Add("Username"); strHide.Add("VNCAuthMode"); strHide.Add("VNCColors"); strHide.Add("VNCCompression"); @@ -1185,6 +1174,7 @@ namespace mRemoteNG.UI.Window strHide.Add("VNCSmartSizeMode"); strHide.Add("VNCViewOnly"); strHide.Add("SoundQuality"); + strHide.Add(nameof(AbstractConnectionRecord.CredentialRecord)); break; case ProtocolType.HTTP: case ProtocolType.HTTPS: