From 1c8a89bcdc95c209abed7d5b191a713530bac831 Mon Sep 17 00:00:00 2001 From: Ilya Date: Fri, 19 Apr 2019 08:28:29 +0500 Subject: [PATCH] Run CodeFormatter for Security module (#9399) --- .../security/AclCommands.cs | 1 - .../security/CertificateCommands.cs | 12 +++++------ .../security/CertificateProvider.cs | 20 +++++++++---------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.PowerShell.Security/security/AclCommands.cs b/src/Microsoft.PowerShell.Security/security/AclCommands.cs index 731ff5dd7..5590506f4 100644 --- a/src/Microsoft.PowerShell.Security/security/AclCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/AclCommands.cs @@ -1591,7 +1591,6 @@ namespace Microsoft.PowerShell.Commands } } #endif // !UNIX - } #pragma warning restore 56506 diff --git a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs index 938721a1c..89d1ab996 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateCommands.cs @@ -140,22 +140,22 @@ namespace Microsoft.PowerShell.Commands } else { - if (Password == null && !NoPromptForPassword.IsPresent) + if (Password == null && !NoPromptForPassword.IsPresent) { - try + try { cert = GetCertFromPfxFile(resolvedProviderPath, null); WriteObject(cert); continue; - } - catch (CryptographicException) + } + catch (CryptographicException) { Password = SecurityUtils.PromptForSecureString( Host.UI, CertificateCommands.GetPfxCertPasswordPrompt); - } + } } - + try { cert = GetCertFromPfxFile(resolvedProviderPath, Password); diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs index 4a4bce37c..6165f8b86 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs @@ -3155,7 +3155,7 @@ namespace Microsoft.PowerShell.Commands if (extension.Oid.Value == "2.5.29.37") { X509EnhancedKeyUsageExtension ext = extension as X509EnhancedKeyUsageExtension; - if(ext != null) + if (ext != null) { OidCollection oids = ext.EnhancedKeyUsages; foreach (Oid oid in oids) @@ -3204,21 +3204,21 @@ namespace Microsoft.PowerShell.Commands // extract DNS name from subject distinguish name // if it exists and does not contain a comma // a comma, indicates it is not a DNS name - if(cert.Subject.StartsWith(distinguishedNamePrefix, System.StringComparison.InvariantCultureIgnoreCase) && - cert.Subject.IndexOf(",",System.StringComparison.InvariantCulture) == -1) + if (cert.Subject.StartsWith(distinguishedNamePrefix, System.StringComparison.InvariantCultureIgnoreCase) && + cert.Subject.IndexOf(",", System.StringComparison.InvariantCulture) == -1) { name = cert.Subject.Substring(distinguishedNamePrefix.Length); try { unicodeName = idnMapping.GetUnicode(name); } - catch(System.ArgumentException) + catch (System.ArgumentException) { // The name is not valid punyCode, assume it's valid ascii. unicodeName = name; } - dnsName = new DnsNameRepresentation(name,unicodeName); + dnsName = new DnsNameRepresentation(name, unicodeName); _dnsList.Add(dnsName); } @@ -3228,26 +3228,26 @@ namespace Microsoft.PowerShell.Commands if (extension.Oid.Value == "2.5.29.17") { string[] names = extension.Format(true).Split(Environment.NewLine); - foreach(string nameLine in names) + foreach (string nameLine in names) { // Get the part after 'DNS Name=' - if(nameLine.StartsWith(dnsNamePrefix, System.StringComparison.InvariantCultureIgnoreCase)) + if (nameLine.StartsWith(dnsNamePrefix, System.StringComparison.InvariantCultureIgnoreCase)) { name = nameLine.Substring(dnsNamePrefix.Length); try { unicodeName = idnMapping.GetUnicode(name); } - catch(System.ArgumentException) + catch (System.ArgumentException) { // The name is not valid punyCode, assume it's valid ascii. unicodeName = name; } - dnsName = new DnsNameRepresentation(name,unicodeName); + dnsName = new DnsNameRepresentation(name, unicodeName); // Only add the name if it is not the same as an existing name. - if(!_dnsList.Contains(dnsName)) + if (!_dnsList.Contains(dnsName)) { _dnsList.Add(dnsName); }