From 7fb0c2dc7a64b90a74adf07109f18fd847d3d76f Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Mon, 5 Aug 2024 19:40:13 -0700 Subject: [PATCH 1/4] Enable EnforceCodeStyleInBuild and fix findings Have to enable GenerateDocumentationFile for test csproj to work around https://github.com/dotnet/roslyn/issues/41640 --- .editorconfig | 12 +++ .../AsymmetricAdapterSignatures.cs | 14 ++-- .../BenchmarkConfig.cs | 2 +- build/common.props | 1 + build/commonTest.props | 2 + .../Json/JsonClaimSet.cs | 8 +- .../Json/JsonWebToken.HeaderClaimSet.cs | 2 +- .../JsonWebToken.cs | 8 +- .../JsonWebTokenHandler.CreateToken.cs | 2 +- .../JsonWebTokenHandler.DecryptToken.cs | 6 +- .../JsonWebTokenHandler.ValidateToken.cs | 2 +- .../JwtHeaderParameterNames.cs | 31 ++++---- .../IdentityModelEventSource.cs | 4 +- .../LogHelper.cs | 14 ++-- .../OpenIdConnectConfigurationValidator.cs | 2 - .../OpenIdConnectProtocolException.cs | 18 ++--- .../OpenIdConnectMessage.cs | 10 +-- .../OpenIdConnectProtocolValidationContext.cs | 3 +- .../Cnf.cs | 6 +- .../SignedHttpRequestDescriptor.cs | 4 +- .../SignedHttpRequestHandler.cs | 15 ++-- .../SignedHttpRequestUtilities.cs | 2 +- .../SignedHttpRequestValidationContext.cs | 6 +- .../Exceptions/WsFederationReadException.cs | 2 +- .../WsAddressingConstants.cs | 4 +- .../WsFederationConstants.cs | 8 +- .../WsFederationMessage.cs | 14 ++-- .../WsFederationMetadataSerializer.cs | 8 +- .../WsPolicyConstants.cs | 6 +- .../WsTrustConstants.cs | 6 +- .../WsTrustConstants_1_3.cs | 6 +- .../WsTrustConstants_1_4.cs | 4 +- .../WsTrustConstants_2005.cs | 6 +- .../WsUtilityConstants.cs | 6 +- .../AuthenticationProtocolMessage.cs | 18 ++--- .../Configuration/ConfigurationManager.cs | 3 +- .../StaticConfigurationManager.cs | 3 +- ...rosoft.IdentityModel.TestExtensions.csproj | 1 + .../TestTokenCreator.cs | 23 +++--- .../Exceptions/SamlSecurityTokenException.cs | 8 +- .../SamlSecurityTokenReadException.cs | 8 +- .../SamlSecurityTokenWriteException.cs | 8 +- .../Saml/SamlAssertion.cs | 1 - .../Saml/SamlAttributeKeyComparer.cs | 1 - .../SamlAuthorizationDecisionStatement.cs | 1 - .../Saml/SamlSecurityTokenHandler.cs | 16 ++-- .../Saml/SamlSerializer.cs | 2 +- .../Exceptions/Saml2SecurityTokenException.cs | 8 +- .../Saml2SecurityTokenReadException.cs | 8 +- .../Saml2SecurityTokenWriteException.cs | 8 +- .../Saml2/Saml2Assertion.cs | 1 - .../Saml2/Saml2AttributeKeyComparer.cs | 1 - .../Saml2AuthorizationDecisionStatement.cs | 1 - .../Saml2/Saml2Constants.cs | 6 +- .../Saml2/Saml2SecurityTokenHandler.cs | 9 +-- .../Saml2/Saml2Serializer.cs | 14 ++-- .../Saml2/Saml2SubjectConfirmationData.cs | 2 +- .../AsymmetricAdapter.cs | 4 +- .../Base64UrlEncoder.cs | 9 ++- .../BaseConfigurationComparer.cs | 2 +- .../CryptoProviderFactory.cs | 50 ++++++------ .../ECDsaAdapter.cs | 14 +++- .../EncodingUtils.cs | 2 +- .../AuthenticatedEncryptionProvider.cs | 8 +- .../Encryption/EcdhKeyExchangeProvider.cs | 2 + .../Encryption/SymmetricKeyWrapProvider.cs | 2 +- .../EventBasedLRUCache.cs | 8 +- .../Exceptions/SecurityTokenException.cs | 11 ++- .../SecurityTokenInvalidTypeException.cs | 2 +- .../ICryptoProvider.cs | 2 - .../InMemoryCryptoProviderCache.cs | 4 +- .../Json/JsonSerializerPrimitives.cs | 38 +++++----- .../Json/JsonWebKeySerializer.cs | 2 +- .../Json/JsonWebKeySetSerializer.cs | 2 +- .../JsonWebKey.cs | 4 +- .../JsonWebKeyConverter.cs | 2 +- .../RsaCryptoServiceProviderProxy.cs | 2 +- .../RsaSecurityKey.cs | 2 +- .../SecurityKeyIdentifierClause.cs | 3 - .../SecurityTokenHandler.cs | 1 - .../SymmetricSignatureProvider.cs | 7 +- .../TokenContext.cs | 4 +- .../TokenUtilities.cs | 2 +- .../Validation/MessageDetail.cs | 1 - .../Validation/ValidationParameters.cs | 4 +- .../Validation/Validators.Algorithm.cs | 1 - .../Validation/Validators.Lifetime.cs | 2 +- .../Validators.cs | 18 ++--- .../X509SigningCredentials.cs | 2 +- .../opensource/AesGcm/AesGcm.cs | 4 +- .../opensource/AesGcm/Cng.cs | 4 +- .../opensource/AesGcm/Interop.cs | 4 +- .../AadIssuerValidator/AadIssuerValidator.cs | 9 +-- .../AadIssuerValidator/IssuerLastKnownGood.cs | 5 -- .../AadTokenValidationParametersExtension.cs | 5 +- .../CanonicalizingTransform.cs | 1 - .../DsigElement.cs | 7 -- .../EnvelopedSignatureReader.cs | 2 +- .../Exceptions/XmlReadException.cs | 8 +- .../Exceptions/XmlWriteException.cs | 8 +- .../ExclusiveCanonicalizationTransform.cs | 2 - src/Microsoft.IdentityModel.Xml/KeyInfo.cs | 2 +- src/Microsoft.IdentityModel.Xml/Reference.cs | 7 +- src/Microsoft.IdentityModel.Xml/SignedInfo.cs | 3 +- .../XmlTokenStreamReader.cs | 76 +++++++++---------- .../JwtHeader.cs | 4 +- .../JwtPayload.cs | 2 +- .../JwtSecurityToken.cs | 9 ++- .../JwtSecurityTokenHandler.cs | 4 +- .../LogMessages.cs | 2 +- .../TelemetryEventDetailsTests.cs | 2 +- .../JsonClaimSetTests.cs | 6 +- .../JsonWebTokenHandler.DecryptTokenTests.cs | 2 +- .../JwtTokenUtilitiesTests.cs | 2 +- .../IdentityModelTelemetryUtilTests.cs | 4 +- .../LogHelperTests.cs | 6 +- .../LoggerTests.cs | 6 +- .../PIITests.cs | 2 +- .../ConfigurationManagerTests.cs | 4 +- .../OpenIdConfigData.cs | 7 +- ...penIdConnectConfigurationRetrieverTests.cs | 6 +- .../OpenIdConnectConfigurationTests.cs | 6 +- .../OpenIdConnectMessageTests.cs | 2 +- ...IdConnectProtocolValidationContextTests.cs | 4 +- .../PopKeyResolvingTests.cs | 2 +- .../SignedHttpRequestCreationTests.cs | 2 +- .../SignedHttpRequestHandlerPublic.cs | 10 +-- .../SignedHttpRequestTestUtils.cs | 6 +- .../SignedHttpRequestUtilityTests.cs | 6 +- ...SignedHttpRequestValidationContextTests.cs | 2 +- .../SignedHttpRequestValidationTests.cs | 4 +- .../AuthenticationProtocolMessageTests.cs | 2 +- ...WsFederationConfigurationRetrieverTests.cs | 4 +- ...WsFederationConfigurationValidatorTests.cs | 2 +- .../WsFederationMessageTests.cs | 2 +- .../WsFederationTestUtilities.cs | 6 +- .../SampleTokenValidationClass.cs | 2 +- .../ClaimSets.cs | 39 +++++----- .../CompareContext.cs | 2 +- .../DerivedTypes.cs | 4 +- .../ExpectedException.cs | 26 +++---- .../HttpResponseMessageUtils.cs | 1 + .../IdentityComparer.cs | 6 +- .../IdentityUtilities.cs | 4 +- .../MockConfigurationManager.cs | 2 +- .../MockHttpMessageHandler.cs | 6 +- .../NotDefault.cs | 4 +- .../ReferenceMetadata.cs | 12 +-- .../ReferenceSaml.cs | 2 +- .../References.cs | 2 +- .../TestSets.cs | 72 +++++++++--------- .../TestStub.cs | 2 +- .../TestUtilities.cs | 12 +-- .../ValidationDelegates.cs | 4 +- .../XmlGenerator.cs | 2 +- .../XmlUtilities.cs | 2 +- .../Saml2SerializerTests.cs | 4 +- .../Saml2TheoryData.cs | 2 +- .../AbstractVirtualsTests.cs | 4 +- .../AsymmetricSignatureTests.cs | 2 +- .../AuthenticatedEncryptionProviderTests.cs | 12 +-- .../CryptoExtensibilityTests.cs | 2 +- .../CryptoProviderCacheTests.cs | 7 +- .../CryptoProviderFactoryTests.cs | 9 ++- .../CustomCryptoProviders.cs | 15 ++-- .../CustomSecurityKeys.cs | 9 +-- .../EventBasedLRUCacheTests.cs | 8 +- .../IdentityComparerTests.cs | 18 ++--- .../Json/DataSets.cs | 6 +- .../Json/JsonData.cs | 2 +- .../Json/JsonSerializerPrimitivesTests.cs | 22 +++--- .../Json/JsonSerializerTheoryData.cs | 2 +- .../Json/JsonUtilities.cs | 2 +- .../JsonWebKeyConverterTest.cs | 8 +- .../JsonWebKeyTests.cs | 2 +- .../JweUsingEchdTests.cs | 2 +- .../KeyVaultVerify.cs | 2 +- .../ReferenceTests.cs | 2 +- .../SecurityTokenExceptionTests.cs | 2 +- .../SignatureProviderTests.cs | 14 ++-- .../SupportedAlgorithmTests.cs | 6 +- .../TokenValidationParametersTests.cs | 2 +- .../SigningKeyValidationResultTests.cs | 18 ++--- .../TokenTypeValidationResultTests.cs | 2 +- .../Validation/ValidatorsTests.cs | 8 +- .../MicrosoftIdentityIssuerValidatorTest.cs | 8 +- .../DSigSerializerTests.cs | 8 +- .../EnvelopedSignatureReaderTests.cs | 8 +- .../EnvelopedSignatureWriterTests.cs | 14 ++-- .../SignatureTests.cs | 6 +- .../CreateAndValidateTokens.cs | 16 ++-- .../JwtHeaderTests.cs | 4 +- .../JwtSecurityTokenConverterTests.cs | 2 +- .../JwtSecurityTokenHandlerTests.cs | 6 +- .../JwtSecurityTokenTests.cs | 4 +- .../JwtTestData.cs | 2 +- .../JwtTestUtilities.cs | 18 ++--- .../References.cs | 64 ++++++++-------- 198 files changed, 712 insertions(+), 735 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7202291eb6..29be06e2e2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -169,6 +169,18 @@ dotnet_diagnostic.CA1303.severity = none dotnet_diagnostic.IDE0073.severity = warning file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License. +# IDE0005: Remove unnecessary usings +dotnet_diagnostic.IDE0005.severity = warning + +# IDE0055: All formatting rules +dotnet_diagnostic.IDE0055.severity = warning + +# CA1845: Use span-based 'string.Concat' +dotnet_diagnostic.CA1845.severity = warning + +# CA1846: Prefer AsSpan over Substring +dotnet_diagnostic.CA1846.severity = warning + # C++ Files [*.{cpp,h,in}] curly_bracket_next_line = true diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/AsymmetricAdapterSignatures.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/AsymmetricAdapterSignatures.cs index d9c3886a03..77cabdedfe 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/AsymmetricAdapterSignatures.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/AsymmetricAdapterSignatures.cs @@ -24,7 +24,7 @@ public class AsymmetricAdapterSignatures [GlobalSetup] public void Setup() { - SecurityTokenDescriptor securityTokenDescriptor = new () + SecurityTokenDescriptor securityTokenDescriptor = new() { SigningCredentials = BenchmarkUtils.SigningCredentialsRsaSha256, Claims = BenchmarkUtils.Claims, @@ -32,12 +32,12 @@ public void Setup() }; _bytesToSign = Encoding.UTF8.GetBytes((new JsonWebTokenHandler()).CreateToken(securityTokenDescriptor)); - _rsaAsymmetricAdapter = new AsymmetricAdapter( - BenchmarkUtils.SigningCredentialsRsaSha256.Key, - SecurityAlgorithms.RsaSha256, - SHA256.Create(), - SupportedAlgorithms.GetHashAlgorithmName(SecurityAlgorithms.RsaSha256), - true ); + _rsaAsymmetricAdapter = new AsymmetricAdapter( + BenchmarkUtils.SigningCredentialsRsaSha256.Key, + SecurityAlgorithms.RsaSha256, + SHA256.Create(), + SupportedAlgorithms.GetHashAlgorithmName(SecurityAlgorithms.RsaSha256), + true); _signatureBuffer = new byte[256]; } diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs index 8e70089ee2..628d6c1225 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs @@ -23,7 +23,7 @@ public BenchmarkConfig() .WithOrderer(new DefaultOrderer(SummaryOrderPolicy.Method)) .HideColumns(Column.WarmupCount, Column.Type, Column.Job) .AddDiagnoser(MemoryDiagnoser.Default); // https://benchmarkdotnet.org/articles/configs/diagnosers.html - //.AddDiagnoser(new EtwProfiler()) // Uncomment to generate traces / flame graphs. Doc: https://adamsitnik.com/ETW-Profiler/ + //.AddDiagnoser(new EtwProfiler()) // Uncomment to generate traces / flame graphs. Doc: https://adamsitnik.com/ETW-Profiler/ } } } diff --git a/build/common.props b/build/common.props index e03f9d5077..8d402d23a1 100644 --- a/build/common.props +++ b/build/common.props @@ -28,6 +28,7 @@ $(SrcStandardTargets) $(NetStandardVersion) 12 + true diff --git a/build/commonTest.props b/build/commonTest.props index ff56d0f461..914262d600 100644 --- a/build/commonTest.props +++ b/build/commonTest.props @@ -18,6 +18,7 @@ $(DotNetCoreAppRuntimeVersion) false 12 + true @@ -27,6 +28,7 @@ $(NoWarn);SYSLIB0050 $(NoWarn);SYSLIB0051 + $(NoWarn);CS1591 diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonClaimSet.cs b/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonClaimSet.cs index 892b8a68fc..7bcfb4d4ce 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonClaimSet.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonClaimSet.cs @@ -74,7 +74,7 @@ internal static void CreateClaimFromObject(List claims, string claimType, else if (value is double d) claims.Add(new Claim(claimType, d.ToString(CultureInfo.InvariantCulture), ClaimValueTypes.Double, issuer, issuer)); else if (value is DateTime dt) - claims.Add(new Claim(claimType, dt.ToString("o",CultureInfo.InvariantCulture), ClaimValueTypes.DateTime, issuer, issuer)); + claims.Add(new Claim(claimType, dt.ToString("o", CultureInfo.InvariantCulture), ClaimValueTypes.DateTime, issuer, issuer)); else if (value is float f) claims.Add(new Claim(claimType, f.ToString(CultureInfo.InvariantCulture), ClaimValueTypes.Double, issuer, issuer)); else if (value is decimal m) @@ -320,7 +320,7 @@ internal T GetValue(string key, bool throwEx, out bool found) else if (typeof(T) == typeof(Collection)) return (T)(object)new Collection { obj }; - else if(typeof(T).IsEnum) + else if (typeof(T).IsEnum) { return (T)Enum.Parse(typeof(T), obj.ToString(), ignoreCase: true); } @@ -342,7 +342,7 @@ internal T GetValue(string key, bool throwEx, out bool found) if (objType == typeof(long)) return (T)(object)new long[] { (long)obj }; - if(objType == typeof(int)) + if (objType == typeof(int)) return (T)(object)new long[] { (int)obj }; if (long.TryParse(obj.ToString(), out long value)) @@ -350,7 +350,7 @@ internal T GetValue(string key, bool throwEx, out bool found) } else if (typeof(T) == typeof(double)) { - if(double.TryParse(obj.ToString(), out double value)) + if (double.TryParse(obj.ToString(), out double value)) return (T)(object)value; } else if (typeof(T) == typeof(uint)) diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonWebToken.HeaderClaimSet.cs b/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonWebToken.HeaderClaimSet.cs index 1c8bcc20aa..4694399aa7 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonWebToken.HeaderClaimSet.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/Json/JsonWebToken.HeaderClaimSet.cs @@ -22,7 +22,7 @@ internal JsonClaimSet CreateHeaderClaimSet(byte[] bytes, int length) } internal JsonClaimSet CreateHeaderClaimSet(ReadOnlySpan byteSpan) - { + { Utf8JsonReader reader = new(byteSpan); if (!JsonSerializerPrimitives.IsReaderAtTokenType(ref reader, JsonTokenType.StartObject, true)) throw LogHelper.LogExceptionMessage( diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs index d7c71cb057..48af759d86 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs @@ -225,7 +225,7 @@ public string EncodedHeader if (!_encodedTokenMemory.IsEmpty) _encodedHeader = _encodedTokenMemory.Span.Slice(0, Dot1).ToString(); else - _encodedHeader = (_encodedToken is not null) ? _encodedToken.Substring(0, Dot1) : string.Empty; + _encodedHeader = (_encodedToken is not null) ? _encodedToken.Substring(0, Dot1) : string.Empty; } return _encodedHeader; @@ -324,10 +324,10 @@ public string EncodedToken { get { - if (_encodedToken is null && !_encodedTokenMemory.IsEmpty) + if (_encodedToken is null && !_encodedTokenMemory.IsEmpty) _encodedToken = _encodedTokenMemory.ToString(); - return _encodedToken; + return _encodedToken; } } @@ -395,7 +395,7 @@ public string InitializationVector /// public override SecurityKey SigningKey { get; set; } - internal byte[] MessageBytes{ get; set; } + internal byte[] MessageBytes { get; set; } internal int NumberOfDots { get; set; } diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs index 86c2b2cf36..7c7d63907e 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs @@ -568,7 +568,7 @@ internal static string CreateToken IDictionary additionalInnerHeaderClaims, string tokenType) { - using (MemoryStream utf8ByteMemoryStream = new ()) + using (MemoryStream utf8ByteMemoryStream = new()) { Utf8JsonWriter writer = null; char[] encodedChars = null; diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs index f7e7922bc2..f51e78edab 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs @@ -137,7 +137,7 @@ internal TokenDecryptionResult DecryptToken( else keys = configurationKeys; } - + } if (jwtToken.Alg.Equals(JwtConstants.DirectKeyUseAlg, StringComparison.Ordinal) @@ -205,7 +205,7 @@ internal TokenDecryptionResult DecryptToken( typeof(SecurityTokenKeyWrapException), new System.Diagnostics.StackFrame()); return (null, exceptionDetail); - } + } } /// @@ -234,7 +234,7 @@ internal TokenDecryptionResult DecryptToken( if (!string.IsNullOrEmpty(jwtToken.X5t) && validationParameters.TokenDecryptionKeys != null) { - for(int i = 0; i < validationParameters.TokenDecryptionKeys.Count; i++) + for (int i = 0; i < validationParameters.TokenDecryptionKeys.Count; i++) { var key = validationParameters.TokenDecryptionKeys[i]; diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.ValidateToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.ValidateToken.cs index c87372ae75..61b35f0544 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.ValidateToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.ValidateToken.cs @@ -485,7 +485,7 @@ internal async ValueTask ValidateTokenAsync( } } - TokenValidationResult tokenValidationResult = jsonWebToken.IsEncrypted ? + TokenValidationResult tokenValidationResult = jsonWebToken.IsEncrypted ? await ValidateJWEAsync(jsonWebToken, validationParameters, currentConfiguration).ConfigureAwait(false) : await ValidateJWSAsync(jsonWebToken, validationParameters, currentConfiguration).ConfigureAwait(false); diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JwtHeaderParameterNames.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JwtHeaderParameterNames.cs index fd9acf920b..6dd88d323b 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JwtHeaderParameterNames.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JwtHeaderParameterNames.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Text; namespace Microsoft.IdentityModel.JsonWebTokens { @@ -97,20 +96,20 @@ internal readonly struct JwtHeaderUtf8Bytes { // Please keep this alphabetical order - public static ReadOnlySpan Alg =>"alg"u8; - public static ReadOnlySpan Apu =>"apu"u8; - public static ReadOnlySpan Apv =>"apv"u8; - public static ReadOnlySpan Cty =>"cty"u8; - public static ReadOnlySpan Enc =>"enc"u8; - public static ReadOnlySpan Epk =>"epk"u8; - public static ReadOnlySpan IV =>"iv"u8; - public static ReadOnlySpan Jku =>"jku"u8; - public static ReadOnlySpan Jwk =>"jwk"u8; - public static ReadOnlySpan Kid =>"kid"u8; - public static ReadOnlySpan Typ =>"typ"u8; - public static ReadOnlySpan X5c =>"x5c"u8; - public static ReadOnlySpan X5t =>"x5t"u8; - public static ReadOnlySpan X5u =>"x5u"u8; - public static ReadOnlySpan Zip =>"zip"u8; + public static ReadOnlySpan Alg => "alg"u8; + public static ReadOnlySpan Apu => "apu"u8; + public static ReadOnlySpan Apv => "apv"u8; + public static ReadOnlySpan Cty => "cty"u8; + public static ReadOnlySpan Enc => "enc"u8; + public static ReadOnlySpan Epk => "epk"u8; + public static ReadOnlySpan IV => "iv"u8; + public static ReadOnlySpan Jku => "jku"u8; + public static ReadOnlySpan Jwk => "jwk"u8; + public static ReadOnlySpan Kid => "kid"u8; + public static ReadOnlySpan Typ => "typ"u8; + public static ReadOnlySpan X5c => "x5c"u8; + public static ReadOnlySpan X5t => "x5t"u8; + public static ReadOnlySpan X5u => "x5u"u8; + public static ReadOnlySpan Zip => "zip"u8; } } diff --git a/src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs b/src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs index 1a1ef48b79..a270c948fc 100644 --- a/src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs +++ b/src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs @@ -298,7 +298,7 @@ public void Write(EventLevel level, Exception innerException, string message, pa // Obtain the current library version dynamically. WriteAlways(string.Format(CultureInfo.InvariantCulture, _versionLogMessage, typeof(IdentityModelEventSource).GetTypeInfo().Assembly.GetName().Version.ToString())); WriteAlways(string.Format(CultureInfo.InvariantCulture, _dateLogMessage, DateTime.UtcNow)); - if (ShowPII) + if (ShowPII) WriteAlways(_piiOnLogMessage); else WriteAlways(_piiOffLogMessage); @@ -340,7 +340,7 @@ public EventLevel LogLevel { get; set; } - + private static string PrepareMessage(EventLevel level, string message, params object[] args) { if (message == null) diff --git a/src/Microsoft.IdentityModel.Logging/LogHelper.cs b/src/Microsoft.IdentityModel.Logging/LogHelper.cs index 9aea99c6dd..b99ef5cad6 100644 --- a/src/Microsoft.IdentityModel.Logging/LogHelper.cs +++ b/src/Microsoft.IdentityModel.Logging/LogHelper.cs @@ -296,7 +296,7 @@ public static void LogInformation(string message, params object[] args) public static void LogVerbose(string message, params object[] args) { if (IdentityModelEventSource.Logger.IsEnabled(EventLevel.Verbose, EventKeywords.All)) - IdentityModelEventSource.Logger.WriteVerbose(message, args); + IdentityModelEventSource.Logger.WriteVerbose(message, args); if (Logger.IsEnabled(EventLogLevel.Verbose)) Logger.Log(WriteEntry(EventLogLevel.Verbose, null, message, args)); @@ -310,7 +310,7 @@ public static void LogVerbose(string message, params object[] args) public static void LogWarning(string message, params object[] args) { if (IdentityModelEventSource.Logger.IsEnabled(EventLevel.Warning, EventKeywords.All)) - IdentityModelEventSource.Logger.WriteWarning(message, args); + IdentityModelEventSource.Logger.WriteWarning(message, args); if (Logger.IsEnabled(EventLogLevel.Warning)) Logger.Log(WriteEntry(EventLogLevel.Warning, null, message, args)); @@ -324,7 +324,7 @@ public static void LogWarning(string message, params object[] args) /// the inner to be added to the outer exception. /// Format string of the log message. /// An object array that contains zero or more objects to format. - private static T LogExceptionImpl<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(EventLevel eventLevel, string argumentName, Exception innerException, string format, params object[] args) where T : Exception + private static T LogExceptionImpl<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(EventLevel eventLevel, string argumentName, Exception innerException, string format, params object[] args) where T : Exception { string message; if (args != null) @@ -339,16 +339,16 @@ public static void LogWarning(string message, params object[] args) if (Logger.IsEnabled(eventLogLevel)) Logger.Log(WriteEntry(eventLogLevel, innerException, message, null)); - if (innerException != null) + if (innerException != null) if (string.IsNullOrEmpty(argumentName)) return (T)Activator.CreateInstance(typeof(T), message, innerException); else return (T)Activator.CreateInstance(typeof(T), argumentName, message, innerException); else if (string.IsNullOrEmpty(argumentName)) - return (T)Activator.CreateInstance(typeof(T), message); - else - return (T)Activator.CreateInstance(typeof(T), argumentName, message); + return (T)Activator.CreateInstance(typeof(T), message); + else + return (T)Activator.CreateInstance(typeof(T), argumentName, message); } private static EventLogLevel EventLevelToEventLogLevel(EventLevel eventLevel) => diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Configuration/OpenIdConnectConfigurationValidator.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Configuration/OpenIdConnectConfigurationValidator.cs index de72a9a519..b5ab88c555 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Configuration/OpenIdConnectConfigurationValidator.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Configuration/OpenIdConnectConfigurationValidator.cs @@ -3,9 +3,7 @@ using System; using System.Linq; -using System.Web; using Microsoft.IdentityModel.Logging; -using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.Protocols.OpenIdConnect.Configuration { diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Exceptions/OpenIdConnectProtocolException.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Exceptions/OpenIdConnectProtocolException.cs index 91585f9573..a79578e08f 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Exceptions/OpenIdConnectProtocolException.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Exceptions/OpenIdConnectProtocolException.cs @@ -38,14 +38,14 @@ public OpenIdConnectProtocolException(String message, Exception innerException) { } - /// - /// Initializes a new instance of the class. - /// - /// the that holds the serialized object data. - /// The contextual information about the source or destination. - protected OpenIdConnectProtocolException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } + /// + /// Initializes a new instance of the class. + /// + /// the that holds the serialized object data. + /// The contextual information about the source or destination. + protected OpenIdConnectProtocolException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectMessage.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectMessage.cs index f756f445c8..3a5d89cf47 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectMessage.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectMessage.cs @@ -122,7 +122,7 @@ private void SetJsonParameters(string json) LogHelper.MarkAsNonPII(reader.CurrentDepth), LogHelper.MarkAsNonPII(reader.BytesConsumed)))); - while(true) + while (true) { // propertyValue is set to match 6.x if (reader.TokenType == JsonTokenType.PropertyName) @@ -219,7 +219,7 @@ public string AccessToken /// /// Gets or sets 'acr_values'. /// - public string AcrValues + public string AcrValues { get { return GetParameter(OpenIdConnectParameterNames.AcrValues); } set { SetParameter(OpenIdConnectParameterNames.AcrValues, value); } @@ -393,7 +393,7 @@ public string Iss /// /// Gets or sets 'login_hint'. /// - [property: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707")] + [property: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707")] public string LoginHint { get { return GetParameter(OpenIdConnectParameterNames.LoginHint); } @@ -508,7 +508,7 @@ public string Resource get { return GetParameter(OpenIdConnectParameterNames.Resource); } set { SetParameter(OpenIdConnectParameterNames.Resource, value); } } - + /// /// Gets or sets 'scope'. /// @@ -590,7 +590,7 @@ public string UserId get { return GetParameter(OpenIdConnectParameterNames.UserId); } set { SetParameter(OpenIdConnectParameterNames.UserId, value); } } - + /// /// Gets or sets 'username'. /// diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidationContext.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidationContext.cs index ccf1a80b39..f7cb9a6dcc 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidationContext.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidationContext.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.IdentityModel.Tokens.Jwt; namespace Microsoft.IdentityModel.Protocols.OpenIdConnect @@ -15,7 +14,7 @@ public class OpenIdConnectProtocolValidationContext /// /// Creates an instance of /// - public OpenIdConnectProtocolValidationContext() {} + public OpenIdConnectProtocolValidationContext() { } /// /// Gets or sets the 'client_id'. diff --git a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/Cnf.cs b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/Cnf.cs index 34869e9389..8f97096271 100644 --- a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/Cnf.cs +++ b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/Cnf.cs @@ -69,7 +69,7 @@ public Cnf(string json) else if (JsonSerializerPrimitives.IsReaderAtTokenType(ref reader, JsonTokenType.EndObject, true)) break; else if (!reader.Read()) - break; + break; } } @@ -83,6 +83,6 @@ public Cnf(string json) public string Jku { get; set; } [JsonPropertyName("jwk")] - public JsonWebKey JsonWebKey{ get; set; } - } + public JsonWebKey JsonWebKey { get; set; } + } } diff --git a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestDescriptor.cs b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestDescriptor.cs index bec080e981..516427bb29 100644 --- a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestDescriptor.cs +++ b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestDescriptor.cs @@ -23,7 +23,7 @@ public class SignedHttpRequestDescriptor /// An access token that contains the 'cnf' claim. /// A structure that represents an outgoing http request. /// A security key and algorithm that will be used to sign the (Signed)HttpRequest. - public SignedHttpRequestDescriptor(string accessToken, HttpRequestData httpRequestData, SigningCredentials signingCredentials) + public SignedHttpRequestDescriptor(string accessToken, HttpRequestData httpRequestData, SigningCredentials signingCredentials) : this(accessToken, httpRequestData, signingCredentials, new SignedHttpRequestCreationParameters()) { } @@ -39,7 +39,7 @@ public SignedHttpRequestDescriptor(string accessToken, HttpRequestData httpReque /// A structure that represents an outgoing http request. /// A security key and algorithm that will be used to sign the (Signed)HttpRequest. /// A set of parameters required for creating a SignedHttpRequest. - public SignedHttpRequestDescriptor(string accessToken, HttpRequestData httpRequestData, SigningCredentials signingCredentials, SignedHttpRequestCreationParameters signedHttpRequestCreationParameters) + public SignedHttpRequestDescriptor(string accessToken, HttpRequestData httpRequestData, SigningCredentials signingCredentials, SignedHttpRequestCreationParameters signedHttpRequestCreationParameters) { AccessToken = !string.IsNullOrEmpty(accessToken) ? accessToken : throw LogHelper.LogArgumentNullException(nameof(accessToken)); HttpRequestData = httpRequestData ?? throw LogHelper.LogArgumentNullException(nameof(httpRequestData)); diff --git a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestHandler.cs b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestHandler.cs index f167f27c3a..1411d14732 100644 --- a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestHandler.cs +++ b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestHandler.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Net.Http; -using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Text.Encodings.Web; @@ -135,7 +134,7 @@ public string CreateSignedHttpRequest(SignedHttpRequestDescriptor signedHttpRequ headerWriter?.Dispose(); } - string message = encodedHeader + "." + encodedPayload; + string message = encodedHeader + "." + encodedPayload; return message + "." + JwtTokenUtilities.CreateEncodedSignature(message, signedHttpRequestDescriptor.SigningCredentials, false); } } @@ -315,7 +314,7 @@ internal virtual void AddQClaim(ref Utf8JsonWriter writer, SignedHttpRequestDesc throw LogHelper.LogArgumentNullException(nameof(signedHttpRequestDescriptor.HttpRequestData.Uri)); Uri httpRequestUri = EnsureAbsoluteUri(signedHttpRequestDescriptor.HttpRequestData.Uri); - IDictionary sanitizedQueryParams = SanitizeQueryParams(httpRequestUri); + IDictionary sanitizedQueryParams = SanitizeQueryParams(httpRequestUri); StringBuilder stringBuffer = new StringBuilder(); try @@ -355,7 +354,7 @@ internal virtual void AddQClaim(ref Utf8JsonWriter writer, SignedHttpRequestDesc /// internal void AddHClaim(ref Utf8JsonWriter writer, SignedHttpRequestDescriptor signedHttpRequestDescriptor) { - IDictionary sanitizedHeaders = SanitizeHeaders(signedHttpRequestDescriptor.HttpRequestData.Headers); + IDictionary sanitizedHeaders = SanitizeHeaders(signedHttpRequestDescriptor.HttpRequestData.Headers); StringBuilder stringBuffer = new StringBuilder(); try { @@ -473,7 +472,7 @@ internal virtual void AddCnfClaim(ref Utf8JsonWriter writer, SignedHttpRequestDe throw LogHelper.LogExceptionMessage(new SignedHttpRequestCreationException(LogHelper.FormatInvariant(LogMessages.IDX23008, LogHelper.MarkAsNonPII(ConfirmationClaimTypes.Cnf), e), e)); } } -#endregion + #endregion #region SignedHttpRequest validation /// @@ -659,7 +658,7 @@ internal virtual async Task ValidateSignatureAsync(JsonWebToken sig if (signatureProvider == null) throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(Tokens.LogMessages.IDX10636, popKey.ToString(), LogHelper.MarkAsNonPII(signedHttpRequest.Alg)))); - if(EncodingUtils.PerformEncodingDependentOperation( + if (EncodingUtils.PerformEncodingDependentOperation( signedHttpRequest.EncodedToken, 0, signedHttpRequest.Dot2, @@ -669,7 +668,7 @@ internal virtual async Task ValidateSignatureAsync(JsonWebToken sig signatureProvider, JsonWebTokenHandler.ValidateSignature)) - return popKey; + return popKey; } finally { @@ -1047,7 +1046,7 @@ internal virtual Cnf GetCnfClaimValue(JsonWebToken signedHttpRequest, JsonWebTok if (validatedAccessToken.TryGetPayloadValue(ConfirmationClaimTypes.Cnf, out string cnf) && cnf != null) return new Cnf(cnf); } - catch(JsonException ex) + catch (JsonException ex) { throw LogHelper.LogExceptionMessage(new SignedHttpRequestInvalidCnfClaimException(LogHelper.FormatInvariant(LogMessages.IDX23003, LogHelper.MarkAsNonPII(ConfirmationClaimTypes.Cnf)), ex)); } diff --git a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestUtilities.cs b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestUtilities.cs index f4151c1d69..ae3a9d72e7 100644 --- a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestUtilities.cs +++ b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestUtilities.cs @@ -75,7 +75,7 @@ public static async Task ToHttpRequestDataAsync(this HttpReques internal static async Task DecryptSymmetricPopKeyAsync(JsonWebTokenHandler jwtTokenHandler, string jwe, SignedHttpRequestValidationContext signedHttpRequestValidationContext, CancellationToken cancellationToken) { - if(string.IsNullOrEmpty(jwe)) + if (string.IsNullOrEmpty(jwe)) throw LogHelper.LogArgumentNullException(nameof(jwe)); var jweJwt = jwtTokenHandler.ReadJsonWebToken(jwe); diff --git a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestValidationContext.cs b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestValidationContext.cs index dcc25cfae2..367bd23b31 100644 --- a/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestValidationContext.cs +++ b/src/Microsoft.IdentityModel.Protocols.SignedHttpRequest/SignedHttpRequestValidationContext.cs @@ -18,8 +18,8 @@ public class SignedHttpRequestValidationContext /// A structure that represents an incoming http request. /// A required for access token ("at") validation. /// Default and will be created. - public SignedHttpRequestValidationContext(string signedHttpRequest, HttpRequestData httpRequestData, TokenValidationParameters accessTokenValidationParameters) - : this (signedHttpRequest, httpRequestData, accessTokenValidationParameters, new SignedHttpRequestValidationParameters(), new CallContext()) + public SignedHttpRequestValidationContext(string signedHttpRequest, HttpRequestData httpRequestData, TokenValidationParameters accessTokenValidationParameters) + : this(signedHttpRequest, httpRequestData, accessTokenValidationParameters, new SignedHttpRequestValidationParameters(), new CallContext()) { } /// @@ -56,7 +56,7 @@ public SignedHttpRequestValidationContext(string signedHttpRequest, HttpRequestD /// A required for access token ("at") validation. /// A set of parameters required for validating a SignedHttpRequest. /// An opaque context used to store work when working with authentication artifacts. - public SignedHttpRequestValidationContext(string signedHttpRequest, HttpRequestData httpRequestData, TokenValidationParameters accessTokenValidationParameters, SignedHttpRequestValidationParameters signedHttpRequestValidationParameters, CallContext callContext) + public SignedHttpRequestValidationContext(string signedHttpRequest, HttpRequestData httpRequestData, TokenValidationParameters accessTokenValidationParameters, SignedHttpRequestValidationParameters signedHttpRequestValidationParameters, CallContext callContext) { SignedHttpRequest = !string.IsNullOrEmpty(signedHttpRequest) ? signedHttpRequest : throw LogHelper.LogArgumentNullException(nameof(signedHttpRequest)); HttpRequestData = httpRequestData ?? throw LogHelper.LogArgumentNullException(nameof(httpRequestData)); diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/Exceptions/WsFederationReadException.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/Exceptions/WsFederationReadException.cs index ef335f8a88..360cf44b46 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/Exceptions/WsFederationReadException.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/Exceptions/WsFederationReadException.cs @@ -43,6 +43,6 @@ public WsFederationReadException(string message, Exception innerException) /// The contextual information about the source or destination. protected WsFederationReadException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsAddressingConstants.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsAddressingConstants.cs index 889a96b11f..28bd75b652 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsAddressingConstants.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsAddressingConstants.cs @@ -22,7 +22,7 @@ public static class Elements public const string EndpointReference = "EndpointReference"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationConstants.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationConstants.cs index 44900ef645..414bb99604 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationConstants.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationConstants.cs @@ -9,10 +9,10 @@ namespace Microsoft.IdentityModel.Protocols.WsFederation /// public static class WsFederationConstants { - #pragma warning disable 1591 +#pragma warning disable 1591 public const string MetadataNamespace = "urn:oasis:names:tc:SAML:2.0:metadata"; - public const string Namespace = "http://docs.oasis-open.org/wsfed/federation/200706"; + public const string Namespace = "http://docs.oasis-open.org/wsfed/federation/200706"; public const string PreferredPrefix = "fed"; /// @@ -139,7 +139,7 @@ internal static class Prefixes public const string Md = "md"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMessage.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMessage.cs index 86fd87fa98..597ed849f5 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMessage.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMessage.cs @@ -41,14 +41,14 @@ public static WsFederationMessage FromQueryString(string queryString) var wsFederationMessage = new WsFederationMessage(); if (!string.IsNullOrWhiteSpace(queryString)) { - foreach(var keyValuePair in QueryHelper.ParseQuery(queryString)) + foreach (var keyValuePair in QueryHelper.ParseQuery(queryString)) { - foreach(var value in keyValuePair.Value) + foreach (var value in keyValuePair.Value) { wsFederationMessage.SetParameter(keyValuePair.Key, value); } } - } + } return wsFederationMessage; } @@ -71,7 +71,7 @@ public static WsFederationMessage FromUri(Uri uri) return new WsFederationMessage(); } - + /// /// Initializes a new instance of the class. /// @@ -312,7 +312,7 @@ public bool IsSignInMessage { get => Wa == WsFederationConstants.WsFederationActions.SignIn; } - + /// /// Gets a boolean representing if the is a 'sign-out-message'. /// @@ -326,8 +326,8 @@ public bool IsSignOutMessage /// [property: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wa")] [property: SuppressMessage("Microsoft.Naming", "CA1704")] - public string? Wa - { + public string? Wa + { get { return GetParameter(WsFederationConstants.WsFederationParameterNames.Wa); } set { SetParameter(WsFederationConstants.WsFederationParameterNames.Wa, value); } } diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMetadataSerializer.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMetadataSerializer.cs index 33df92e5cc..980ef8d58e 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMetadataSerializer.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsFederationMetadataSerializer.cs @@ -18,7 +18,7 @@ namespace Microsoft.IdentityModel.Protocols.WsFederation public class WsFederationMetadataSerializer { private DSigSerializer _dsigSerializer = DSigSerializer.Default; - private string _preferredPrefix = WsFederationConstants.PreferredPrefix; + private string _preferredPrefix = WsFederationConstants.PreferredPrefix; /// /// Metadata serializer for WsFed. @@ -91,7 +91,7 @@ protected virtual WsFederationConfiguration ReadEntityDescriptor(XmlReader reade if (IsSecurityTokenServiceTypeRoleDescriptor(reader)) { var roleDescriptor = ReadSecurityTokenServiceTypeRoleDescriptor(reader); - foreach(var keyInfo in roleDescriptor.KeyInfos) + foreach (var keyInfo in roleDescriptor.KeyInfos) { configuration.KeyInfos.Add(keyInfo); if (keyInfo.X509Data != null) @@ -225,7 +225,7 @@ protected virtual string ReadPassiveRequestorEndpoint(XmlReader reader) reader.ReadStartElement(WsAddressing.Elements.EndpointReference, WsAddressing.Namespace); reader.MoveToContent(); - + if (reader.IsEmptyElement) throw XmlUtil.LogReadException(LogMessages.IDX22803); @@ -380,7 +380,7 @@ public void WriteMetadata(XmlWriter writer, WsFederationConfiguration configurat if (string.IsNullOrEmpty(configuration.TokenEndpoint)) throw XmlUtil.LogWriteException(LogMessages.IDX22811); - + if (configuration.SigningCredentials != null) writer = new EnvelopedSignatureWriter(writer, configuration.SigningCredentials, "id"); diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsPolicyConstants.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsPolicyConstants.cs index 5e83cbc530..d1fa80c92f 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsPolicyConstants.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsPolicyConstants.cs @@ -8,7 +8,7 @@ namespace Microsoft.IdentityModel.Xml /// public static class WsPolicy { - #pragma warning disable 1591 +#pragma warning disable 1591 public const string Namespace = "http://schemas.xmlsoap.org/ws/2004/09/policy"; public const string PreferredPrefix = "wsp"; @@ -18,7 +18,7 @@ public static class Elements public const string AppliesTo = "AppliesTo"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants.cs index ee663daf5f..a9732d8a26 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants.cs @@ -9,7 +9,7 @@ namespace Microsoft.IdentityModel.Xml /// public static class WsTrustConstants { - #pragma warning disable 1591 +#pragma warning disable 1591 /// /// Elements that can be in a WsTrust message @@ -38,7 +38,7 @@ public static class Namespaces public const string WsTrust1_4 = "http://docs.oasis-open.org/ws-sx/ws-trust/200802"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_3.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_3.cs index e4b1ce48a1..a492119822 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_3.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_3.cs @@ -8,7 +8,7 @@ namespace Microsoft.IdentityModel.Xml /// public static class WsTrustConstants_1_3 { - #pragma warning disable 1591 +#pragma warning disable 1591 public const string Namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512"; public const string PreferredPrefix = "t"; @@ -18,7 +18,7 @@ public static class Actions public const string Issue = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_4.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_4.cs index 291ce53c57..a8f393f279 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_4.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_1_4.cs @@ -18,7 +18,7 @@ public static class Actions public const string Issue = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_2005.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_2005.cs index e44bbd8fa6..d0d692f568 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_2005.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsTrustConstants_2005.cs @@ -8,7 +8,7 @@ namespace Microsoft.IdentityModel.Xml /// public static class WsTrustConstants_2005 { - #pragma warning disable 1591 +#pragma warning disable 1591 public const string Namespace = "http://schemas.xmlsoap.org/ws/2005/02/trust"; public const string PreferredPrefix = "trust"; @@ -18,7 +18,7 @@ public static class Actions public const string Issue = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsUtilityConstants.cs b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsUtilityConstants.cs index 3754b49f96..9eea60b816 100644 --- a/src/Microsoft.IdentityModel.Protocols.WsFederation/WsUtilityConstants.cs +++ b/src/Microsoft.IdentityModel.Protocols.WsFederation/WsUtilityConstants.cs @@ -8,7 +8,7 @@ namespace Microsoft.IdentityModel.Xml /// public static class WsUtility { - #pragma warning disable 1591 +#pragma warning disable 1591 public const string Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; public const string PreferredPrefix = "wsu"; @@ -22,7 +22,7 @@ public static class Elements public const string Expires = "Expires"; } - #pragma warning restore 1591 +#pragma warning restore 1591 } } - + diff --git a/src/Microsoft.IdentityModel.Protocols/AuthenticationProtocolMessage.cs b/src/Microsoft.IdentityModel.Protocols/AuthenticationProtocolMessage.cs index dd9f0892fb..36cac13e31 100644 --- a/src/Microsoft.IdentityModel.Protocols/AuthenticationProtocolMessage.cs +++ b/src/Microsoft.IdentityModel.Protocols/AuthenticationProtocolMessage.cs @@ -16,7 +16,7 @@ namespace Microsoft.IdentityModel.Protocols public abstract class AuthenticationProtocolMessage { private string _postTitle = "Working..."; - private string _script = ""; + private string _script = ""; private string _scriptButtonText = "Submit"; private string _scriptDisabledText = "Script is disabled. Click Submit to continue."; @@ -111,7 +111,7 @@ public virtual string GetParameter(string parameter) _parameters.TryGetValue(parameter, out value); return value; } - + /// /// Gets or sets the issuer address. /// @@ -136,9 +136,9 @@ public string IssuerAddress /// public IDictionary Parameters { - get - { - return _parameters; + get + { + return _parameters; } } @@ -146,11 +146,11 @@ public IDictionary Parameters /// Gets or sets the title used when constructing the post string. /// /// If the 'value' is null. - public string PostTitle + public string PostTitle { get - { - return _postTitle; + { + return _postTitle; } set @@ -183,7 +183,7 @@ public virtual void RemoveParameter(string parameter) /// The value to be assigned to parameter. /// If 'parameterName' is null or empty. /// If null is passed as value and the parameter exists, that parameter is removed. - public void SetParameter(string parameter, string value) + public void SetParameter(string parameter, string value) { if (string.IsNullOrEmpty(parameter)) throw LogHelper.LogArgumentNullException(nameof(parameter)); diff --git a/src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs b/src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs index 279e046687..c923422ab1 100644 --- a/src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs +++ b/src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Diagnostics.Contracts; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -193,7 +192,7 @@ public virtual async Task GetConfigurationAsync(CancellationToken cancel) throw LogHelper.LogExceptionMessage( new InvalidOperationException( LogHelper.FormatInvariant(LogMessages.IDX20803, LogHelper.MarkAsNonPII(MetadataAddress ?? "null"), LogHelper.MarkAsNonPII(_syncAfter), LogHelper.MarkAsNonPII(ex)), ex)); - } + } else { _syncAfter = DateTimeUtil.Add(DateTime.UtcNow, AutomaticRefreshInterval < RefreshInterval ? AutomaticRefreshInterval : RefreshInterval); diff --git a/src/Microsoft.IdentityModel.Protocols/Configuration/StaticConfigurationManager.cs b/src/Microsoft.IdentityModel.Protocols/Configuration/StaticConfigurationManager.cs index ca2f8a11e1..7b4cbb1e36 100644 --- a/src/Microsoft.IdentityModel.Protocols/Configuration/StaticConfigurationManager.cs +++ b/src/Microsoft.IdentityModel.Protocols/Configuration/StaticConfigurationManager.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.IdentityModel.Logging; -using Microsoft.IdentityModel.Protocols.Configuration; using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.Protocols @@ -16,7 +15,7 @@ namespace Microsoft.IdentityModel.Protocols /// /// must be a class. public class StaticConfigurationManager : BaseConfigurationManager, IConfigurationManager where T : class - { + { private T _configuration; /// diff --git a/src/Microsoft.IdentityModel.TestExtensions/Microsoft.IdentityModel.TestExtensions.csproj b/src/Microsoft.IdentityModel.TestExtensions/Microsoft.IdentityModel.TestExtensions.csproj index 8a68c34a08..8cb7fa5e5a 100644 --- a/src/Microsoft.IdentityModel.TestExtensions/Microsoft.IdentityModel.TestExtensions.csproj +++ b/src/Microsoft.IdentityModel.TestExtensions/Microsoft.IdentityModel.TestExtensions.csproj @@ -8,6 +8,7 @@ true Microsoft.IdentityModel.TestExtensions true + true Microsoft.IdentityModel.TestExtensions true enable diff --git a/src/Microsoft.IdentityModel.TestExtensions/TestTokenCreator.cs b/src/Microsoft.IdentityModel.TestExtensions/TestTokenCreator.cs index d263ce4756..41545e83d7 100644 --- a/src/Microsoft.IdentityModel.TestExtensions/TestTokenCreator.cs +++ b/src/Microsoft.IdentityModel.TestExtensions/TestTokenCreator.cs @@ -34,7 +34,7 @@ namespace Microsoft.IdentityModel.TestExtensions /// In the following code example, generateTokenToTest should be one of the methods from this class. /// /// - /// internal void AssertValidationException(Func generateTokenToTest, Type innerExceptionType, string innerExceptionMessagePart) + /// internal void AssertValidationException(Func{string} generateTokenToTest, Type innerExceptionType, string innerExceptionMessagePart) /// { /// try /// { @@ -159,7 +159,12 @@ public string CreateTokenWithInvalidSignature() { var tokenDescriptor = CreateTokenDescriptorWithInstanceOverrides(); var token = CreateToken(tokenDescriptor); - return token.Substring(0, token.LastIndexOf('.')) + ".InvalidSignature"; + +#if NETCOREAPP + return string.Concat(token.AsSpan(0, token.LastIndexOf(value: '.')), ".InvalidSignature"); +#else + return token.Substring(0, token.LastIndexOf(value: '.')) + ".InvalidSignature"; +#endif } /// @@ -335,7 +340,7 @@ public string CreateTokenWithMissingKey() /// /// Creates a default set of claims based on the instance values. /// - /// A representing the claims of a token to create. + /// A representing the claims of a token to create. public Dictionary CreateClaimsSetWithInstanceOverrides() { var claims = new Dictionary(); @@ -395,12 +400,12 @@ public static string CreateToken(SecurityTokenDescriptor securityTokenDescriptor } /// - /// Creates a token based on the passed . + /// Creates a token based on the passed . /// - /// - /// The of claims which describe the token to create. + /// + /// The of claims which describe the token to create. /// - /// A JWS token described by the passed . + /// A JWS token described by the passed . public string CreateToken(Dictionary claims) { var tokenHandler = new JsonWebTokenHandler() @@ -412,10 +417,10 @@ public string CreateToken(Dictionary claims) } /// - /// Creates a JSON payload based on the passed of claims. + /// Creates a JSON payload based on the passed of claims. /// /// - /// The of claims which describe the payload to create. + /// The of claims which describe the payload to create. /// A JSON payload based on the passed . public static string CreateJsonPayload(IDictionary claims) { diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenException.cs index 14e3352276..4964d8f4e5 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenException.cs @@ -17,7 +17,7 @@ public class SamlSecurityTokenException : SecurityTokenException /// public SamlSecurityTokenException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public SamlSecurityTokenException() /// Addtional information to be included in the exception and displayed to user. public SamlSecurityTokenException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public SamlSecurityTokenException(string message) /// A that represents the root cause of the exception. public SamlSecurityTokenException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public SamlSecurityTokenException(string message, Exception innerException) /// The contextual information about the source or destination. protected SamlSecurityTokenException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenReadException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenReadException.cs index 0012dbfa15..c76779cee4 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenReadException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenReadException.cs @@ -17,7 +17,7 @@ public class SamlSecurityTokenReadException : SamlSecurityTokenException /// public SamlSecurityTokenReadException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public SamlSecurityTokenReadException() /// Addtional information to be included in the exception and displayed to user. public SamlSecurityTokenReadException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public SamlSecurityTokenReadException(string message) /// A that represents the root cause of the exception. public SamlSecurityTokenReadException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public SamlSecurityTokenReadException(string message, Exception innerException) /// The contextual information about the source or destination. protected SamlSecurityTokenReadException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenWriteException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenWriteException.cs index 03d3611a1a..d896bbc34d 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenWriteException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/Exceptions/SamlSecurityTokenWriteException.cs @@ -17,7 +17,7 @@ public class SamlSecurityTokenWriteException : SamlSecurityTokenException /// public SamlSecurityTokenWriteException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public SamlSecurityTokenWriteException() /// Addtional information to be included in the exception and displayed to user. public SamlSecurityTokenWriteException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public SamlSecurityTokenWriteException(string message) /// A that represents the root cause of the exception. public SamlSecurityTokenWriteException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public SamlSecurityTokenWriteException(string message, Exception innerException) /// The contextual information about the source or destination. protected SamlSecurityTokenWriteException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAssertion.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAssertion.cs index be6e2c61d4..f1b64ff790 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAssertion.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAssertion.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Text; using System.Xml; diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAttributeKeyComparer.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAttributeKeyComparer.cs index 854fd4ef4a..0231ae14a9 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAttributeKeyComparer.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAttributeKeyComparer.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using static Microsoft.IdentityModel.Logging.LogHelper; diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAuthorizationDecisionStatement.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAuthorizationDecisionStatement.cs index 94fad82780..adf485b15a 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAuthorizationDecisionStatement.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlAuthorizationDecisionStatement.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using System.Security.Claims; using static Microsoft.IdentityModel.Logging.LogHelper; diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs index 2a15d78ee5..d82ff3f75e 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs @@ -30,7 +30,7 @@ public class SamlSecurityTokenHandler : SecurityTokenHandler private IEqualityComparer _samlSubjectEqualityComparer = new SamlSubjectEqualityComparer(); private SamlSerializer _serializer = new SamlSerializer(); -#region fields + #region fields /// /// Gets a value indicating whether this handler supports validation of tokens /// handled by this instance. @@ -75,7 +75,7 @@ public SamlSerializer Serializer { get { return _serializer; } set { _serializer = value ?? throw LogHelper.LogArgumentNullException(nameof(value)); } - } + } /// /// Gets the securityToken type supported by this handler. @@ -87,7 +87,7 @@ public override Type TokenType #endregion fields -#region methods + #region methods /// /// Adds all Actors. /// @@ -131,7 +131,7 @@ public override bool CanReadToken(string securityToken) using (var sr = new StringReader(securityToken)) { var settings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Prohibit }; - using (var reader = XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(sr, settings))) + using (var reader = XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(sr, settings))) { return CanReadToken(reader); } @@ -550,7 +550,7 @@ protected virtual string CreateXmlStringFromAttributes(ICollectionThe to be used for validating the token. protected virtual void ValidateIssuerSecurityKey(SecurityKey securityKey, SecurityToken securityToken, TokenValidationParameters validationParameters) { - Validators.ValidateIssuerSecurityKey(securityKey, securityToken, validationParameters); + Validators.ValidateIssuerSecurityKey(securityKey, securityToken, validationParameters); } /// @@ -1329,6 +1329,6 @@ public override void WriteToken(XmlWriter writer, SecurityToken token) Serializer.WriteAssertion(writer, samlToken.Assertion); } -#endregion methods + #endregion methods } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSerializer.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSerializer.cs index ab5c952332..bf0c47a6f4 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSerializer.cs @@ -1169,7 +1169,7 @@ protected virtual void WriteAudienceRestrictionCondition(XmlWriter writer, SamlA if (audienceRestriction == null) throw LogArgumentNullException(nameof(audienceRestriction)); - + // writer.WriteStartElement(Prefix, SamlConstants.Elements.AudienceRestrictionCondition, SamlConstants.Namespace); diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenException.cs index 758558afd6..89a187b404 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenException.cs @@ -17,7 +17,7 @@ public class Saml2SecurityTokenException : SecurityTokenException /// public Saml2SecurityTokenException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public Saml2SecurityTokenException() /// Addtional information to be included in the exception and displayed to user. public Saml2SecurityTokenException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public Saml2SecurityTokenException(string message) /// A that represents the root cause of the exception. public Saml2SecurityTokenException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public Saml2SecurityTokenException(string message, Exception innerException) /// The contextual information about the source or destination. protected Saml2SecurityTokenException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenReadException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenReadException.cs index 6019b68c94..385950227e 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenReadException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenReadException.cs @@ -17,7 +17,7 @@ public class Saml2SecurityTokenReadException : Saml2SecurityTokenException /// public Saml2SecurityTokenReadException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public Saml2SecurityTokenReadException() /// Addtional information to be included in the exception and displayed to user. public Saml2SecurityTokenReadException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public Saml2SecurityTokenReadException(string message) /// A that represents the root cause of the exception. public Saml2SecurityTokenReadException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public Saml2SecurityTokenReadException(string message, Exception innerException) /// The contextual information about the source or destination. protected Saml2SecurityTokenReadException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenWriteException.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenWriteException.cs index 3a888f9dc5..973d516d42 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenWriteException.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Exceptions/Saml2SecurityTokenWriteException.cs @@ -17,7 +17,7 @@ public class Saml2SecurityTokenWriteException : Saml2SecurityTokenException /// public Saml2SecurityTokenWriteException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public Saml2SecurityTokenWriteException() /// Addtional information to be included in the exception and displayed to user. public Saml2SecurityTokenWriteException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public Saml2SecurityTokenWriteException(string message) /// A that represents the root cause of the exception. public Saml2SecurityTokenWriteException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public Saml2SecurityTokenWriteException(string message, Exception innerException /// The contextual information about the source or destination. protected Saml2SecurityTokenWriteException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Assertion.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Assertion.cs index 421f235ec8..c33f050965 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Assertion.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Assertion.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Text; using System.Xml; diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AttributeKeyComparer.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AttributeKeyComparer.cs index bad34d9001..8ef62e9ea5 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AttributeKeyComparer.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AttributeKeyComparer.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using static Microsoft.IdentityModel.Logging.LogHelper; diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AuthorizationDecisionStatement.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AuthorizationDecisionStatement.cs index 1173beaf32..f915e4d8f5 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AuthorizationDecisionStatement.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2AuthorizationDecisionStatement.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using static Microsoft.IdentityModel.Logging.LogHelper; namespace Microsoft.IdentityModel.Tokens.Saml2 diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Constants.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Constants.cs index 6f1afaa4d5..d9eb4e13ca 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Constants.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Constants.cs @@ -42,11 +42,11 @@ public static class Saml2Constants public static class AccessDecision { - public static string Deny { get { return "Deny"; } } + public static string Deny { get { return "Deny"; } } - public static string Indeterminate { get { return "Indeterminate"; } } + public static string Indeterminate { get { return "Indeterminate"; } } - public static string Permit { get { return "Permit"; } } + public static string Permit { get { return "Permit"; } } } public static class Attributes diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs index 0fb090b98c..90184df46f 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Security.Claims; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Xml; using Microsoft.IdentityModel.Abstractions; @@ -104,7 +103,7 @@ public override bool CanReadToken(string token) } } } - catch(Exception) + catch (Exception) { return false; } @@ -649,7 +648,7 @@ protected virtual Saml2Conditions CreateConditions(SecurityTokenDescriptor token var audienceRestriction = new Saml2AudienceRestriction(tokenDescriptor.Audiences); if (!string.IsNullOrEmpty(tokenDescriptor.Audience)) audienceRestriction.Audiences.Add(tokenDescriptor.Audience); - conditions.AudienceRestrictions.Add(audienceRestriction); + conditions.AudienceRestrictions.Add(audienceRestriction); } else if (!string.IsNullOrEmpty(tokenDescriptor.Audience)) conditions.AudienceRestrictions.Add(new Saml2AudienceRestriction(tokenDescriptor.Audience)); @@ -1044,7 +1043,7 @@ protected virtual void ValidateConditions(Saml2SecurityToken samlToken, TokenVal ValidateAudience(audienceRestriction.Audiences, samlToken, validationParameters); } - + if (validationParameters.RequireAudience && !foundAudienceRestriction) throw LogExceptionMessage(new Saml2SecurityTokenException(LogMessages.IDX13002)); } @@ -1078,7 +1077,7 @@ protected virtual void SetClaimsIdentityActorFromAttribute(Saml2Attribute attrib Saml2Attribute actorAttribute = null; var claims = new Collection(); - + // search through attribute values to see if the there is an embedded actor. foreach (string value in attribute.Values) { diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Serializer.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Serializer.cs index 1da8c0a2ee..87511d4f33 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Serializer.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2Serializer.cs @@ -215,7 +215,7 @@ public virtual Saml2Assertion ReadAssertion(XmlReader reader) // will move to next element // 0-1 read by EnvelopedSignatureReader envelopeReader.Read(); - + // 1 assertion.Issuer = ReadIssuer(envelopeReader); @@ -1381,7 +1381,7 @@ protected virtual Saml2NameIdentifier ReadNameIdentifier(XmlDictionaryReader rea // No declaration, or declaring that this is just a "BaseID", is invalid since statement is abstract if (declaredType == null || XmlUtil.EqualsQName(declaredType, Saml2Constants.Types.BaseIDAbstractType, Saml2Constants.Namespace)) - throw LogReadException(LogMessages.IDX13103, Saml2Constants.Elements.BaseID, declaredType, GetType(), "ReadSubjectId" ); + throw LogReadException(LogMessages.IDX13103, Saml2Constants.Elements.BaseID, declaredType, GetType(), "ReadSubjectId"); // If it's NameID we can handle it if (XmlUtil.EqualsQName(declaredType, Saml2Constants.Types.NameIDType, Saml2Constants.Namespace)) @@ -1610,7 +1610,7 @@ public virtual void WriteAttribute(XmlWriter writer, Saml2Attribute attribute) writer.WriteAttributeString(Saml2Constants.Attributes.FriendlyName, attribute.FriendlyName); // @OriginalIssuer - optional - if (attribute.OriginalIssuer != null ) + if (attribute.OriginalIssuer != null) writer.WriteAttributeString(Saml2Constants.Attributes.OriginalIssuer, Saml2Constants.ClaimType2009Namespace, attribute.OriginalIssuer); string xsiTypePrefix = null; @@ -1809,7 +1809,7 @@ protected virtual void WriteAuthorizationDecisionStatement(XmlWriter writer, Sam throw LogArgumentNullException(nameof(statement)); if (statement.Actions.Count == 0) - throw LogWriteException(LogMessages.IDX13901, statement.GetType(), "Actions" ); + throw LogWriteException(LogMessages.IDX13901, statement.GetType(), "Actions"); if (string.IsNullOrEmpty(statement.Decision)) throw LogWriteException(LogMessages.IDX13900, Saml2Constants.Attributes.Decision, nameof(statement.Decision)); @@ -1900,8 +1900,8 @@ protected virtual void WriteEvidence(XmlWriter writer, Saml2Evidence evidence) throw LogArgumentNullException(nameof(evidence)); if (evidence.AssertionIdReferences.Count == 0 - && evidence.Assertions.Count == 0 - && evidence.AssertionUriReferences.Count == 0 ) + && evidence.Assertions.Count == 0 + && evidence.AssertionUriReferences.Count == 0) throw LogWriteException(LogMessages.IDX13902); // @@ -2088,7 +2088,7 @@ protected virtual void WriteSubject(XmlWriter writer, Saml2Subject subject) throw LogArgumentNullException(nameof(subject)); // If there's no ID, there has to be a SubjectConfirmation - if (subject.NameId == null && 0 == subject.SubjectConfirmations.Count) + if (subject.NameId == null && 0 == subject.SubjectConfirmations.Count) throw LogExceptionMessage(new Saml2SecurityTokenException(FormatInvariant(LogMessages.IDX13305, subject))); // diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SubjectConfirmationData.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SubjectConfirmationData.cs index 31f5ed1735..fc5ad6f542 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SubjectConfirmationData.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SubjectConfirmationData.cs @@ -78,7 +78,7 @@ public DateTime? NotOnOrAfter /// public Uri Recipient { - get { return _recipient; } + get { return _recipient; } set { if (value == null) diff --git a/src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs b/src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs index f33207105c..5bca1e9317 100644 --- a/src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs +++ b/src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs @@ -428,7 +428,7 @@ private bool VerifyUsingSpan(bool isRSA, ReadOnlySpan bytes, byte[] signat } #endif -#region DESKTOP related code + #region DESKTOP related code #if DESKTOP internal byte[] DecryptWithRsaCryptoServiceProviderProxy(byte[] bytes) { @@ -461,7 +461,7 @@ private bool VerifyWithRsaCryptoServiceProviderProxyUsingOffset(byte[] bytes, in return RsaCryptoServiceProviderProxy.VerifyDataWithLength(bytes, offset, length, HashAlgorithm, HashAlgorithmName, signature); } #endif -#endregion + #endregion } } diff --git a/src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs b/src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs index 3058a55f5d..7fcd84cb1a 100644 --- a/src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs +++ b/src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs @@ -3,12 +3,13 @@ using System; using System.Buffers; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; using Microsoft.IdentityModel.Logging; +#if NETCOREAPP +using System.Runtime.CompilerServices; +#endif + namespace Microsoft.IdentityModel.Tokens { /// @@ -159,7 +160,7 @@ public static int Encode(ReadOnlySpan inArray, Span output) } break; - //default or case 0: no further operations are needed. + //default or case 0: no further operations are needed. } return j; diff --git a/src/Microsoft.IdentityModel.Tokens/BaseConfigurationComparer.cs b/src/Microsoft.IdentityModel.Tokens/BaseConfigurationComparer.cs index 28413ea56c..bc2bd01127 100644 --- a/src/Microsoft.IdentityModel.Tokens/BaseConfigurationComparer.cs +++ b/src/Microsoft.IdentityModel.Tokens/BaseConfigurationComparer.cs @@ -42,7 +42,7 @@ public bool Equals(BaseConfiguration config1, BaseConfiguration config2) private static bool ContainsKeyWithInternalId(BaseConfiguration config, string internalId) { - foreach(var key in config.SigningKeys) + foreach (var key in config.SigningKeys) if (key.InternalId == internalId) return true; diff --git a/src/Microsoft.IdentityModel.Tokens/CryptoProviderFactory.cs b/src/Microsoft.IdentityModel.Tokens/CryptoProviderFactory.cs index 8df6bf6e17..4bfcad5437 100644 --- a/src/Microsoft.IdentityModel.Tokens/CryptoProviderFactory.cs +++ b/src/Microsoft.IdentityModel.Tokens/CryptoProviderFactory.cs @@ -447,43 +447,43 @@ public virtual KeyedHashAlgorithm CreateKeyedHashAlgorithm(byte[] keyBytes, stri switch (algorithm) { case SecurityAlgorithms.Aes128CbcHmacSha256: - { - ValidateKeySize(keyBytes, algorithm, 16); - return new HMACSHA256(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 16); + return new HMACSHA256(keyBytes); + } case SecurityAlgorithms.Aes192CbcHmacSha384: - { - ValidateKeySize(keyBytes, algorithm, 24); - return new HMACSHA384(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 24); + return new HMACSHA384(keyBytes); + } case SecurityAlgorithms.Aes256CbcHmacSha512: - { - ValidateKeySize(keyBytes, algorithm, 32); - return new HMACSHA512(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 32); + return new HMACSHA512(keyBytes); + } case SecurityAlgorithms.HmacSha256Signature: case SecurityAlgorithms.HmacSha256: - { - ValidateKeySize(keyBytes, algorithm, 32); - return new HMACSHA256(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 32); + return new HMACSHA256(keyBytes); + } case SecurityAlgorithms.HmacSha384Signature: case SecurityAlgorithms.HmacSha384: - { - ValidateKeySize(keyBytes, algorithm, 48); - return new HMACSHA384(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 48); + return new HMACSHA384(keyBytes); + } case SecurityAlgorithms.HmacSha512Signature: case SecurityAlgorithms.HmacSha512: - { - ValidateKeySize(keyBytes, algorithm, 64); - return new HMACSHA512(keyBytes); - } + { + ValidateKeySize(keyBytes, algorithm, 64); + return new HMACSHA512(keyBytes); + } default: throw LogHelper.LogExceptionMessage(new NotSupportedException(LogHelper.FormatInvariant(LogMessages.IDX10666, LogHelper.MarkAsNonPII(algorithm)))); @@ -561,7 +561,7 @@ private SignatureProvider CreateSignatureProvider(SecurityKey key, string algori } } } - catch(Exception ex) + catch (Exception ex) { throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX10694, key, ex), ex)); } diff --git a/src/Microsoft.IdentityModel.Tokens/ECDsaAdapter.cs b/src/Microsoft.IdentityModel.Tokens/ECDsaAdapter.cs index 32c25b070c..65c76a544e 100644 --- a/src/Microsoft.IdentityModel.Tokens/ECDsaAdapter.cs +++ b/src/Microsoft.IdentityModel.Tokens/ECDsaAdapter.cs @@ -2,11 +2,17 @@ // Licensed under the MIT License. using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Security.Cryptography; using Microsoft.IdentityModel.Logging; +#if NET462 || NETSTANDARD2_0 +using System.Runtime.InteropServices; +#endif + +#if NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER +using System.Runtime.CompilerServices; +#endif + namespace Microsoft.IdentityModel.Tokens { delegate ECDsa CreateECDsaDelegate(JsonWebKey jsonWebKey, bool usePrivateKey); @@ -37,7 +43,7 @@ internal ECDsaAdapter() if (SupportsECParameters()) CreateECDsaFunction = CreateECDsaUsingECParams; else CreateECDsaFunction = CreateECDsaUsingCNGKey; #else - CreateECDsaFunction = CreateECDsaUsingCNGKey; + CreateECDsaFunction = CreateECDsaUsingCNGKey; #endif } @@ -309,7 +315,7 @@ internal static string GetCrvParameterValue(ECCurve curve) else throw LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(LogMessages.IDX10645, (curve.Oid.Value ?? curve.Oid.FriendlyName) ?? "null"))); } - + /// /// Determines whether user application's runtime supports structure. diff --git a/src/Microsoft.IdentityModel.Tokens/EncodingUtils.cs b/src/Microsoft.IdentityModel.Tokens/EncodingUtils.cs index c1e8f12d0e..817302f32a 100644 --- a/src/Microsoft.IdentityModel.Tokens/EncodingUtils.cs +++ b/src/Microsoft.IdentityModel.Tokens/EncodingUtils.cs @@ -161,7 +161,7 @@ internal static T PerformEncodingDependentOperation( TX parameter, Func action) { - + int size = encoding.GetMaxByteCount(length); byte[] bytes = ArrayPool.Shared.Rent(size); try diff --git a/src/Microsoft.IdentityModel.Tokens/Encryption/AuthenticatedEncryptionProvider.cs b/src/Microsoft.IdentityModel.Tokens/Encryption/AuthenticatedEncryptionProvider.cs index d3e794b40a..a8e38b0b1f 100644 --- a/src/Microsoft.IdentityModel.Tokens/Encryption/AuthenticatedEncryptionProvider.cs +++ b/src/Microsoft.IdentityModel.Tokens/Encryption/AuthenticatedEncryptionProvider.cs @@ -2,12 +2,14 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; using System.IO; -using System.Runtime.InteropServices; using System.Security.Cryptography; using Microsoft.IdentityModel.Logging; +#if NETSTANDARD2_0 +using System.Runtime.InteropServices; +#endif + namespace Microsoft.IdentityModel.Tokens { delegate AuthenticatedEncryptionResult EncryptionDelegate(byte[] plaintText, byte[] authenticatedData, byte[] iv); @@ -63,7 +65,7 @@ public AuthenticatedEncryptionProvider(SecurityKey key, string algorithm) if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) throw LogHelper.LogExceptionMessage(new PlatformNotSupportedException(LogHelper.FormatInvariant(LogMessages.IDX10713, LogHelper.MarkAsNonPII(algorithm)))); #elif NET6_0_OR_GREATER - if(!System.Security.Cryptography.AesGcm.IsSupported) + if (!System.Security.Cryptography.AesGcm.IsSupported) throw LogHelper.LogExceptionMessage(new PlatformNotSupportedException(LogHelper.FormatInvariant(LogMessages.IDX10713, LogHelper.MarkAsNonPII(algorithm)))); #endif InitializeUsingAesGcm(); diff --git a/src/Microsoft.IdentityModel.Tokens/Encryption/EcdhKeyExchangeProvider.cs b/src/Microsoft.IdentityModel.Tokens/Encryption/EcdhKeyExchangeProvider.cs index a1ccd090cf..b6cb2cdb9f 100644 --- a/src/Microsoft.IdentityModel.Tokens/Encryption/EcdhKeyExchangeProvider.cs +++ b/src/Microsoft.IdentityModel.Tokens/Encryption/EcdhKeyExchangeProvider.cs @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if NET472 || NET6_0_OR_GREATER using System; using System.Text; using System.Security.Cryptography; using Microsoft.IdentityModel.Logging; +#endif namespace Microsoft.IdentityModel.Tokens { diff --git a/src/Microsoft.IdentityModel.Tokens/Encryption/SymmetricKeyWrapProvider.cs b/src/Microsoft.IdentityModel.Tokens/Encryption/SymmetricKeyWrapProvider.cs index ee156b6a42..20b9f096f0 100644 --- a/src/Microsoft.IdentityModel.Tokens/Encryption/SymmetricKeyWrapProvider.cs +++ b/src/Microsoft.IdentityModel.Tokens/Encryption/SymmetricKeyWrapProvider.cs @@ -296,7 +296,7 @@ Return an error } } - if (Utility.AreEqual(a, _defaultIV)) + if (Utility.AreEqual(a, _defaultIV)) { var keyBytes = new byte[n << 3]; diff --git a/src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs b/src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs index 80ba6ed504..381138019f 100644 --- a/src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs +++ b/src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs @@ -267,7 +267,7 @@ internal void RemoveExpiredValuesLRU() node = nextNode; } } - catch(Exception ex) + catch (Exception ex) { if (LogHelper.IsEnabled(EventLogLevel.Warning)) LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, LogHelper.MarkAsNonPII(nameof(RemoveExpiredValuesLRU)), ex)); @@ -299,7 +299,7 @@ internal void RemoveExpiredValues() } } } - catch(Exception ex) + catch (Exception ex) { if (LogHelper.IsEnabled(EventLogLevel.Warning)) LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, LogHelper.MarkAsNonPII(nameof(ProcessCompactedValues)), ex)); @@ -331,7 +331,7 @@ internal void ProcessCompactedValues() } } } - catch(Exception ex) + catch (Exception ex) { if (LogHelper.IsEnabled(EventLogLevel.Warning)) LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10906, LogHelper.MarkAsNonPII(nameof(ProcessCompactedValues)), ex)); @@ -541,7 +541,7 @@ private void StartEventQueueTaskIfNotRunning() // the caller's TaskScheduler (if there is one) as some custom TaskSchedulers might be single-threaded and its execution can be blocked. if (Interlocked.CompareExchange(ref _eventQueueTaskState, EventQueueTaskRunning, EventQueueTaskStopped) == EventQueueTaskStopped) { - _ = Task.Run(EventQueueTaskAction); + _ = Task.Run(EventQueueTaskAction); } } diff --git a/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenException.cs b/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenException.cs index e346c7cf73..efe000f387 100644 --- a/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenException.cs +++ b/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenException.cs @@ -4,8 +4,15 @@ using System; using System.Diagnostics; using System.Runtime.Serialization; -using System.Text; + +#if NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER using Microsoft.IdentityModel.Logging; +#endif + +#if !NET8_0_OR_GREATER +using System.Text; +#endif + namespace Microsoft.IdentityModel.Tokens { @@ -52,7 +59,7 @@ public SecurityTokenException(string message, Exception innerException) /// the that holds the serialized object data. /// The contextual information about the source or destination. #if NET8_0_OR_GREATER - [Obsolete("Formatter-based serialization is obsolete", DiagnosticId = "SYSLIB0051")] + [Obsolete("Formatter-based serialization is obsolete", DiagnosticId = "SYSLIB0051")] #endif protected SecurityTokenException(SerializationInfo info, StreamingContext context) : base(info, context) diff --git a/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenInvalidTypeException.cs b/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenInvalidTypeException.cs index 6dccc65bd8..0b70e9cf9b 100644 --- a/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenInvalidTypeException.cs +++ b/src/Microsoft.IdentityModel.Tokens/Exceptions/SecurityTokenInvalidTypeException.cs @@ -13,7 +13,7 @@ namespace Microsoft.IdentityModel.Tokens public class SecurityTokenInvalidTypeException : SecurityTokenValidationException { [NonSerialized] - const string _Prefix = "Microsoft.IdentityModel." + nameof(SecurityTokenInvalidTypeException) +"."; + const string _Prefix = "Microsoft.IdentityModel." + nameof(SecurityTokenInvalidTypeException) + "."; [NonSerialized] const string _InvalidTypeKey = _Prefix + nameof(InvalidType); diff --git a/src/Microsoft.IdentityModel.Tokens/ICryptoProvider.cs b/src/Microsoft.IdentityModel.Tokens/ICryptoProvider.cs index ac062187b2..9f950b81ec 100644 --- a/src/Microsoft.IdentityModel.Tokens/ICryptoProvider.cs +++ b/src/Microsoft.IdentityModel.Tokens/ICryptoProvider.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Security.Cryptography; - namespace Microsoft.IdentityModel.Tokens { /// diff --git a/src/Microsoft.IdentityModel.Tokens/InMemoryCryptoProviderCache.cs b/src/Microsoft.IdentityModel.Tokens/InMemoryCryptoProviderCache.cs index fbd0567e66..1cd4edf23e 100644 --- a/src/Microsoft.IdentityModel.Tokens/InMemoryCryptoProviderCache.cs +++ b/src/Microsoft.IdentityModel.Tokens/InMemoryCryptoProviderCache.cs @@ -12,7 +12,7 @@ namespace Microsoft.IdentityModel.Tokens /// Defines a cache for crypto providers. /// Current support is limited to only. /// - public class InMemoryCryptoProviderCache: CryptoProviderCache, IDisposable + public class InMemoryCryptoProviderCache : CryptoProviderCache, IDisposable { internal CryptoProviderCacheOptions _cryptoProviderCacheOptions; private bool _disposed; @@ -250,7 +250,7 @@ protected virtual void Dispose(bool disposing) } } -#region FOR TESTING (INTERNAL ONLY) + #region FOR TESTING (INTERNAL ONLY) /// /// FOR TESTING ONLY. /// diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs index 87180bfe7b..d94f9ec768 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs @@ -844,7 +844,7 @@ internal static object ReadStringAsObject(ref Utf8JsonReader reader, string prop return dateTimeValue; } } - catch(Exception) + catch (Exception) { } #pragma warning restore CA1031 // Do not catch general exception types @@ -1190,7 +1190,7 @@ public static void WriteObject(ref Utf8JsonWriter writer, string key, object obj LogMessages.IDX11025, LogHelper.MarkAsNonPII(objType.ToString()), LogHelper.MarkAsNonPII(key)))); - } + } /// /// Writes values into an array. @@ -1233,7 +1233,7 @@ public static void WriteObjectValue(ref Utf8JsonWriter writer, object obj) #if NET6_0_OR_GREATER writer.WriteNumberValue(dub); #else - #pragma warning disable CA1031 // Do not catch general exception types, we have seen TryParse fault. +#pragma warning disable CA1031 // Do not catch general exception types, we have seen TryParse fault. try { if (decimal.TryParse(dub.ToString(CultureInfo.InvariantCulture), out decimal dec)) @@ -1245,7 +1245,7 @@ public static void WriteObjectValue(ref Utf8JsonWriter writer, object obj) { writer.WriteNumberValue(dub); } - #pragma warning restore CA1031 +#pragma warning restore CA1031 #endif else if (obj is JsonElement j) j.WriteTo(writer); @@ -1270,24 +1270,24 @@ public static void WriteObjectValue(ref Utf8JsonWriter writer, object obj) else if (obj is decimal d) writer.WriteNumberValue(d); else if (obj is float f) - // Below net6.0, we have to convert the float to a decimal otherwise values like 1.11 will be serailized as 1.11000001 - // In failure cases, we will write the float as is. + // Below net6.0, we have to convert the float to a decimal otherwise values like 1.11 will be serailized as 1.11000001 + // In failure cases, we will write the float as is. #if NET6_0_OR_GREATER - writer.WriteNumberValue(f); + writer.WriteNumberValue(f); #else - #pragma warning disable CA1031 // Do not catch general exception types, we have seen TryParse fault. - try - { - if (decimal.TryParse(f.ToString(CultureInfo.InvariantCulture), out decimal dec)) - writer.WriteNumberValue(dec); - else +#pragma warning disable CA1031 // Do not catch general exception types, we have seen TryParse fault. + try + { + if (decimal.TryParse(f.ToString(CultureInfo.InvariantCulture), out decimal dec)) + writer.WriteNumberValue(dec); + else + writer.WriteNumberValue(f); + } + catch (Exception) + { writer.WriteNumberValue(f); - } - catch (Exception) - { - writer.WriteNumberValue(f); - } - #pragma warning restore CA1031 + } +#pragma warning restore CA1031 #endif else diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs index 89defe3734..0cf3e539b1 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs @@ -108,7 +108,7 @@ public static JsonWebKey Read(ref Utf8JsonReader reader, JsonWebKey jsonWebKey) LogHelper.MarkAsNonPII(reader.CurrentDepth), LogHelper.MarkAsNonPII(reader.BytesConsumed)))); - while(true) + while (true) { #region Check property name using ValueTextEquals // common names are tried first diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs index cca32dd494..f4e64f7bf0 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs @@ -73,7 +73,7 @@ public static JsonWebKeySet Read(ref Utf8JsonReader reader, JsonWebKeySet jsonWe if (propertyName.Equals(JsonWebKeyParameterNames.Keys, StringComparison.OrdinalIgnoreCase)) ReadKeys(ref reader, jsonWebKeySet); else - jsonWebKeySet.AdditionalData[propertyName] = JsonSerializerPrimitives.ReadPropertyValueAsObject(ref reader,JsonWebKeyParameterNames.Keys, JsonWebKeySet.ClassName); + jsonWebKeySet.AdditionalData[propertyName] = JsonSerializerPrimitives.ReadPropertyValueAsObject(ref reader, JsonWebKeyParameterNames.Keys, JsonWebKeySet.ClassName); } } // We read a JsonTokenType.StartObject above, exiting and positioning reader at next token. diff --git a/src/Microsoft.IdentityModel.Tokens/JsonWebKey.cs b/src/Microsoft.IdentityModel.Tokens/JsonWebKey.cs index f6afd42c37..0086ccda18 100644 --- a/src/Microsoft.IdentityModel.Tokens/JsonWebKey.cs +++ b/src/Microsoft.IdentityModel.Tokens/JsonWebKey.cs @@ -486,7 +486,7 @@ internal string RepresentAsAsymmetricPublicJwk() if (string.IsNullOrEmpty(Y)) throw LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(LogMessages.IDX10708, LogHelper.MarkAsNonPII(nameof(Y))))); - return $@"{kid}" + + return $@"{kid}" + $@"""{JsonWebKeyParameterNames.Crv}"":""{Crv}""," + $@"""{JsonWebKeyParameterNames.Kty}"":""{Kty}""," + $@"""{JsonWebKeyParameterNames.X}"":""{X}""," + @@ -500,7 +500,7 @@ internal string RepresentAsAsymmetricPublicJwk() if (string.IsNullOrEmpty(N)) throw LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(LogMessages.IDX10709, LogHelper.MarkAsNonPII(nameof(N))))); - return $@"{kid}" + + return $@"{kid}" + $@"""{JsonWebKeyParameterNames.E}"":""{E}""," + $@"""{JsonWebKeyParameterNames.Kty}"":""{Kty}""," + $@"""{JsonWebKeyParameterNames.N}"":""{N}""}}"; diff --git a/src/Microsoft.IdentityModel.Tokens/JsonWebKeyConverter.cs b/src/Microsoft.IdentityModel.Tokens/JsonWebKeyConverter.cs index 337e94baeb..786d6c1b25 100644 --- a/src/Microsoft.IdentityModel.Tokens/JsonWebKeyConverter.cs +++ b/src/Microsoft.IdentityModel.Tokens/JsonWebKeyConverter.cs @@ -256,7 +256,7 @@ internal static bool TryConvertToSymmetricSecurityKey(JsonWebKey webKey, out Sec key = new SymmetricSecurityKey(webKey); return true; } - catch(Exception ex) + catch (Exception ex) { if (LogHelper.IsEnabled(EventLogLevel.Error)) LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX10813, LogHelper.MarkAsNonPII(typeof(SymmetricSecurityKey)), webKey, ex), ex)); diff --git a/src/Microsoft.IdentityModel.Tokens/RsaCryptoServiceProviderProxy.cs b/src/Microsoft.IdentityModel.Tokens/RsaCryptoServiceProviderProxy.cs index c41d333ee1..58968b471a 100644 --- a/src/Microsoft.IdentityModel.Tokens/RsaCryptoServiceProviderProxy.cs +++ b/src/Microsoft.IdentityModel.Tokens/RsaCryptoServiceProviderProxy.cs @@ -176,7 +176,7 @@ internal byte[] SignData(byte[] input, int offset, int length, object hash) if (input == null || input.Length == 0) throw LogHelper.LogArgumentNullException(nameof(input)); - _ = hash ?? throw LogHelper.LogArgumentNullException(nameof(hash)); + _ = hash ?? throw LogHelper.LogArgumentNullException(nameof(hash)); return _rsa.SignData(input, offset, length, hash); } diff --git a/src/Microsoft.IdentityModel.Tokens/RsaSecurityKey.cs b/src/Microsoft.IdentityModel.Tokens/RsaSecurityKey.cs index f71b8dae69..d3b973ed38 100644 --- a/src/Microsoft.IdentityModel.Tokens/RsaSecurityKey.cs +++ b/src/Microsoft.IdentityModel.Tokens/RsaSecurityKey.cs @@ -128,7 +128,7 @@ public override PrivateKeyStatus PrivateKeyStatus } return _foundPrivateKey; - } + } } /// diff --git a/src/Microsoft.IdentityModel.Tokens/SecurityKeyIdentifierClause.cs b/src/Microsoft.IdentityModel.Tokens/SecurityKeyIdentifierClause.cs index 107c1ecd96..88325db4af 100644 --- a/src/Microsoft.IdentityModel.Tokens/SecurityKeyIdentifierClause.cs +++ b/src/Microsoft.IdentityModel.Tokens/SecurityKeyIdentifierClause.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using Microsoft.IdentityModel.Logging; - namespace Microsoft.IdentityModel.Tokens { /// diff --git a/src/Microsoft.IdentityModel.Tokens/SecurityTokenHandler.cs b/src/Microsoft.IdentityModel.Tokens/SecurityTokenHandler.cs index 1b02a21667..0ba33af73c 100644 --- a/src/Microsoft.IdentityModel.Tokens/SecurityTokenHandler.cs +++ b/src/Microsoft.IdentityModel.Tokens/SecurityTokenHandler.cs @@ -3,7 +3,6 @@ using System; using System.Security.Claims; -using System.Threading.Tasks; using System.Xml; namespace Microsoft.IdentityModel.Tokens diff --git a/src/Microsoft.IdentityModel.Tokens/SymmetricSignatureProvider.cs b/src/Microsoft.IdentityModel.Tokens/SymmetricSignatureProvider.cs index 82b513dcf8..bcc4f4a198 100644 --- a/src/Microsoft.IdentityModel.Tokens/SymmetricSignatureProvider.cs +++ b/src/Microsoft.IdentityModel.Tokens/SymmetricSignatureProvider.cs @@ -3,12 +3,15 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Security.Cryptography; using Microsoft.IdentityModel.Abstractions; using Microsoft.IdentityModel.Logging; +#if NET6_0_OR_GREATER +using System.Diagnostics; +using System.Runtime.CompilerServices; +#endif + namespace Microsoft.IdentityModel.Tokens { /// diff --git a/src/Microsoft.IdentityModel.Tokens/TokenContext.cs b/src/Microsoft.IdentityModel.Tokens/TokenContext.cs index 673846c36a..bc8471fbd4 100644 --- a/src/Microsoft.IdentityModel.Tokens/TokenContext.cs +++ b/src/Microsoft.IdentityModel.Tokens/TokenContext.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; namespace Microsoft.IdentityModel.Tokens { @@ -23,7 +21,7 @@ public TokenContext() : base() /// /// Instantiates a new with an activity ID. /// - public TokenContext(Guid activityId) : base (activityId) + public TokenContext(Guid activityId) : base(activityId) { } } diff --git a/src/Microsoft.IdentityModel.Tokens/TokenUtilities.cs b/src/Microsoft.IdentityModel.Tokens/TokenUtilities.cs index d43c34d910..2817ddd5d6 100644 --- a/src/Microsoft.IdentityModel.Tokens/TokenUtilities.cs +++ b/src/Microsoft.IdentityModel.Tokens/TokenUtilities.cs @@ -250,7 +250,7 @@ internal static IEnumerable MergeClaims(IEnumerable claims, IEnume /// true if the exception is certain types of exceptions otherwise, false. internal static bool IsRecoverableException(Exception exception) { - return exception is SecurityTokenInvalidSignatureException + return exception is SecurityTokenInvalidSignatureException || exception is SecurityTokenInvalidIssuerException || exception is SecurityTokenSignatureKeyNotFoundException; } diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/MessageDetail.cs b/src/Microsoft.IdentityModel.Tokens/Validation/MessageDetail.cs index 800126a725..0282247ec3 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/MessageDetail.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/MessageDetail.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using Microsoft.IdentityModel.Logging; namespace Microsoft.IdentityModel.Tokens diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs b/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs index c064531798..29b118f571 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Security.Claims; -using System.Threading; using Microsoft.IdentityModel.Abstractions; using Microsoft.IdentityModel.Logging; @@ -116,7 +115,8 @@ public ValidationParameters() /// If no delegate is set, the default implementation will be used. The default checks the algorithm /// against the property, if present. If not, it will succeed. /// - public AlgorithmValidatorDelegate AlgorithmValidator { + public AlgorithmValidatorDelegate AlgorithmValidator + { get { return _algorithmValidator; } set { _algorithmValidator = value ?? throw new ArgumentNullException(nameof(value), "AlgorithmValidator cannot be null."); } } diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Algorithm.cs b/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Algorithm.cs index 7cfe70b870..7770374b0f 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Algorithm.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Algorithm.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Microsoft.IdentityModel.Logging; diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Lifetime.cs b/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Lifetime.cs index cc4e4f0abf..1073db2cd3 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Lifetime.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/Validators.Lifetime.cs @@ -86,7 +86,7 @@ internal static LifetimeValidationResult ValidateLifetime(DateTime? notBefore, D LogHelper.MarkAsNonPII(notBefore.Value), LogHelper.MarkAsNonPII(expires.Value)), typeof(SecurityTokenInvalidLifetimeException), - new StackFrame(true))); + new StackFrame(true))); DateTime utcNow = DateTime.UtcNow; if (notBefore.HasValue && (notBefore.Value > DateTimeUtil.Add(utcNow, validationParameters.ClockSkew))) diff --git a/src/Microsoft.IdentityModel.Tokens/Validators.cs b/src/Microsoft.IdentityModel.Tokens/Validators.cs index ab9de078f2..6002eded77 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validators.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validators.cs @@ -74,9 +74,9 @@ public static void ValidateAudience(IEnumerable audiences, SecurityToken LogHelper.FormatInvariant( LogMessages.IDX10231, LogHelper.MarkAsUnsafeSecurityArtifact(securityToken, t => t.ToString()))) - { - InvalidAudience = Utility.SerializeAsSingleCommaDelimitedString(audiences) - }); + { + InvalidAudience = Utility.SerializeAsSingleCommaDelimitedString(audiences) + }); return; } @@ -265,14 +265,14 @@ internal static async ValueTask ValidateIssuerAsync( if (string.IsNullOrWhiteSpace(issuer)) throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidIssuerException(LogMessages.IDX10211) - { InvalidIssuer = issuer }); + { InvalidIssuer = issuer }); // Throw if all possible places to validate against are null or empty - if ( string.IsNullOrWhiteSpace(validationParameters.ValidIssuer) + if (string.IsNullOrWhiteSpace(validationParameters.ValidIssuer) && validationParameters.ValidIssuers.IsNullOrEmpty() && string.IsNullOrWhiteSpace(configuration?.Issuer)) - throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidIssuerException(LogMessages.IDX10204) - { InvalidIssuer = issuer }); + throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidIssuerException(LogMessages.IDX10204) + { InvalidIssuer = issuer }); if (configuration != null) { @@ -319,7 +319,7 @@ internal static async ValueTask ValidateIssuerAsync( LogHelper.MarkAsNonPII(validationParameters.ValidIssuer ?? "null"), LogHelper.MarkAsNonPII(Utility.SerializeAsSingleCommaDelimitedString(validationParameters.ValidIssuers)), LogHelper.MarkAsNonPII(configuration?.Issuer))) - { InvalidIssuer = issuer }; + { InvalidIssuer = issuer }; if (!validationParameters.LogValidationExceptions) throw ex; @@ -444,7 +444,7 @@ public static void ValidateLifetime(DateTime? notBefore, DateTime? expires, Secu { if (!validationParameters.LifetimeValidator(notBefore, expires, securityToken, validationParameters)) throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidLifetimeException(LogHelper.FormatInvariant(LogMessages.IDX10230, securityToken)) - { NotBefore = notBefore, Expires = expires }); + { NotBefore = notBefore, Expires = expires }); return; } diff --git a/src/Microsoft.IdentityModel.Tokens/X509SigningCredentials.cs b/src/Microsoft.IdentityModel.Tokens/X509SigningCredentials.cs index bac2ecb8ac..f66dc5bc4b 100644 --- a/src/Microsoft.IdentityModel.Tokens/X509SigningCredentials.cs +++ b/src/Microsoft.IdentityModel.Tokens/X509SigningCredentials.cs @@ -33,7 +33,7 @@ public X509SigningCredentials(X509Certificate2 certificate) /// if 'certificate' is null. /// if 'algorithm' is null or empty. public X509SigningCredentials(X509Certificate2 certificate, string algorithm) - :base(certificate, algorithm) + : base(certificate, algorithm) { Certificate = certificate; } diff --git a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/AesGcm.cs b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/AesGcm.cs index 05f2bc9cde..b68403c68b 100644 --- a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/AesGcm.cs +++ b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/AesGcm.cs @@ -48,12 +48,12 @@ public void Decrypt(byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintex AesAead.Decrypt(_keyHandle, nonce, associatedData, ciphertext, tag, plaintext, clearPlaintextOnFailure: true); } -#region FOR TESTING ONLY + #region FOR TESTING ONLY internal void Encrypt(byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null) { AesAead.CheckArgumentsForNull(nonce, plaintext, ciphertext, tag); AesAead.Encrypt(_keyHandle, nonce, associatedData, plaintext, ciphertext, tag); } -#endregion + #endregion } } diff --git a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Cng.cs b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Cng.cs index 2feecd8282..a59c940d57 100644 --- a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Cng.cs +++ b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Cng.cs @@ -86,7 +86,7 @@ public static unsafe void Decrypt( } } -#region FOR TESTING ONLY + #region FOR TESTING ONLY internal static unsafe void Encrypt( SafeKeyHandle keyHandle, byte[] nonce, @@ -132,7 +132,7 @@ internal static unsafe void Encrypt( } } } -#endregion + #endregion } internal static class AesBCryptModes diff --git a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Interop.cs b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Interop.cs index ed5e7d629b..a6a851f3a7 100644 --- a/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Interop.cs +++ b/src/Microsoft.IdentityModel.Tokens/opensource/AesGcm/Interop.cs @@ -100,10 +100,10 @@ internal static class BCryptPropertyStrings internal const string BCRYPT_MESSAGE_BLOCK_LENGTH = "MessageBlockLength"; } -#region FOR TESTING ONLY + #region FOR TESTING ONLY [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] public static extern unsafe NTSTATUS BCryptEncrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, [In, Out] byte[] pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); -#endregion + #endregion [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] public static extern unsafe NTSTATUS BCryptDecrypt(SafeKeyHandle hKey, byte* pbInput, int cbInput, IntPtr paddingInfo, [In, Out] byte[] pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags); diff --git a/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/AadIssuerValidator.cs b/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/AadIssuerValidator.cs index 6086810788..a20c1ac4f4 100644 --- a/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/AadIssuerValidator.cs +++ b/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/AadIssuerValidator.cs @@ -13,7 +13,6 @@ using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; -using static Microsoft.IdentityModel.Validators.AadIssuerValidator; namespace Microsoft.IdentityModel.Validators { @@ -71,7 +70,7 @@ internal BaseConfigurationManager ConfigurationManagerV1 { if (_configurationManagerV1 == null) _configurationManagerV1 = CreateConfigManager(AadAuthorityV1); - + return _configurationManagerV1; } @@ -140,7 +139,7 @@ private void SetupAuthorities(string aadAuthority, ProtocolVersion version) AadAuthorityV11 = AadAuthorityV1 + V11EndpointSuffix; AadAuthorityV2 = AadAuthorityV1 + V2EndpointSuffix; break; - + case ProtocolVersion.V11: AadAuthorityV1 = CreateV1Authority(AadAuthority, V11EndpointSuffix); AadAuthorityV11 = aadAuthority; @@ -462,11 +461,11 @@ private static ProtocolVersion GetTokenIssuerVersion(SecurityToken securityToken } private BaseConfigurationManager GetEffectiveConfigurationManager(ProtocolVersion protocolVersion) - { + { if (_configurationManagerProvider != null) { string aadAuthority = GetAuthority(protocolVersion); - + var configurationManager = _configurationManagerProvider(aadAuthority); if (configurationManager != null) diff --git a/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/IssuerLastKnownGood.cs b/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/IssuerLastKnownGood.cs index 8d72f38801..6db7d50c3e 100644 --- a/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/IssuerLastKnownGood.cs +++ b/src/Microsoft.IdentityModel.Validators/AadIssuerValidator/IssuerLastKnownGood.cs @@ -2,12 +2,7 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.IdentityModel.Logging; -using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.Validators { diff --git a/src/Microsoft.IdentityModel.Validators/AadTokenValidationParametersExtension.cs b/src/Microsoft.IdentityModel.Validators/AadTokenValidationParametersExtension.cs index 3278c13630..ff2de23b3d 100644 --- a/src/Microsoft.IdentityModel.Validators/AadTokenValidationParametersExtension.cs +++ b/src/Microsoft.IdentityModel.Validators/AadTokenValidationParametersExtension.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; using System.Linq; -using System.Security.Claims; using Microsoft.IdentityModel.JsonWebTokens; using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -75,8 +74,8 @@ internal static bool ValidateIssuerSigningKey(SecurityKey securityKey, SecurityT if (string.IsNullOrEmpty(tenantIdFromToken)) { if (AppContextSwitches.DontFailOnMissingTid) - return true; - + return true; + throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidIssuerException(LogMessages.IDX40009)); } diff --git a/src/Microsoft.IdentityModel.Xml/CanonicalizingTransform.cs b/src/Microsoft.IdentityModel.Xml/CanonicalizingTransform.cs index 53d0e62894..fcc1669f30 100644 --- a/src/Microsoft.IdentityModel.Xml/CanonicalizingTransform.cs +++ b/src/Microsoft.IdentityModel.Xml/CanonicalizingTransform.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Text; diff --git a/src/Microsoft.IdentityModel.Xml/DsigElement.cs b/src/Microsoft.IdentityModel.Xml/DsigElement.cs index 86b6cad027..77f89e43cf 100644 --- a/src/Microsoft.IdentityModel.Xml/DsigElement.cs +++ b/src/Microsoft.IdentityModel.Xml/DsigElement.cs @@ -1,13 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.IO; -using System.Security.Cryptography; -using System.Xml; -using Microsoft.IdentityModel.Tokens; -using static Microsoft.IdentityModel.Logging.LogHelper; - namespace Microsoft.IdentityModel.Xml { /// diff --git a/src/Microsoft.IdentityModel.Xml/EnvelopedSignatureReader.cs b/src/Microsoft.IdentityModel.Xml/EnvelopedSignatureReader.cs index 4b4bb2fc36..2e7d273711 100644 --- a/src/Microsoft.IdentityModel.Xml/EnvelopedSignatureReader.cs +++ b/src/Microsoft.IdentityModel.Xml/EnvelopedSignatureReader.cs @@ -31,7 +31,7 @@ public EnvelopedSignatureReader(XmlReader reader) throw LogArgumentNullException(nameof(reader)); _tokenStreamReader = new XmlTokenStreamReader(CreateDictionaryReader(reader)); - InnerReader = _tokenStreamReader; + InnerReader = _tokenStreamReader; } /// diff --git a/src/Microsoft.IdentityModel.Xml/Exceptions/XmlReadException.cs b/src/Microsoft.IdentityModel.Xml/Exceptions/XmlReadException.cs index a30794e6ad..e5603ea4f3 100644 --- a/src/Microsoft.IdentityModel.Xml/Exceptions/XmlReadException.cs +++ b/src/Microsoft.IdentityModel.Xml/Exceptions/XmlReadException.cs @@ -17,7 +17,7 @@ public class XmlReadException : XmlException /// public XmlReadException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public XmlReadException() /// Addtional information to be included in the exception and displayed to user. public XmlReadException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public XmlReadException(string message) /// A that represents the root cause of the exception. public XmlReadException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public XmlReadException(string message, Exception innerException) /// The contextual information about the source or destination. protected XmlReadException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Xml/Exceptions/XmlWriteException.cs b/src/Microsoft.IdentityModel.Xml/Exceptions/XmlWriteException.cs index ba8f634be6..517c58d29e 100644 --- a/src/Microsoft.IdentityModel.Xml/Exceptions/XmlWriteException.cs +++ b/src/Microsoft.IdentityModel.Xml/Exceptions/XmlWriteException.cs @@ -17,7 +17,7 @@ public class XmlWriteException : XmlException /// public XmlWriteException() : base() - {} + { } /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public XmlWriteException() /// Addtional information to be included in the exception and displayed to user. public XmlWriteException(string message) : base(message) - {} + { } /// /// Initializes a new instance of the class. @@ -34,7 +34,7 @@ public XmlWriteException(string message) /// A that represents the root cause of the exception. public XmlWriteException(string message, Exception innerException) : base(message, innerException) - {} + { } /// /// Initializes a new instance of the class. @@ -43,6 +43,6 @@ public XmlWriteException(string message, Exception innerException) /// The contextual information about the source or destination. protected XmlWriteException(SerializationInfo info, StreamingContext context) : base(info, context) - {} + { } } } diff --git a/src/Microsoft.IdentityModel.Xml/ExclusiveCanonicalizationTransform.cs b/src/Microsoft.IdentityModel.Xml/ExclusiveCanonicalizationTransform.cs index 65531f1c33..93f270cfba 100644 --- a/src/Microsoft.IdentityModel.Xml/ExclusiveCanonicalizationTransform.cs +++ b/src/Microsoft.IdentityModel.Xml/ExclusiveCanonicalizationTransform.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Xml; diff --git a/src/Microsoft.IdentityModel.Xml/KeyInfo.cs b/src/Microsoft.IdentityModel.Xml/KeyInfo.cs index ee0c78961e..ccca2cb886 100644 --- a/src/Microsoft.IdentityModel.Xml/KeyInfo.cs +++ b/src/Microsoft.IdentityModel.Xml/KeyInfo.cs @@ -55,7 +55,7 @@ public KeyInfo(SecurityKey key) // Obtain parameters from the RSA if the rsaKey does not contain a valid value for RSAParameters if (rsaKey.Parameters.Equals(default(RSAParameters))) rsaParameters = rsaKey.Rsa.ExportParameters(false); - + RSAKeyValue = new RSAKeyValue(Convert.ToBase64String(rsaParameters.Modulus), Convert.ToBase64String(rsaParameters.Exponent)); } } diff --git a/src/Microsoft.IdentityModel.Xml/Reference.cs b/src/Microsoft.IdentityModel.Xml/Reference.cs index e4e0b54dfe..22d26824f7 100644 --- a/src/Microsoft.IdentityModel.Xml/Reference.cs +++ b/src/Microsoft.IdentityModel.Xml/Reference.cs @@ -30,7 +30,6 @@ using System.IO; using System.Security.Cryptography; using System.Xml; -using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Tokens; using static Microsoft.IdentityModel.Logging.LogHelper; using static Microsoft.IdentityModel.Xml.XmlUtil; @@ -203,10 +202,10 @@ protected byte[] ComputeDigest(CryptoProviderFactory cryptoProviderFactory) // see: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-ReferenceProcessingModel // - If the data object is a node-set and the next transform requires octets, the signature application // MUST attempt to convert the node-set to an octet stream using the specified canonicalization algorithm. - for (int i = 0; i < Transforms.Count; i++) + for (int i = 0; i < Transforms.Count; i++) TokenStream = Transforms[i].Process(TokenStream); - - if (CanonicalizingTransfrom == null) + + if (CanonicalizingTransfrom == null) return ProcessAndDigest(TokenStream, hashAlg); // only run canonicalizing transform if it was specified diff --git a/src/Microsoft.IdentityModel.Xml/SignedInfo.cs b/src/Microsoft.IdentityModel.Xml/SignedInfo.cs index ebc64013bc..50c59ccf3a 100644 --- a/src/Microsoft.IdentityModel.Xml/SignedInfo.cs +++ b/src/Microsoft.IdentityModel.Xml/SignedInfo.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Xml; using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Tokens; @@ -67,7 +66,7 @@ public string CanonicalizationMethod if (string.IsNullOrEmpty(value)) throw LogArgumentNullException(nameof(value)); - if (!string.Equals(value,SecurityAlgorithms.ExclusiveC14n) && !string.Equals(value, SecurityAlgorithms.ExclusiveC14nWithComments)) + if (!string.Equals(value, SecurityAlgorithms.ExclusiveC14n) && !string.Equals(value, SecurityAlgorithms.ExclusiveC14nWithComments)) throw LogExceptionMessage(new NotSupportedException(LogHelper.FormatInvariant(LogMessages.IDX30204, LogHelper.MarkAsNonPII(CanonicalizationMethod), LogHelper.MarkAsNonPII(SecurityAlgorithms.ExclusiveC14n), LogHelper.MarkAsNonPII(SecurityAlgorithms.ExclusiveC14nWithComments)))); _canonicalizationMethod = value; diff --git a/src/Microsoft.IdentityModel.Xml/XmlTokenStreamReader.cs b/src/Microsoft.IdentityModel.Xml/XmlTokenStreamReader.cs index 43dfc680aa..826e84f5aa 100644 --- a/src/Microsoft.IdentityModel.Xml/XmlTokenStreamReader.cs +++ b/src/Microsoft.IdentityModel.Xml/XmlTokenStreamReader.cs @@ -102,34 +102,34 @@ private void Record(bool recordSignaturePosition) switch (InnerReader.NodeType) { case XmlNodeType.Element: - { - bool isEmpty = InnerReader.IsEmptyElement; - if (recordSignaturePosition && InnerReader.IsLocalName(XmlSignatureConstants.Elements.Signature) && InnerReader.IsNamespaceUri(XmlSignatureConstants.Namespace)) - TokenStream.SignatureElement = TokenStream.XmlTokens.Count; + { + bool isEmpty = InnerReader.IsEmptyElement; + if (recordSignaturePosition && InnerReader.IsLocalName(XmlSignatureConstants.Elements.Signature) && InnerReader.IsNamespaceUri(XmlSignatureConstants.Namespace)) + TokenStream.SignatureElement = TokenStream.XmlTokens.Count; - TokenStream.AddElement(InnerReader.Prefix, InnerReader.LocalName, InnerReader.NamespaceURI, isEmpty); + TokenStream.AddElement(InnerReader.Prefix, InnerReader.LocalName, InnerReader.NamespaceURI, isEmpty); - if (InnerReader.MoveToFirstAttribute()) - { - do + if (InnerReader.MoveToFirstAttribute()) { - TokenStream.AddAttribute(InnerReader.Prefix, InnerReader.LocalName, InnerReader.NamespaceURI, InnerReader.Value); - } - while (InnerReader.MoveToNextAttribute()); + do + { + TokenStream.AddAttribute(InnerReader.Prefix, InnerReader.LocalName, InnerReader.NamespaceURI, InnerReader.Value); + } + while (InnerReader.MoveToNextAttribute()); InnerReader.MoveToElement(); - } + } - if (!isEmpty) - { - _depth++; - } - else if (_depth == 0) - { - _recordDone = true; - } + if (!isEmpty) + { + _depth++; + } + else if (_depth == 0) + { + _recordDone = true; + } - break; - } + break; + } case XmlNodeType.CDATA: case XmlNodeType.Comment: case XmlNodeType.Text: @@ -137,27 +137,27 @@ private void Record(bool recordSignaturePosition) case XmlNodeType.EndEntity: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Whitespace: - { - TokenStream.Add(InnerReader.NodeType, InnerReader.Value); - break; - } + { + TokenStream.Add(InnerReader.NodeType, InnerReader.Value); + break; + } case XmlNodeType.EndElement: - { - TokenStream.Add(InnerReader.NodeType, InnerReader.Value); - if (--_depth == 0) - _recordDone = true; + { + TokenStream.Add(InnerReader.NodeType, InnerReader.Value); + if (--_depth == 0) + _recordDone = true; - break; - } + break; + } case XmlNodeType.DocumentType: case XmlNodeType.XmlDeclaration: - { - break; - } + { + break; + } default: - { - throw LogExceptionMessage(new XmlException(FormatInvariant(LogMessages.IDX30406, MarkAsNonPII(InnerReader.NodeType)))); - } + { + throw LogExceptionMessage(new XmlException(FormatInvariant(LogMessages.IDX30406, MarkAsNonPII(InnerReader.NodeType)))); + } } } } diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtHeader.cs b/src/System.IdentityModel.Tokens.Jwt/JwtHeader.cs index 54e9fe8b9b..4e04e5da3d 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtHeader.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtHeader.cs @@ -64,7 +64,7 @@ internal JwtHeader(string json) else obj = JsonPrimitives.ReadPropertyValueAsObject(ref reader, propertyName, ClassName); - this[propertyName] = obj; + this[propertyName] = obj; } // We read a JsonTokenType.StartObject above, exiting and positioning reader at next token. else if (JsonPrimitives.IsReaderAtTokenType(ref reader, JsonTokenType.EndObject, true)) @@ -104,7 +104,7 @@ public JwtHeader(EncryptingCredentials encryptingCredentials) /// /// used when creating a JWS Compact JSON. /// provides a mapping for the 'alg' value so that values are within the JWT namespace. - public JwtHeader(SigningCredentials signingCredentials, IDictionary outboundAlgorithmMap) + public JwtHeader(SigningCredentials signingCredentials, IDictionary outboundAlgorithmMap) : this(signingCredentials, outboundAlgorithmMap, null) { } diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtPayload.cs b/src/System.IdentityModel.Tokens.Jwt/JwtPayload.cs index af38253fc8..5464beafa8 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtPayload.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtPayload.cs @@ -464,7 +464,7 @@ public string Nonce /// If the 'notbefore' claim is not found OR could not be converted to , null is returned. public long? NotBefore { - get => GetLongClaim(JwtRegisteredClaimNames.Nbf); + get => GetLongClaim(JwtRegisteredClaimNames.Nbf); } /// diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityToken.cs b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityToken.cs index 51feccc0bc..fe0ee0ae4b 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityToken.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityToken.cs @@ -36,7 +36,7 @@ public JwtSecurityToken(string jwtEncodedString) // Set the maximum number of segments to MaxJwtSegmentCount + 1. This controls the number of splits and allows detecting the number of segments is too large. // For example: "a.b.c.d.e.f.g.h" => [a], [b], [c], [d], [e], [f.g.h]. 6 segments. // If just MaxJwtSegmentCount was used, then [a], [b], [c], [d], [e.f.g.h] would be returned. 5 segments. - string[] tokenParts = jwtEncodedString.Split(new char[] {'.'}, JwtConstants.MaxJwtSegmentCount + 1); + string[] tokenParts = jwtEncodedString.Split(new char[] { '.' }, JwtConstants.MaxJwtSegmentCount + 1); if (tokenParts.Length == JwtConstants.JwsSegmentCount) { if (!JwtTokenUtilities.RegexJws.IsMatch(jwtEncodedString)) @@ -292,7 +292,8 @@ public override string Issuer /// This property can be null if the content type of the most inner token is unrecognized, in that case /// the content of the token is the string returned by PlainText property. /// - public JwtPayload Payload { + public JwtPayload Payload + { get { if (InnerToken != null) @@ -396,7 +397,7 @@ public SigningCredentials SigningCredentials /// public EncryptingCredentials EncryptingCredentials { - get { return Header.EncryptingCredentials; } + get { return Header.EncryptingCredentials; } } /// @@ -446,7 +447,7 @@ public override DateTime ValidTo return DateTime.MinValue; } } - + /// /// Gets the 'value' of the 'issued at' claim { iat, 'value' } converted to a assuming 'value' is seconds since UnixEpoch (UTC 1970-01-01T0:0:0Z). /// diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs index ccdb96a3e3..bad33a8ed9 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs @@ -35,7 +35,7 @@ public class JwtSecurityTokenHandler : SecurityTokenHandler private Dictionary _outboundAlgorithmMap; private static string _shortClaimType = _namespace + "/ShortTypeName"; private bool _mapInboundClaims = DefaultMapInboundClaims; - + /// /// Default claim type mapping for inbound claims. /// @@ -1268,7 +1268,7 @@ public override string WriteToken(SecurityToken token) var header = jwtToken.EncryptingCredentials == null ? jwtToken.Header : new JwtHeader(jwtToken.SigningCredentials); encodedHeader = header.Base64UrlEncode(); if (jwtToken.SigningCredentials != null) - encodedSignature = JwtTokenUtilities.CreateEncodedSignature(string.Concat(encodedHeader, ".", encodedPayload), jwtToken.SigningCredentials); + encodedSignature = JwtTokenUtilities.CreateEncodedSignature(string.Concat(encodedHeader, ".", encodedPayload), jwtToken.SigningCredentials); if (jwtToken.EncryptingCredentials != null) return EncryptToken( diff --git a/src/System.IdentityModel.Tokens.Jwt/LogMessages.cs b/src/System.IdentityModel.Tokens.Jwt/LogMessages.cs index 59ce275cea..388b9bd28f 100644 --- a/src/System.IdentityModel.Tokens.Jwt/LogMessages.cs +++ b/src/System.IdentityModel.Tokens.Jwt/LogMessages.cs @@ -11,7 +11,7 @@ namespace System.IdentityModel.Tokens.Jwt /// internal static class LogMessages { - #pragma warning disable 1591 +#pragma warning disable 1591 // token creation internal const string IDX12401 = "IDX12401: Expires: '{0}' must be after NotBefore: '{1}'."; diff --git a/test/Microsoft.IdentityModel.Abstractions.Tests/TelemetryEventDetailsTests.cs b/test/Microsoft.IdentityModel.Abstractions.Tests/TelemetryEventDetailsTests.cs index 8083ae2789..0bc9450e6c 100644 --- a/test/Microsoft.IdentityModel.Abstractions.Tests/TelemetryEventDetailsTests.cs +++ b/test/Microsoft.IdentityModel.Abstractions.Tests/TelemetryEventDetailsTests.cs @@ -112,7 +112,7 @@ public IReadOnlyDictionary IsPersonalData } } - public override void SetProperty( + public override void SetProperty( string key, string value) { diff --git a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonClaimSetTests.cs b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonClaimSetTests.cs index a481acdc5d..f114fa38a3 100644 --- a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonClaimSetTests.cs +++ b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonClaimSetTests.cs @@ -122,7 +122,7 @@ public static TheoryData GetClaimAsTypeTheoryData() Json = header + "." + payload + ".", PropertyName = "b", PropertyType = typeof(Dictionary), - PropertyValue = new Dictionary {{"prop1", new string[]{"value1","value2"}}} + PropertyValue = new Dictionary { { "prop1", new string[] { "value1", "value2" } } } }); theoryData.Add( @@ -131,7 +131,7 @@ public static TheoryData GetClaimAsTypeTheoryData() Json = header + "." + payload + ".", PropertyName = "a", PropertyType = typeof(Dictionary), - PropertyValue = new Dictionary {{"prop1","value1"}} + PropertyValue = new Dictionary { { "prop1", "value1" } } }); theoryData.Add( @@ -167,7 +167,7 @@ public JsonClaimSetTheoryData(string id) : base(id) { } public Type PropertyOut { get; set; } - public Type PropertyType { get; set; } + public Type PropertyType { get; set; } public object PropertyValue { get; set; } diff --git a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonWebTokenHandler.DecryptTokenTests.cs b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonWebTokenHandler.DecryptTokenTests.cs index 3d4b8dac3f..0b5b8829ca 100644 --- a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonWebTokenHandler.DecryptTokenTests.cs +++ b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonWebTokenHandler.DecryptTokenTests.cs @@ -195,7 +195,7 @@ public static TheoryData JsonWebTokenHandlerDecryptTo TokenString = ReferenceTokens.JWEDirectEncryptionUnsignedInnerJWTWithAdditionalHeaderClaims, ValidationParameters = new ValidationParameters(), ExpectedException = ExpectedException.SecurityTokenDecryptionFailedException("IDX10609:"), - TokenDecryptionResult = new TokenDecryptionResult( + TokenDecryptionResult = new TokenDecryptionResult( new JsonWebToken(ReferenceTokens.JWEDirectEncryptionUnsignedInnerJWTWithAdditionalHeaderClaims), ValidationFailureType.TokenDecryptionFailed, new ExceptionDetail( diff --git a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JwtTokenUtilitiesTests.cs b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JwtTokenUtilitiesTests.cs index e7c649539b..16509cbea4 100644 --- a/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JwtTokenUtilitiesTests.cs +++ b/test/Microsoft.IdentityModel.JsonWebTokens.Tests/JwtTokenUtilitiesTests.cs @@ -19,7 +19,7 @@ public class JwtTokenUtilitiesTests { // Used for formatting a message for testing with one parameter. private const string TestMessageOneParam = "This is the parameter: '{0}'."; - + [Fact] public void LogSecurityArtifactTest() { diff --git a/test/Microsoft.IdentityModel.Logging.Tests/IdentityModelTelemetryUtilTests.cs b/test/Microsoft.IdentityModel.Logging.Tests/IdentityModelTelemetryUtilTests.cs index cb38799767..f2b5b95d3d 100644 --- a/test/Microsoft.IdentityModel.Logging.Tests/IdentityModelTelemetryUtilTests.cs +++ b/test/Microsoft.IdentityModel.Logging.Tests/IdentityModelTelemetryUtilTests.cs @@ -162,8 +162,8 @@ private static HttpRequestMessage BuildHttpRequestMessage(IDictionary string.Format(SafeFormat, obj), - obj => string.Format(UnsafeFormat, obj)); + LogHelper.MarkAsSecurityArtifact(null, + obj => string.Format(SafeFormat, obj), + obj => string.Format(UnsafeFormat, obj)); } [Fact] diff --git a/test/Microsoft.IdentityModel.Logging.Tests/LoggerTests.cs b/test/Microsoft.IdentityModel.Logging.Tests/LoggerTests.cs index c0e6bfede5..2f4ffa6bb7 100644 --- a/test/Microsoft.IdentityModel.Logging.Tests/LoggerTests.cs +++ b/test/Microsoft.IdentityModel.Logging.Tests/LoggerTests.cs @@ -38,7 +38,7 @@ public void EventLevelToEventLogLevelMapping() LogHelper.LogInformation(infoMessage, LogHelper.MarkAsNonPII(arg)); LogHelper.LogVerbose(verboseMessage, LogHelper.MarkAsNonPII(arg)); LogHelper.LogWarning(warnMessage, LogHelper.MarkAsNonPII(arg)); - + Assert.True(logger.ContainsLogOfSpecificLevel("IDX10000:", EventLogLevel.Error)); Assert.True(logger.ContainsLogOfSpecificLevel(string.Format(infoMessage, arg), EventLogLevel.Informational)); Assert.True(logger.ContainsLogOfSpecificLevel(string.Format(verboseMessage, arg), EventLogLevel.Verbose)); @@ -173,7 +173,7 @@ public void TextListenerCantAccessFileToWrite() // default log file cannot be accessed because it is in use. Should throw an IO exception. string fileName = Guid.NewGuid().ToString() + ".txt"; FileStream fileStream = File.Create(fileName); - Assert.Throws(() => { new TextWriterEventListener(fileName); }); + Assert.Throws(() => { new TextWriterEventListener(fileName); }); Assert.Contains("MIML10001: ", listener.TraceBuffer); fileStream.Dispose(); File.Delete(fileName); @@ -244,7 +244,7 @@ public void PrepareMessageWithNoArguments() IdentityModelEventSource.Logger.LogLevel = EventLevel.Error; listener.EnableEvents(IdentityModelEventSource.Logger, EventLevel.Error); - var exception = LogHelper.LogExceptionMessage(new ArgumentException("This is the first parameter '{0}'. This is the second parameter '{1}'.")); + var exception = LogHelper.LogExceptionMessage(new ArgumentException("This is the first parameter '{0}'. This is the second parameter '{1}'.")); } [Theory, MemberData(nameof(LoggerTestTheoryData))] diff --git a/test/Microsoft.IdentityModel.Logging.Tests/PIITests.cs b/test/Microsoft.IdentityModel.Logging.Tests/PIITests.cs index b42bf66ca7..3dae66def8 100644 --- a/test/Microsoft.IdentityModel.Logging.Tests/PIITests.cs +++ b/test/Microsoft.IdentityModel.Logging.Tests/PIITests.cs @@ -182,7 +182,7 @@ public void LogNullArgument() Assert.Contains("Algorithm not supported exception 2: Null", listener.TraceBuffer); } - + [Fact] public void LogExceptionAsArgument() { diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/ConfigurationManagerTests.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/ConfigurationManagerTests.cs index 4fa6f57ca3..d103db30ba 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/ConfigurationManagerTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/ConfigurationManagerTests.cs @@ -676,9 +676,9 @@ public static TheoryData : TheoryDataBase { - public ConfigurationManagerTheoryData() {} + public ConfigurationManagerTheoryData() { } - public ConfigurationManagerTheoryData(string testId) : base(testId) {} + public ConfigurationManagerTheoryData(string testId) : base(testId) { } public TimeSpan AutomaticRefreshInterval { get; set; } diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConfigData.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConfigData.cs index 3de8987f4f..8f7af243a7 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConfigData.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConfigData.cs @@ -227,7 +227,7 @@ public static OpenIdConnectConfiguration AccountsGoogleComConfig UserInfoEndpoint = "https://openidconnect.googleapis.com/v1/userinfo", }; - AddToCollection(config.CodeChallengeMethodsSupported, "plain", "S256"); + AddToCollection(config.CodeChallengeMethodsSupported, "plain", "S256"); AddToCollection(config.ResponseTypesSupported, "code", "id_token", "code id_token"); config.SubjectTypesSupported.Add("public"); config.IdTokenSigningAlgValuesSupported.Add("RS256"); @@ -448,7 +448,7 @@ public static OpenIdConnectConfiguration ObjectConfig "claims_parameter_supported": true, "claims_parameter_Supported": false, "request_parameter_supported": false, - {{IssuerClaim }}, + {{IssuerClaim}}, {{JsonData.ObjectClaim}}, {{JksUriClaim}}, {{JsonData.ArrayClaim}}, @@ -461,7 +461,8 @@ public static OpenIdConnectConfiguration ObjectConfig """; public static OpenIdConnectConfiguration DuplicatesConfig - { get + { + get { OpenIdConnectConfiguration config = new OpenIdConnectConfiguration { diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationRetrieverTests.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationRetrieverTests.cs index a64391ed85..ec9e7b2d58 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationRetrieverTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationRetrieverTests.cs @@ -19,7 +19,7 @@ public async Task FromNetwork() { OpenIdConnectConfiguration configuration = await GetConfigurationFromHttpAsync(OpenIdConfigData.AADCommonUrl, expectedException: ExpectedException.NoExceptionExpected); Assert.NotNull(configuration); - + await GetConfigurationFromHttpAsync(string.Empty, expectedException: ExpectedException.ArgumentNullException()); await GetConfigurationFromHttpAsync(OpenIdConfigData.BadUri, expectedException: ExpectedException.ArgumentException("IDX20108:")); await GetConfigurationFromHttpAsync(OpenIdConfigData.HttpsBadUri, expectedException: ExpectedException.IOException(inner: typeof(HttpRequestException))); @@ -202,7 +202,7 @@ private async Task GetConfigurationFromMixedAsync(st return openIdConnectConfiguration; } - private void GetAndCheckConfiguration(string jsonName, string propertyName, CompareContext context, string propertyValue=null) + private void GetAndCheckConfiguration(string jsonName, string propertyName, CompareContext context, string propertyValue = null) { string jsonValue = propertyValue; if (jsonValue == null) @@ -243,7 +243,7 @@ public TestDocumentRetriever(string primaryDocument, IDocumentRetriever fallback _primaryDocument = primaryDocument; _fallback = fallback; } - + public Task GetDocumentAsync(string address, CancellationToken cancel) { if (string.Equals("primary", address)) diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationTests.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationTests.cs index 87ddf99d3e..d9629abcfe 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationTests.cs @@ -308,7 +308,7 @@ public void RoundTripFromJsonWithStream() [Fact] public void EmptyCollectionSerialization() { - var context = new CompareContext {Title = "EmptyCollectionSerialization"}; + var context = new CompareContext { Title = "EmptyCollectionSerialization" }; // Initialize an OpenIdConnectConfiguration object with all collections empty. var oidcWithEmptyCollections = new OpenIdConnectConfiguration(); var oidcWithEmptyCollectionsJson = OpenIdConnectConfiguration.Write(oidcWithEmptyCollections); @@ -323,7 +323,7 @@ public void EmptyCollectionSerializationWithStream() { using MemoryStream stream = new(); - var context = new CompareContext {Title = "EmptyCollectionSerialization"}; + var context = new CompareContext { Title = "EmptyCollectionSerialization" }; // Initialize an OpenIdConnectConfiguration object with all collections empty. var oidcWithEmptyCollections = new OpenIdConnectConfiguration(); OpenIdConnectConfiguration.Write(oidcWithEmptyCollections, stream); @@ -405,7 +405,7 @@ public void NonemptyCollectionSerializationWithStream() OpenIdConnectConfiguration.Write(oidcWithAllCollections, stream); IdentityComparer.AreBytesEqual(oidcWithAllCollectionsBytes, stream.GetBuffer(), context); - + TestUtilities.AssertFailIfErrors(context); } } diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectMessageTests.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectMessageTests.cs index ee63a5104c..2d4afd4b9a 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectMessageTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectMessageTests.cs @@ -156,7 +156,7 @@ public void Defaults() { List errors = new List(); var message = new OpenIdConnectMessage(); - + if (message.AcrValues != null) errors.Add("message.ArcValues != null"); diff --git a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectProtocolValidationContextTests.cs b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectProtocolValidationContextTests.cs index 3af7b9e4bf..8b99ef4c87 100644 --- a/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectProtocolValidationContextTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectProtocolValidationContextTests.cs @@ -26,8 +26,8 @@ public void GetSets() GetSetContext context = new GetSetContext { - PropertyNamesAndSetGetValue = new List>> - { + PropertyNamesAndSetGetValue = new List>> + { new KeyValuePair>("State", new List{(string)null, "AuthorizationCode", "AuthorizationCode_AuthorizationCode"}), new KeyValuePair>("Nonce", new List{(string)null, "Nonce", "Nonce_Nonce"}), }, diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/PopKeyResolvingTests.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/PopKeyResolvingTests.cs index f5f446358b..157aead84e 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/PopKeyResolvingTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/PopKeyResolvingTests.cs @@ -742,7 +742,7 @@ public static TheoryData ResolvePopKeyFromJkuKidTheoryD } } - [Theory (Skip = "flaky"), MemberData(nameof(GetPopKeysFromJkuAsyncTheoryData))] + [Theory(Skip = "flaky"), MemberData(nameof(GetPopKeysFromJkuAsyncTheoryData))] public async Task GetPopKeysFromJkuAsync(ResolvePopKeyTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.GetPopKeysFromJkuAsync", theoryData); diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestCreationTests.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestCreationTests.cs index a34e43002a..1675a7cafa 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestCreationTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestCreationTests.cs @@ -981,7 +981,7 @@ public void CreateAdditionalClaim(CreateSignedHttpRequestTheoryData theoryData) var handler = new SignedHttpRequestHandler(); var signedHttpRequestDescriptor = theoryData.BuildSignedHttpRequestDescriptor(); - var payloadString = handler.CreateHttpRequestPayload(signedHttpRequestDescriptor, theoryData.CallContext); + var payloadString = handler.CreateHttpRequestPayload(signedHttpRequestDescriptor, theoryData.CallContext); var payload = JObject.Parse(payloadString); if (signedHttpRequestDescriptor.AdditionalPayloadClaims != null) diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestHandlerPublic.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestHandlerPublic.cs index 9952634a61..efdae2a794 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestHandlerPublic.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestHandlerPublic.cs @@ -30,7 +30,7 @@ public void ValidateTsClaimPublic(JsonWebToken jwtSignedHttpRequest, SignedHttpR { ValidateTsClaim(jwtSignedHttpRequest, signedHttpRequestValidationContext); } - + public void ValidateMClaimPublic(JsonWebToken jwtSignedHttpRequest, SignedHttpRequestValidationContext signedHttpRequestValidationContext) { ValidateMClaim(jwtSignedHttpRequest, signedHttpRequestValidationContext); @@ -45,12 +45,12 @@ public void ValidatePClaimPublic(JsonWebToken jwtSignedHttpRequest, SignedHttpRe { ValidatePClaim(jwtSignedHttpRequest, signedHttpRequestValidationContext); } - + public void ValidateQClaimPublic(JsonWebToken jwtSignedHttpRequest, SignedHttpRequestValidationContext signedHttpRequestValidationContext) { ValidateQClaim(jwtSignedHttpRequest, signedHttpRequestValidationContext); } - + public void ValidateHClaimPublic(JsonWebToken jwtSignedHttpRequest, SignedHttpRequestValidationContext signedHttpRequestValidationContext) { ValidateHClaim(jwtSignedHttpRequest, signedHttpRequestValidationContext); @@ -85,7 +85,7 @@ public async Task ResolvePopKeyFromJwePublicAsync(string jwe, JsonW { return await ResolvePopKeyFromJweAsync(jwe, signedHttpRequestValidationContext, cancellationToken).ConfigureAwait(false); } - + internal async Task ResolvePopKeyFromJkuPublicAsync(string jkuSetUrl, Cnf cnf, JsonWebToken signedHttpRequest, JsonWebToken validatedAccessToken, SignedHttpRequestValidationContext signedHttpRequestValidationContext, CancellationToken cancellationToken) { return await ResolvePopKeyFromJkuAsync(jkuSetUrl, cnf, signedHttpRequestValidationContext, cancellationToken).ConfigureAwait(false); @@ -254,7 +254,7 @@ internal override SecurityKey ResolvePopKeyFromJwk(JsonWebKey jwk, SignedHttpReq return null; } - return base.ResolvePopKeyFromJwk(jwk, signedHttpRequestValidationContext); + return base.ResolvePopKeyFromJwk(jwk, signedHttpRequestValidationContext); } internal override async Task ResolvePopKeyFromJweAsync(string jwe, SignedHttpRequestValidationContext signedHttpRequestValidationContext, CancellationToken cancellationToken) diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestTestUtils.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestTestUtils.cs index f86bade886..d926c08b18 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestTestUtils.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestTestUtils.cs @@ -22,7 +22,7 @@ public static class SignedHttpRequestTestUtils internal static string DefaultEncodedAccessTokenWithCnfThumprint = CreateAt(DefaultCnfJwkThumprint, false); - internal static SigningCredentials DefaultSigningCredentials => new SigningCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSha256, SecurityAlgorithms.Sha256){ CryptoProviderFactory = new CryptoProviderFactory()}; + internal static SigningCredentials DefaultSigningCredentials => new SigningCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSha256, SecurityAlgorithms.Sha256) { CryptoProviderFactory = new CryptoProviderFactory() }; internal static EncryptingCredentials DefaultEncryptingCredentials => KeyingMaterial.DefaultSymmetricEncryptingCreds_Aes128_Sha2; @@ -235,7 +235,7 @@ internal static HttpHeaders CreateHttpHeaders(List> using (var client = new HttpClient()) { var headers = client.DefaultRequestHeaders; - foreach(var headerKeyValuePair in headerKeyValuePairs) + foreach (var headerKeyValuePair in headerKeyValuePairs) headers.Add(headerKeyValuePair.Key, headerKeyValuePair.Value); return headers; @@ -257,7 +257,7 @@ internal static HttpRequestMessage CreateHttpRequestMessage(HttpMethod method, U } foreach (var header in headers) - { + { message.Headers.Add(header.Key, header.Value); } diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestUtilityTests.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestUtilityTests.cs index 663d8c0c1b..56cd48a826 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestUtilityTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestUtilityTests.cs @@ -367,15 +367,15 @@ public static TheoryData ToHttpRequestDataAs new SignedHttpRequestUtilityTheoryData { HttpRequestMessage = SignedHttpRequestTestUtils.CreateHttpRequestMessage( - HttpMethod.Get, - new Uri("https://www.contoso.com/"), + HttpMethod.Get, + new Uri("https://www.contoso.com/"), new List>() { new KeyValuePair ("h1", "value1"), new KeyValuePair ("h2", "value2") }, Encoding.UTF8.GetBytes("abcd") - ), + ), ExpectedHttpRequestData = new HttpRequestData() { Method = "GET", diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationContextTests.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationContextTests.cs index 6a09223b28..c3c9e0213e 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationContextTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationContextTests.cs @@ -53,7 +53,7 @@ public void SignedHttpRequestValidationContext() Assert.Equal(tokenValidationParameters, signedHttpRequestDescriptor.AccessTokenValidationParameters); Assert.Equal(callContext, signedHttpRequestDescriptor.CallContext); Assert.NotNull(signedHttpRequestDescriptor.SignedHttpRequestValidationParameters); - + signedHttpRequestDescriptor = new SignedHttpRequestValidationContext(signedHttpRequest, httpRequestData, tokenValidationParameters, validationParameters); Assert.Equal(httpRequestData, signedHttpRequestDescriptor.HttpRequestData); diff --git a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationTests.cs b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationTests.cs index cbac99b92d..1282bee4ed 100644 --- a/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.SignedHttpRequest.Tests/SignedHttpRequestValidationTests.cs @@ -32,7 +32,7 @@ public async void SignedHttpRequestReplayValidation() var signedHttpRequestValidationParameters = new SignedHttpRequestValidationParameters() { - ReplayValidatorAsync = (SecurityToken signedHttpRequest, SignedHttpRequestValidationContext validationContext, CancellationToken cancellationToken) => + ReplayValidatorAsync = (SecurityToken signedHttpRequest, SignedHttpRequestValidationContext validationContext, CancellationToken cancellationToken) => { var jwtSignedHttpRequest = signedHttpRequest as JsonWebToken; @@ -1472,7 +1472,7 @@ public static TheoryData ValidateSignedHttp }, new ValidateSignedHttpRequestTheoryData { - SignedHttpRequestToken = signedHttpRequestWithEncryptedAt, + SignedHttpRequestToken = signedHttpRequestWithEncryptedAt, SignedHttpRequestValidationParameters = new SignedHttpRequestValidationParameters() { ValidateB = false, diff --git a/test/Microsoft.IdentityModel.Protocols.Tests/AuthenticationProtocolMessageTests.cs b/test/Microsoft.IdentityModel.Protocols.Tests/AuthenticationProtocolMessageTests.cs index 61981f4f2f..22099217ec 100644 --- a/test/Microsoft.IdentityModel.Protocols.Tests/AuthenticationProtocolMessageTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.Tests/AuthenticationProtocolMessageTests.cs @@ -53,7 +53,7 @@ public void GetSets() }; var context = new GetSetContext(); - foreach(string property in properties) + foreach (string property in properties) { TestUtilities.SetGet(authenticationProtocolMessage, property, null, ExpectedException.ArgumentNullException(substringExpected: property), context); TestUtilities.SetGet(authenticationProtocolMessage, property, "", ExpectedException.NoExceptionExpected, context); diff --git a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationRetrieverTests.cs b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationRetrieverTests.cs index 2a8789335f..3c8cee087f 100644 --- a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationRetrieverTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationRetrieverTests.cs @@ -22,7 +22,7 @@ public class WsFederationConfigurationRetrieverTests [Theory, MemberData(nameof(ReadMetadataTheoryData))] public void ReadMetadata(WsFederationMetadataTheoryData theoryData) { - var context = TestUtilities.WriteHeader($"{this}.ReadMetadata", theoryData); + var context = TestUtilities.WriteHeader($"{this}.ReadMetadata", theoryData); var configuration = new WsFederationConfiguration(); try @@ -37,7 +37,7 @@ public void ReadMetadata(WsFederationMetadataTheoryData theoryData) var reader = XmlReader.Create(theoryData.MetadataPath); configuration = theoryData.Serializer.ReadMetadata(reader); } - + if (theoryData.SigningKey != null) configuration.Signature.Verify(theoryData.SigningKey, theoryData.SigningKey.CryptoProviderFactory); diff --git a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationValidatorTests.cs b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationValidatorTests.cs index f3610e8ca9..53218a036f 100644 --- a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationValidatorTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationConfigurationValidatorTests.cs @@ -30,7 +30,7 @@ public void ValidateConfiguration(WsFederationConfigurationTheoryData theoryData } try - { + { var result = validator.Validate(configToValidate); theoryData.ExpectedException.ProcessNoException(context); IdentityComparer.AreConfigurationValidationResultEqual(result, theoryData.ExpectedResult, context); diff --git a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationMessageTests.cs b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationMessageTests.cs index fcfe5f7ee5..ca5458d377 100644 --- a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationMessageTests.cs +++ b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationMessageTests.cs @@ -187,7 +187,7 @@ private static void AddWaSignInVariation(IList claims, string variation, QueryString = WsFederationTestUtilities.BuildWaSignInMessage(samlToken, samlSecurityTokenHandler, "saml1" + variation), SecurityToken = samlToken, SecurityTokenHandler = samlSecurityTokenHandler, - TestId = "Saml1WriteToken"+variation + TestId = "Saml1WriteToken" + variation }); theoryData.Add(new WsFederationSigninMessageTheoryData diff --git a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationTestUtilities.cs b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationTestUtilities.cs index 069a69ac24..e2f0377c94 100644 --- a/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationTestUtilities.cs +++ b/test/Microsoft.IdentityModel.Protocols.WsFederation.Tests/WsFederationTestUtilities.cs @@ -13,7 +13,7 @@ namespace Microsoft.IdentityModel.Protocols.WsFederation.Tests { public static class WsFederationTestUtilities { - public static string BuildWaSignInMessage(SecurityToken securityToken, SecurityTokenHandler tokenHandler, string tokenType ) + public static string BuildWaSignInMessage(SecurityToken securityToken, SecurityTokenHandler tokenHandler, string tokenType) { using (var memoryStream = new MemoryStream()) { @@ -21,7 +21,7 @@ public static string BuildWaSignInMessage(SecurityToken securityToken, SecurityT { // writer.WriteStartElement(WsTrustConstants_1_3.PreferredPrefix, WsTrustConstants.Elements.RequestSecurityTokenResponse, WsTrustConstants_1_3.Namespace); - + // writer.WriteStartElement(WsTrustConstants_1_3.PreferredPrefix, WsTrustConstants.Elements.Lifetime, WsTrustConstants.Namespaces.WsTrust1_3); @@ -66,7 +66,7 @@ public static string BuildWaSignInMessage(SecurityToken securityToken, SecurityT writer.Flush(); var rstr = Encoding.UTF8.GetString(memoryStream.ToArray()); - return "wa=wsignin1.0&wresult="+Uri.EscapeDataString(rstr); + return "wa=wsignin1.0&wresult=" + Uri.EscapeDataString(rstr); } } } diff --git a/test/Microsoft.IdentityModel.SampleTests/SampleTokenValidationClass.cs b/test/Microsoft.IdentityModel.SampleTests/SampleTokenValidationClass.cs index 0ed431df97..c325c89db9 100644 --- a/test/Microsoft.IdentityModel.SampleTests/SampleTokenValidationClass.cs +++ b/test/Microsoft.IdentityModel.SampleTests/SampleTokenValidationClass.cs @@ -89,7 +89,7 @@ public void ValidateTokenShim(string token, TokenValidationParameters tokenValid /// Validates the passed token using the instance of the deprecated . /// /// The token to validate. - /// + /// /// The to use instead of the instance's value. /// /// A representing the claims from the passed JWT. diff --git a/test/Microsoft.IdentityModel.TestUtils/ClaimSets.cs b/test/Microsoft.IdentityModel.TestUtils/ClaimSets.cs index 968cb20396..707d1af0b8 100644 --- a/test/Microsoft.IdentityModel.TestUtils/ClaimSets.cs +++ b/test/Microsoft.IdentityModel.TestUtils/ClaimSets.cs @@ -201,9 +201,6 @@ public static ClaimsPrincipal DefaultClaimsPrincipal /// /// Claims containing global Unicode chars. Gleamed from a number of sources. /// - /// - /// - /// public static List GlobalClaims { get; @@ -229,7 +226,7 @@ public static List MultipleAudiences() public static List MultipleAudiences(string issuer, string orignalIssuer) { var claims = new List(); - foreach(var aud in Default.Audiences) + foreach (var aud in Default.Audiences) { claims.Add(new Claim(JwtRegisteredClaimNames.Aud, aud, ClaimValueTypes.String, issuer ?? Default.Issuer, orignalIssuer ?? Default.Issuer)); } @@ -249,18 +246,18 @@ public static List SingleAudience(string issuer, string orignalIssuer) public static List GetDefaultRoles() { - return new List{"role1", "roles1"}; + return new List { "role1", "roles1" }; } public static Dictionary GetDefaultRolePairs() { - return new Dictionary {{"role","role1"},{"roles","roles1"}}; + return new Dictionary { { "role", "role1" }, { "roles", "roles1" } }; } public static List GetDefaultRoleClaims(JwtSecurityTokenHandler handler) { var claims = new List(); - foreach(var kv in GetDefaultRolePairs()) + foreach (var kv in GetDefaultRolePairs()) AddMappedClaim(kv.Key, kv.Value, handler, claims); return claims; @@ -297,7 +294,7 @@ public static List Simple(string issuer, string originalIssuer) public static IEnumerable SimpleShortClaimtypes(string issuer, string originalIssuer) { return new List() - { + { NewClaimWithShortType(ClaimTypes.Country, "USA", ClaimValueTypes.String, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer), NewClaimWithShortType(ClaimTypes.Email, "user@contoso.com", ClaimValueTypes.String, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer), NewClaimWithShortType(ClaimTypes.GivenName, "Tony", ClaimValueTypes.String, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer ), @@ -312,7 +309,7 @@ public static Claim NewClaimWithShortType(string claimType, string claimValue, s return new Claim(JwtSecurityTokenHandler.DefaultOutboundClaimTypeMap.ContainsKey(ClaimTypes.Country) ? JwtSecurityTokenHandler.DefaultOutboundClaimTypeMap[ClaimTypes.Country] : ClaimTypes.Country, claimValue, claimValueType, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer); } - public static IEnumerable ActorClaimNotJwt(string issuer, string originalIssuer ) + public static IEnumerable ActorClaimNotJwt(string issuer, string originalIssuer) { return new List() { @@ -340,14 +337,14 @@ public static IEnumerable DefaultClaimsAsCreatedInPayload() public static IEnumerable AllInboundShortClaimTypes(string issuer, string originalIssuer, IEnumerable extraClaims = null) { - foreach ( KeyValuePair pair in JwtSecurityTokenHandler.DefaultInboundClaimTypeMap ) + foreach (KeyValuePair pair in JwtSecurityTokenHandler.DefaultInboundClaimTypeMap) { - yield return new Claim( pair.Key, pair.Value, ClaimValueTypes.String, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer ); + yield return new Claim(pair.Key, pair.Value, ClaimValueTypes.String, issuer ?? Default.Issuer, originalIssuer ?? Default.OriginalIssuer); } - if ( extraClaims != null ) + if (extraClaims != null) { - foreach ( Claim c in extraClaims ) + foreach (Claim c in extraClaims) { yield return c; } @@ -376,7 +373,7 @@ public static List DuplicateTypes() { return DuplicateTypes(Default.Issuer, Default.Issuer); } - + /// /// Returns an enumeration containing duplicate claims. Used to test duplicates. /// @@ -400,7 +397,7 @@ public static List DuplicateTypes(string issuer, string originalIssuer) }; } - public static List EntityAsJsonClaim( string issuer, string originalIssuer ) + public static List EntityAsJsonClaim(string issuer, string originalIssuer) { return new List { new Claim( @@ -460,9 +457,9 @@ public static Entity Default public string Urn { get; set; } - public long Exp { get; set; } + public long Exp { get; set; } - public double pi { get; set; } + public double pi { get; set; } public string Nothing { get; set; } @@ -478,7 +475,7 @@ public static Entity Default /// public class AuthTime { - public bool Essential { get; set;} + public bool Essential { get; set; } } /// @@ -486,7 +483,7 @@ public class AuthTime /// public class Acr { - public string[] Values{ get; set;} + public string[] Values { get; set; } } /// @@ -508,8 +505,8 @@ public class Address { public string Locality { get; set; } - public string Region { get; set; } + public string Region { get; set; } - public string Country { get; set; } + public string Country { get; set; } } } diff --git a/test/Microsoft.IdentityModel.TestUtils/CompareContext.cs b/test/Microsoft.IdentityModel.TestUtils/CompareContext.cs index 30911717ed..b9dc30bfc6 100644 --- a/test/Microsoft.IdentityModel.TestUtils/CompareContext.cs +++ b/test/Microsoft.IdentityModel.TestUtils/CompareContext.cs @@ -72,7 +72,7 @@ public void AddClaimTypesToIgnoreWhenComparing(params string[] claimTypes) public void AddDictionaryKeysToIgnoreWhenComparing(params string[] keyValues) { - foreach(string keyValue in keyValues) + foreach (string keyValue in keyValues) DictionaryKeysToIgnoreWhenComparing.Add(keyValue); } diff --git a/test/Microsoft.IdentityModel.TestUtils/DerivedTypes.cs b/test/Microsoft.IdentityModel.TestUtils/DerivedTypes.cs index 42c15e81c6..a09e76a924 100644 --- a/test/Microsoft.IdentityModel.TestUtils/DerivedTypes.cs +++ b/test/Microsoft.IdentityModel.TestUtils/DerivedTypes.cs @@ -5,9 +5,7 @@ using System.Security.Cryptography; using Microsoft.IdentityModel.Tokens; -/// -/// Contains derived types that are useful across multiple handlers / protocols. -/// +// Contains derived types that are useful across multiple handlers / protocols. namespace Microsoft.IdentityModel.TestUtils { public class DerivedAuthenticatedEncryptionProvider : AuthenticatedEncryptionProvider diff --git a/test/Microsoft.IdentityModel.TestUtils/ExpectedException.cs b/test/Microsoft.IdentityModel.TestUtils/ExpectedException.cs index 5a2baaadd0..d95be38f45 100644 --- a/test/Microsoft.IdentityModel.TestUtils/ExpectedException.cs +++ b/test/Microsoft.IdentityModel.TestUtils/ExpectedException.cs @@ -41,7 +41,7 @@ public static ExpectedException ArgumentOutOfRangeException(string substringExpe public static ExpectedException ArgumentNullException(string substringExpected = null, Type inner = null) { - return new ExpectedException(typeof(ArgumentNullException), substringExpected, inner); + return new ExpectedException(typeof(ArgumentNullException), substringExpected, inner); } public static ExpectedException CryptographicException(string substringExpected = null, Type inner = null, bool ignoreInnerException = false) @@ -74,8 +74,8 @@ public static ExpectedException XmlException(string substringExpected = null, Ty return new ExpectedException(typeof(XmlException), substringExpected, inner); } - public static ExpectedException NoExceptionExpected - { + public static ExpectedException NoExceptionExpected + { get { return new ExpectedException(); } } @@ -84,12 +84,12 @@ public static ExpectedException NotSupportedException(string substringExpected = return new ExpectedException(typeof(NotSupportedException), substringExpected, inner); } - public static ExpectedException ObjectDisposedException - { - get + public static ExpectedException ObjectDisposedException + { + get { - return new ExpectedException(typeof(ObjectDisposedException)); - } + return new ExpectedException(typeof(ObjectDisposedException)); + } } public void ProcessException(Exception exception, CompareContext context) @@ -157,7 +157,7 @@ public void ProcessException(Exception exception, List errors = null) } if (PropertiesExpected != null && PropertiesExpected.Count > 0) - { + { foreach (KeyValuePair property in PropertiesExpected) { PropertyInfo propertyInfo = TypeExpected.GetProperty(property.Key); @@ -175,7 +175,7 @@ public void ProcessException(Exception exception, List errors = null) HandleError("exception type " + TypeExpected + " does not match the expected property " + property.Key + " type.\nexpected type: " + expectedTypeNonNullable + ", actual type: " + runtimeValue.GetType(), errors); } - if (runtimeValue != property.Value && + if (runtimeValue != property.Value && ((runtimeValue != null && !runtimeValue.Equals(property.Value)) || (property.Value != null && !property.Value.Equals(runtimeValue)))) { @@ -205,7 +205,7 @@ public void ProcessNoException(CompareContext context) context.Diffs.Add("expectedException.TypeExpected != null: " + TypeExpected); } - private static void HandleError(string error, List errors ) + private static void HandleError(string error, List errors) { if (errors != null) errors.Add(error); @@ -278,7 +278,7 @@ public static ExpectedException SecurityTokenInvalidTypeException(string substri public static ExpectedException SecurityTokenNoExpirationException(string substringExpected = null, Type innerTypeExpected = null) { return new ExpectedException(typeof(SecurityTokenNoExpirationException), substringExpected, innerTypeExpected); - } + } public static ExpectedException SecurityTokenNotYetValidException(string substringExpected = null, Type innerTypeExpected = null, Dictionary propertiesExpected = null) { @@ -293,7 +293,7 @@ public static ExpectedException SecurityTokenReplayAddFailed(string substringExp public static ExpectedException SecurityTokenReplayDetected(string substringExpected = null, Type innerTypeExpected = null) { return new ExpectedException(typeof(SecurityTokenReplayDetectedException), substringExpected, innerTypeExpected); - } + } public static ExpectedException SecurityTokenSignatureKeyNotFoundException(string substringExpected = null, Type innerTypeExpected = null) { diff --git a/test/Microsoft.IdentityModel.TestUtils/HttpResponseMessageUtils.cs b/test/Microsoft.IdentityModel.TestUtils/HttpResponseMessageUtils.cs index 731b9757ac..66a71b2ea8 100644 --- a/test/Microsoft.IdentityModel.TestUtils/HttpResponseMessageUtils.cs +++ b/test/Microsoft.IdentityModel.TestUtils/HttpResponseMessageUtils.cs @@ -4,6 +4,7 @@ using System.Net; using System.Net.Http; using System.Text; +using Microsoft.IdentityModel.Protocols; namespace Microsoft.IdentityModel.TestUtils { diff --git a/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs b/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs index 0e8a3ae226..e51826ca2c 100644 --- a/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs +++ b/test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs @@ -1697,7 +1697,7 @@ public static bool AreStringsEqual(object object1, object object2, string name1, if (str1 == null) localContext.Diffs.Add($"({name1} == null, {name2} == {str2}."); - if(str2 == null) + if (str2 == null) localContext.Diffs.Add($"({name1} == {str1}, {name2} == null."); if (!string.Equals(str1, str2, context.StringComparison)) @@ -1924,8 +1924,8 @@ public static bool CompareAllPublicProperties(object obj1, object obj2, CompareC bool skipProperty = false; if (context.PropertiesToIgnoreWhenComparing != null && context.PropertiesToIgnoreWhenComparing.TryGetValue(type, out List propertiesToIgnore)) { - foreach(var val in propertiesToIgnore) - if(string.Equals(val, propertyInfo.Name, StringComparison.OrdinalIgnoreCase)) + foreach (var val in propertiesToIgnore) + if (string.Equals(val, propertyInfo.Name, StringComparison.OrdinalIgnoreCase)) { skipProperty = true; break; diff --git a/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs b/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs index d792573dc6..130d0ab4a7 100644 --- a/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs +++ b/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs @@ -67,7 +67,7 @@ public static JwtSecurityToken CreateJwtSecurityToken(string issuer, string audi { JwtPayload payload = new JwtPayload(issuer, audience, claims, nbf, exp, iat); JwtHeader header = (signingCredentials != null) ? new JwtHeader(signingCredentials) : new JwtHeader(); - return new JwtSecurityToken(header, payload, header.Base64UrlEncode(), payload.Base64UrlEncode(), "" ); + return new JwtSecurityToken(header, payload, header.Base64UrlEncode(), payload.Base64UrlEncode(), ""); } public static string CreateEncodedSaml(SecurityTokenDescriptor tokenDescriptor, SecurityTokenHandler tokenHandler) @@ -77,7 +77,7 @@ public static string CreateEncodedSaml(SecurityTokenDescriptor tokenDescriptor, public static string CreateEncodedSaml2(SecurityTokenDescriptor tokenDescriptor, SecurityTokenHandler tokenHandler) { - return tokenHandler.WriteToken(tokenHandler.CreateToken(tokenDescriptor)); + return tokenHandler.WriteToken(tokenHandler.CreateToken(tokenDescriptor)); } public static string CreateEncodedJwt(SecurityTokenDescriptor tokenDescriptor, SecurityTokenHandler tokenHandler) diff --git a/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs b/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs index 82c0360e0a..eea4435da1 100644 --- a/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs +++ b/test/Microsoft.IdentityModel.TestUtils/MockConfigurationManager.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Protocols; -using Microsoft.IdentityModel.Protocols.Configuration; using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.TestUtils @@ -45,6 +44,7 @@ public MockConfigurationManager(T configuration) : base() /// Initializes an new instance of with a Configuration instance. /// /// Configuration of type OpenIdConnectConfiguration or OpenIdConnectConfiguration. + /// The exception to throw. public MockConfigurationManager(T configuration, Exception exToThrowOnFirstGet) { if (configuration == null) diff --git a/test/Microsoft.IdentityModel.TestUtils/MockHttpMessageHandler.cs b/test/Microsoft.IdentityModel.TestUtils/MockHttpMessageHandler.cs index 3c5489ed68..c772d9818f 100644 --- a/test/Microsoft.IdentityModel.TestUtils/MockHttpMessageHandler.cs +++ b/test/Microsoft.IdentityModel.TestUtils/MockHttpMessageHandler.cs @@ -10,7 +10,7 @@ namespace Microsoft.IdentityModel.TestUtils /// /// A mock . /// - public class MockHttpMessageHandler : HttpMessageHandler + public class MockHttpMessageHandler : HttpMessageHandler { private HttpResponseMessage _httpResponseMessage; private HttpResponseMessage _errorHttpResponseMessageOnFirstSend; @@ -46,8 +46,8 @@ public MockHttpMessageHandler(HttpResponseMessage httpResponseMessage, HttpRespo /// /// protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - if (!_firstSend || _errorHttpResponseMessageOnFirstSend == null) + { + if (!_firstSend || _errorHttpResponseMessageOnFirstSend == null) { return await Task.FromResult(_httpResponseMessage).ConfigureAwait(false); } diff --git a/test/Microsoft.IdentityModel.TestUtils/NotDefault.cs b/test/Microsoft.IdentityModel.TestUtils/NotDefault.cs index 75077cf113..114567c96a 100644 --- a/test/Microsoft.IdentityModel.TestUtils/NotDefault.cs +++ b/test/Microsoft.IdentityModel.TestUtils/NotDefault.cs @@ -73,7 +73,7 @@ public static ClaimsIdentity CaimsIdentity public static string ClaimsIdentityLabel { - get { return Default.ClaimsIdentityLabel.Replace("Default", "NotDefault"); } + get { return Default.ClaimsIdentityLabel.Replace("Default", "NotDefault"); } } public static string Issuer @@ -100,7 +100,7 @@ public static string RoleClaimType { get { return Default.RoleClaimType.Replace("Default", "NotDefault"); } } - + public static EncryptingCredentials SymmetricEncryptionCredentials { get { return new EncryptingCredentials(new SymmetricSecurityKey(KeyingMaterial.SymmetricKeyBytes2_256), "dir", SecurityAlgorithms.Aes128CbcHmacSha256); } diff --git a/test/Microsoft.IdentityModel.TestUtils/ReferenceMetadata.cs b/test/Microsoft.IdentityModel.TestUtils/ReferenceMetadata.cs index ecb68b40dd..02ae9ca34a 100644 --- a/test/Microsoft.IdentityModel.TestUtils/ReferenceMetadata.cs +++ b/test/Microsoft.IdentityModel.TestUtils/ReferenceMetadata.cs @@ -150,7 +150,7 @@ public static WsFederationConfiguration AADCommonEndpoint configuration.KeyInfos.Add(keyInfo3); - foreach(var key in MetadataSigningKeys) + foreach (var key in MetadataSigningKeys) configuration.SigningKeys.Add(key); return configuration; @@ -192,7 +192,7 @@ public static WsFederationConfiguration AADCommonFormated configuration.KeyInfos.Add(keyInfo3); foreach (var key in MetadataSigningKeys) - configuration.SigningKeys.Add(key); + configuration.SigningKeys.Add(key); return configuration; } @@ -344,10 +344,10 @@ public static Reference AADCommonReference { get => new Reference(new EnvelopedSignatureTransform(), new ExclusiveCanonicalizationTransform()) { - DigestMethod = AADCommonMetadataReferenceDigestMethod, - DigestValue = AADCommonMetadataReferenceDigestValue, - TokenStream = new XmlTokenStream(), - Uri = AADCommonMetadataReferenceURI, + DigestMethod = AADCommonMetadataReferenceDigestMethod, + DigestValue = AADCommonMetadataReferenceDigestValue, + TokenStream = new XmlTokenStream(), + Uri = AADCommonMetadataReferenceURI, }; } diff --git a/test/Microsoft.IdentityModel.TestUtils/ReferenceSaml.cs b/test/Microsoft.IdentityModel.TestUtils/ReferenceSaml.cs index c027d08231..411163649e 100644 --- a/test/Microsoft.IdentityModel.TestUtils/ReferenceSaml.cs +++ b/test/Microsoft.IdentityModel.TestUtils/ReferenceSaml.cs @@ -539,7 +539,7 @@ public static SamlAttributeTestSet SamlAttributeValueNull { return new SamlAttributeTestSet { - Attribute = Default.SamlAttributeNoValue, + Attribute = Default.SamlAttributeNoValue, Xml = XmlGenerator.SamlAttributeXml(Default.AttributeName, Default.AttributeNamespace, null) }; } diff --git a/test/Microsoft.IdentityModel.TestUtils/References.cs b/test/Microsoft.IdentityModel.TestUtils/References.cs index 1d3472a3ad..a4f6d5a051 100644 --- a/test/Microsoft.IdentityModel.TestUtils/References.cs +++ b/test/Microsoft.IdentityModel.TestUtils/References.cs @@ -229,7 +229,7 @@ public static byte[] T } } } - + // https://datatracker.ietf.org/doc/html/rfc7518#appendix-A.3 // B.3. Test Cases for AES_256_CBC_HMAC_SHA_512 public static class AES_256_CBC_HMAC_SHA_512 diff --git a/test/Microsoft.IdentityModel.TestUtils/TestSets.cs b/test/Microsoft.IdentityModel.TestUtils/TestSets.cs index dc1dc36d1b..9646c9b1e7 100644 --- a/test/Microsoft.IdentityModel.TestUtils/TestSets.cs +++ b/test/Microsoft.IdentityModel.TestUtils/TestSets.cs @@ -28,7 +28,7 @@ public string TestId } } -#region Saml + #region Saml public class SamlActionTestSet : XmlTestSet { public SamlAction Action { get; set; } @@ -130,7 +130,7 @@ public static TransformTestSet AlgorithmNull get => new TransformTestSet { TestId = nameof(AlgorithmNull), - Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformXml(DSigPrefix, "Algorithm", null, "") }, DSigNS) + Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformXml(DSigPrefix, "Algorithm", null, "") }, DSigNS) }; } @@ -168,7 +168,7 @@ public static TransformTestSet Enveloped_WithNS { TestId = nameof(Enveloped_WithNS), Transform = new EnvelopedSignatureTransform(), - Xml = XmlGenerator.TransformsXml(DSigPrefix,new List { XmlGenerator.TransformXml(DSigPrefix, "Algorithm", SecurityAlgorithms.EnvelopedSignature, DSigNS) }, DSigNS) + Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformXml(DSigPrefix, "Algorithm", SecurityAlgorithms.EnvelopedSignature, DSigNS) }, DSigNS) }; } @@ -178,7 +178,7 @@ public static TransformTestSet Enveloped_WithoutPrefix { TestId = nameof(Enveloped_WithoutPrefix), Transform = new EnvelopedSignatureTransform(), - Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformXml("", "Algorithm", SecurityAlgorithms.EnvelopedSignature, "") }, DSigNS) + Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformXml("", "Algorithm", SecurityAlgorithms.EnvelopedSignature, "") }, DSigNS) }; } @@ -198,7 +198,7 @@ public static TransformTestSet C14n_WithInclusivePrefix { CanonicalizingTransfrom = new ExclusiveCanonicalizationTransform(true) { InclusiveNamespacesPrefixList = "#default saml ds xs xsi" }, TestId = nameof(C14n_WithInclusivePrefix), - Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformWithInclusivePrefixXml(DSigPrefix, "Algorithm", SecurityAlgorithms.ExclusiveC14nWithComments, "", "" ) }, DSigNS) + Xml = XmlGenerator.TransformsXml(DSigPrefix, new List { XmlGenerator.TransformWithInclusivePrefixXml(DSigPrefix, "Algorithm", SecurityAlgorithms.ExclusiveC14nWithComments, "", "") }, DSigNS) }; } @@ -264,7 +264,7 @@ public static TransformTestSet MultipleTransforms(int numberOfTransforms, string for (int i = 0; i < numberOfTransforms; i++) transforms.Add(XmlGenerator.TransformXml(DSigPrefix, "Algorithm", transform, DSigNS)); - return new TransformTestSet + return new TransformTestSet { CanonicalizingTransfrom = canonicalizingTransfrom, TestId = testVariation, @@ -326,7 +326,7 @@ public static KeyInfoTestSet KeyInfoFullyPopulated }; } } - + public static KeyInfoTestSet MalformedCertificate { get @@ -351,7 +351,7 @@ public static KeyInfoTestSet MultipleCertificates { get { - var data = new X509Data(new List { new X509Certificate2(Convert.FromBase64String(Default.CertificateData)), new X509Certificate2(Convert.FromBase64String(Default.CertificateData)) } ); + var data = new X509Data(new List { new X509Certificate2(Convert.FromBase64String(Default.CertificateData)), new X509Certificate2(Convert.FromBase64String(Default.CertificateData)) }); var keyInfo = new KeyInfo(); keyInfo.X509Data.Add(data); return new KeyInfoTestSet @@ -505,7 +505,7 @@ public static KeyInfoTestSet MultipleX509Data { var data1 = new X509Data(new X509Certificate2(Convert.FromBase64String("MIIDBTCCAe2gAwIBAgIQY4RNIR0dX6dBZggnkhCRoDANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MB4XDTE3MDIxMzAwMDAwMFoXDTE5MDIxNDAwMDAwMFowLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMBEizU1OJms31S/ry7iav/IICYVtQ2MRPhHhYknHImtU03sgVk1Xxub4GD7R15i9UWIGbzYSGKaUtGU9lP55wrfLpDjQjEgaXi4fE6mcZBwa9qc22is23B6R67KMcVyxyDWei+IP3sKmCcMX7Ibsg+ubZUpvKGxXZ27YgqFTPqCT2znD7K81YKfy+SVg3uW6epW114yZzClTQlarptYuE2mujxjZtx7ZUlwc9AhVi8CeiLwGO1wzTmpd/uctpner6oc335rvdJikNmc1cFKCK+2irew1bgUJHuN+LJA0y5iVXKvojiKZ2Ii7QKXn19Ssg1FoJ3x2NWA06wc0CnruLsCAwEAAaMhMB8wHQYDVR0OBBYEFDAr/HCMaGqmcDJa5oualVdWAEBEMA0GCSqGSIb3DQEBCwUAA4IBAQAiUke5mA86R/X4visjceUlv5jVzCn/SIq6Gm9/wCqtSxYvifRXxwNpQTOyvHhrY/IJLRUp2g9/fDELYd65t9Dp+N8SznhfB6/Cl7P7F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nKpWlS/PS0uKAdNvLmz1zbGSILdcF+Qf41OozD4QNsS1c9YbDO4vpC9v8x3PVjfJvJwPonzNoOsLXA+8IONSXwCApsnmrwepKu8sifsFYSwgrwxRPGTEAjkdzRJ0yMqiY/VoJ7lqJ/FBJqqAjGPGq/yI9rVoG+mbO1amrIDWHHTKgfbKk0bXGtVUbsayyHR5jSgadmkLBh5AaN/HcgDK/jINrnpiQ+/2ewH/8qLaQ3B"))); - + var keyInfo = new KeyInfo(); keyInfo.X509Data.Add(data1); keyInfo.X509Data.Add(data2); @@ -777,13 +777,13 @@ public static SignatureTestSet UnknownSignatureAlgorithm { Signature = signature, TestId = nameof(UnknownSignatureAlgorithm), - Xml = XmlGenerator.Generate(Default.SignatureNS).Replace(SecurityAlgorithms.RsaSha256Signature, $"_{SecurityAlgorithms.RsaSha256Signature}" ) + Xml = XmlGenerator.Generate(Default.SignatureNS).Replace(SecurityAlgorithms.RsaSha256Signature, $"_{SecurityAlgorithms.RsaSha256Signature}") }; } } public static SignatureTestSet SignatureFullyPopulated - { + { get { var signatureBytes = XmlUtilities.GenerateSignatureBytes(SignedInfoTestSet.SignedInfoFullyPopulated.SignedInfo, Default.AsymmetricSigningKey); @@ -858,31 +858,31 @@ public static SignedInfoTestSet ReferenceDigestValueNotBase64 { get { - var digestValue = Guid.NewGuid().ToString(); - var reference = Default.ReferenceWithNullTokenStreamNS; - reference.DigestValue = digestValue; - var signedInfo = Default.SignedInfoNS; - signedInfo.References.Clear(); - signedInfo.References.Add(reference); - signedInfo.Prefix = ""; - return new SignedInfoTestSet - { - SignedInfo = signedInfo, - TestId = nameof(ReferenceDigestValueNotBase64), - Xml = XmlGenerator.SignedInfoXml( - XmlSignatureConstants.Namespace, + var digestValue = Guid.NewGuid().ToString(); + var reference = Default.ReferenceWithNullTokenStreamNS; + reference.DigestValue = digestValue; + var signedInfo = Default.SignedInfoNS; + signedInfo.References.Clear(); + signedInfo.References.Add(reference); + signedInfo.Prefix = ""; + return new SignedInfoTestSet + { + SignedInfo = signedInfo, + TestId = nameof(ReferenceDigestValueNotBase64), + Xml = XmlGenerator.SignedInfoXml( + XmlSignatureConstants.Namespace, + SecurityAlgorithms.ExclusiveC14n, + SecurityAlgorithms.RsaSha256Signature, + XmlGenerator.ReferenceXml( + Default.ReferencePrefix + ":", + Default.ReferenceId, + Default.ReferenceType, + Default.ReferenceUriWithPrefix, + SecurityAlgorithms.EnvelopedSignature, SecurityAlgorithms.ExclusiveC14n, - SecurityAlgorithms.RsaSha256Signature, - XmlGenerator.ReferenceXml( - Default.ReferencePrefix + ":", - Default.ReferenceId, - Default.ReferenceType, - Default.ReferenceUriWithPrefix, - SecurityAlgorithms.EnvelopedSignature, - SecurityAlgorithms.ExclusiveC14n, - Default.ReferenceDigestMethod, - digestValue)) - }; + Default.ReferenceDigestMethod, + digestValue)) + }; } } @@ -1146,7 +1146,7 @@ public static TransformsTestSet TransformsEmpty } } } - + public class WsFederationMessageTestSet : XmlTestSet { public WsFederationMessage WsFederationMessage diff --git a/test/Microsoft.IdentityModel.TestUtils/TestStub.cs b/test/Microsoft.IdentityModel.TestUtils/TestStub.cs index bc0b042d55..811def29eb 100644 --- a/test/Microsoft.IdentityModel.TestUtils/TestStub.cs +++ b/test/Microsoft.IdentityModel.TestUtils/TestStub.cs @@ -43,7 +43,7 @@ public static TheoryData TestStubTheoryData new TestStubTheoryData { First = true, - TestId = "TestStub1" + TestId = "TestStub1" } }; } diff --git a/test/Microsoft.IdentityModel.TestUtils/TestUtilities.cs b/test/Microsoft.IdentityModel.TestUtils/TestUtilities.cs index c9e0d6739c..55d5b56cfa 100644 --- a/test/Microsoft.IdentityModel.TestUtils/TestUtilities.cs +++ b/test/Microsoft.IdentityModel.TestUtils/TestUtilities.cs @@ -73,8 +73,6 @@ public static void CallAllPublicInstanceAndStaticPropertyGets(object obj, string /// /// Gets a named field on an object /// - /// - /// public static object GetField(object obj, string field) { Type type = obj.GetType(); @@ -85,8 +83,6 @@ public static object GetField(object obj, string field) /// /// Sets a named field on an object /// - /// - /// public static void SetField(object obj, string field, object fieldValue) { Type type = obj.GetType(); @@ -97,9 +93,6 @@ public static void SetField(object obj, string field, object fieldValue) /// /// Gets a named property on an object /// - /// - /// - /// public static object GetProperty(object obj, string property) { Type type = obj.GetType(); @@ -171,10 +164,6 @@ public static void GetSet(GetSetContext context) /// /// Gets and sets a named property on an object. Checks: initial value. /// - /// - /// - /// - /// public static void GetSet(object obj, string property, object initialPropertyValue, object[] setPropertyValues, List errors) { Type type = obj.GetType(); @@ -244,6 +233,7 @@ public static string SerializeAsSingleCommaDelimitedString(IEnumerable s /// the name of the property. /// value to set on the property. /// checks that exception is correct. + /// The context for this call. public static void SetGet(object obj, string property, object propertyValue, ExpectedException expectedException, GetSetContext context) { if (obj == null) diff --git a/test/Microsoft.IdentityModel.TestUtils/ValidationDelegates.cs b/test/Microsoft.IdentityModel.TestUtils/ValidationDelegates.cs index 1170d40822..edb382d863 100644 --- a/test/Microsoft.IdentityModel.TestUtils/ValidationDelegates.cs +++ b/test/Microsoft.IdentityModel.TestUtils/ValidationDelegates.cs @@ -216,7 +216,7 @@ public static bool TokenReplayValidatorChecksExpirationTimeSaml(DateTime? expire if (expires == null) return false; - var samlToken = (SamlSecurityToken) new SamlSecurityTokenHandler().ReadToken(token); + var samlToken = (SamlSecurityToken)new SamlSecurityTokenHandler().ReadToken(token); return samlToken.Assertion.Conditions.NotOnOrAfter == expires; } @@ -225,7 +225,7 @@ public static bool TokenReplayValidatorChecksExpirationTimeSaml2(DateTime? expir if (expires == null) return false; - var saml2Token = (Saml2SecurityToken) new Saml2SecurityTokenHandler().ReadToken(token); + var saml2Token = (Saml2SecurityToken)new Saml2SecurityTokenHandler().ReadToken(token); return saml2Token.Assertion.Conditions.NotOnOrAfter == expires; } diff --git a/test/Microsoft.IdentityModel.TestUtils/XmlGenerator.cs b/test/Microsoft.IdentityModel.TestUtils/XmlGenerator.cs index 6399bbab59..cb56579f1a 100644 --- a/test/Microsoft.IdentityModel.TestUtils/XmlGenerator.cs +++ b/test/Microsoft.IdentityModel.TestUtils/XmlGenerator.cs @@ -415,7 +415,7 @@ public static string TransformTemplate get => "<{0}{1} {2} = \"{3}\" {4} />"; } - public static string TransformXml(string prefix, string attributeName, string algorithm, string @namespace ) + public static string TransformXml(string prefix, string attributeName, string algorithm, string @namespace) { return string.Format(TransformTemplate, prefix, XmlSignatureConstants.Elements.Transform, attributeName, algorithm, @namespace); } diff --git a/test/Microsoft.IdentityModel.TestUtils/XmlUtilities.cs b/test/Microsoft.IdentityModel.TestUtils/XmlUtilities.cs index 53adc14e0c..a6faaefbc6 100644 --- a/test/Microsoft.IdentityModel.TestUtils/XmlUtilities.cs +++ b/test/Microsoft.IdentityModel.TestUtils/XmlUtilities.cs @@ -55,7 +55,7 @@ public static EnvelopedSignatureReader CreateEnvelopedSignatureReader(string xml public static XmlTokenStream CreateXmlTokenStream(string xml) { var xmlTokenStreamReader = new XmlTokenStreamReader(CreateDictionaryReader(xml)); - while (xmlTokenStreamReader.Read()); + while (xmlTokenStreamReader.Read()) ; return xmlTokenStreamReader.TokenStream; } diff --git a/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2SerializerTests.cs b/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2SerializerTests.cs index 400021db07..17751662ca 100644 --- a/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2SerializerTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2SerializerTests.cs @@ -357,7 +357,7 @@ public void ReadAuthorizationDecisionStatement(Saml2TheoryData theoryData) theoryData.ExpectedException.ProcessNoException(); IdentityComparer.AreEqual(statement, theoryData.AuthorizationDecision, context); - + } catch (Exception ex) { @@ -422,7 +422,7 @@ public static TheoryData ReadConditionsTheoryData NotOnOrAfter = DateTime.ParseExact("2017-03-18T18:33:37.080Z", Saml2Constants.AcceptedDateTimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None) }, Xml = @"", - First = true, + First = true, Saml2Serializer = new Saml2SerializerPublic(), TestId = "Saml2ConditionsEmpty" } diff --git a/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2TheoryData.cs b/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2TheoryData.cs index 3214b67841..eef6e370e1 100644 --- a/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2TheoryData.cs +++ b/test/Microsoft.IdentityModel.Tokens.Saml.Tests/Saml2TheoryData.cs @@ -42,7 +42,7 @@ public Saml2TheoryData(TokenTheoryData tokenTheoryData) public Saml2AuthorizationDecisionStatement AuthorizationDecision { get; set; } - public Saml2Conditions Conditions{ get; set; } + public Saml2Conditions Conditions { get; set; } public List ConsolidatedAttributes { get; set; } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/AbstractVirtualsTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/AbstractVirtualsTests.cs index 474c85378b..2e6fd63a22 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/AbstractVirtualsTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/AbstractVirtualsTests.cs @@ -46,7 +46,7 @@ public void SignatureProvider_Sign() } } - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [Fact] public void SignatureProvider_Sign_Offset() { @@ -61,7 +61,7 @@ public void SignatureProvider_Sign_Offset() Assert.Contains("IDX10267: 'public virtual bool Sign(ReadOnlySpan data, Span destination, out int bytesWritten)'", ex.Message); } } - #endif +#endif [Fact] public void SignatureProvider_Verify_Offset() diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/AsymmetricSignatureTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/AsymmetricSignatureTests.cs index d7e5bb50f3..18f25331df 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/AsymmetricSignatureTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/AsymmetricSignatureTests.cs @@ -145,7 +145,7 @@ public static TheoryData SignVerifyTheoryData }, theoryData); - foreach (var certTuple in AsymmetricSignatureTestData.Certificates) + foreach (var certTuple in AsymmetricSignatureTestData.Certificates) AsymmetricSignatureTestData.AddRsaPssAlgorithmVariations(new SignatureProviderTheoryData { SigningKey = new RsaSecurityKey(certTuple.Item1.PrivateKey as RSA), diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/AuthenticatedEncryptionProviderTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/AuthenticatedEncryptionProviderTests.cs index 09c9c30bb6..778e2c976b 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/AuthenticatedEncryptionProviderTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/AuthenticatedEncryptionProviderTests.cs @@ -72,7 +72,7 @@ public void AesGcmEncryptionOnWindows() Assert.Throws(() => new AuthenticatedEncryptionProvider(Default.SymmetricEncryptionKey256, SecurityAlgorithms.Aes256Gcm)); } else - { + { var context = new CompareContext(); try { @@ -309,7 +309,7 @@ public static TheoryData DecryptMismatchTheor var keys128_256 = new List { Default.SymmetricEncryptionKey512, Default.SymmetricEncryptionKey768, Default.SymmetricEncryptionKey1024, Default.SymmetricEncryptionKey256, Default.SymmetricEncryptionKey384 }; for (int i = 0; i < keys128.Count - 1; i++) - for(int j = i + 1; j < keys128.Count; j++) + for (int j = i + 1; j < keys128.Count; j++) AddDecryptMismatchTheoryData( "Test1-" + i.ToString() + "-" + j.ToString(), keys128[i], @@ -414,7 +414,7 @@ public void Dispose(AuthenticatedEncryptionTheoryData theoryData) TestUtilities.AssertFailIfErrors(context); } -#region DisposeTests + #region DisposeTests public static TheoryData DisposeTheoryData() { var theoryData = new TheoryData(); @@ -637,7 +637,7 @@ public static TheoryData DisposeTheoryData() return theoryData; } -#endregion + #endregion [Theory, MemberData(nameof(EncryptDecryptTheoryData))] public void EncryptDecrypt(AuthenticatedEncryptionTheoryData theoryData) @@ -679,9 +679,9 @@ public static TheoryData EncryptDecryptTheory AddEncryptDecryptTheoryData("Test8", SecurityAlgorithms.Aes256CbcHmacSha512, Default.SymmetricEncryptionKey1024, theoryData); // Encrypt parameter checking - AddEncryptParameterCheckTheoryData("Test9", null, new byte[1], theoryData); + AddEncryptParameterCheckTheoryData("Test9", null, new byte[1], theoryData); AddEncryptParameterCheckTheoryData("Test10", new byte[0], new byte[1], theoryData); - AddEncryptParameterCheckTheoryData("Test11", new byte[1], null, theoryData); + AddEncryptParameterCheckTheoryData("Test11", new byte[1], null, theoryData); AddEncryptParameterCheckTheoryData("Test12", new byte[1], new byte[0], theoryData); return theoryData; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoExtensibilityTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoExtensibilityTests.cs index bb7ca2c8b3..8a554efa2d 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoExtensibilityTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoExtensibilityTests.cs @@ -163,7 +163,7 @@ public void DefaultCryptoProviderFactoryGetHashAlgorithm(string algorithm, bool CryptoProviderFactory.Default.CreateHashAlgorithm(algorithm); ee.ProcessNoException(); } - catch(Exception ex) + catch (Exception ex) { ee.ProcessException(ex); } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderCacheTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderCacheTests.cs index 377312c526..6ed0a3d6c8 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderCacheTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderCacheTests.cs @@ -431,6 +431,7 @@ public static TheoryData TryGetSignatureProviderT /// /// Checks that the Dispose() method is properly called on the InMemoryCryptoProviderCache. + /// [Fact] public void CryptoProviderCacheDispose() { @@ -472,7 +473,7 @@ public static TheoryData TryRemoveTheoryData { var cache = CreateCacheForTesting(); - var theoryData = new TheoryData + var theoryData = new TheoryData { new CryptoProviderCacheTheoryData { @@ -529,7 +530,7 @@ public static TheoryData TryRemoveTheoryData SignatureProvider = signatureProvider, TestId = "SignatureProviderRemoved" }); - + // SignatureProvider was removed above, so should not be found theoryData.Add(new CryptoProviderCacheTheoryData { @@ -631,7 +632,7 @@ public void Dispose() public class InMemoryCryptoProviderCachePublic : InMemoryCryptoProviderCache { public InMemoryCryptoProviderCachePublic() : base(new CryptoProviderCacheOptions(), TaskCreationOptions.None, 50) - {} + { } public bool DisposeCalled { get; set; } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderFactoryTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderFactoryTests.cs index 42fbe8c5cf..8c680f7e5f 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderFactoryTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/CryptoProviderFactoryTests.cs @@ -279,7 +279,7 @@ public static TheoryData FaultingAsymmetricSignatur theoryData.Add(new SignatureProviderTheoryData { First = true, - ExpectedException = new EE(typeof(Exception)){IgnoreExceptionType = true}, + ExpectedException = new EE(typeof(Exception)) { IgnoreExceptionType = true }, CryptoProviderFactory = new CustomCryptoProviderFactory(new string[] { ALG.RsaSha256 }) { SigningSignatureProvider = signingSignatureProvider @@ -923,7 +923,7 @@ public void ReferenceCountingTest_Caching() TestUtilities.AssertFailIfErrors(context); } - [Fact (Skip = "too long")] + [Fact(Skip = "too long")] public void ReferenceCountingTest_MultiThreaded() { var context = new CompareContext($"{this}.ReferenceCountingTest_MultiThreaded"); @@ -1105,7 +1105,7 @@ public void ProviderCache_EnsureNoLeakingTasks_SecurityTokenHandler_SymmetricEnc KeyingMaterial.DefaultSymmetricEncryptingCreds_Aes128_Sha2.Key, KeyingMaterial.DefaultSymmetricEncryptingCreds_Aes128_Sha2.Alg, KeyingMaterial.DefaultSymmetricEncryptingCreds_Aes128_Sha2.Enc) - { CryptoProviderFactory = cryptoProviderFactory }); + { CryptoProviderFactory = cryptoProviderFactory }); JwtPayload payload = new JwtPayload("IssuerName", "Audience", testClaims, DateTime.Now.AddHours(-1), DateTime.Now.AddHours(1), DateTime.Now.AddHours(-1)); var token = new JwtSecurityToken(header, payload); @@ -1213,7 +1213,8 @@ private void WaitTillTaskComplete(InMemoryCryptoProviderCache cache, long second /// /// Thread proc that creates and removes providers. /// - /// func creating providers (signing and verifying) + /// The input to the . + /// func creating providers (signing and verifying). private static void ThreadStartProcAddAndRemoveProviders(CryptoProviderFactory factory, CreateProvidersFunc func) { var cache = factory.CryptoProviderCache as InMemoryCryptoProviderCache; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/CustomCryptoProviders.cs b/test/Microsoft.IdentityModel.Tokens.Tests/CustomCryptoProviders.cs index 3db6471a08..af81751b27 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/CustomCryptoProviders.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/CustomCryptoProviders.cs @@ -8,11 +8,8 @@ using System.Threading.Tasks; using Microsoft.IdentityModel.Tokens; - -/// -/// Derived types to simplify testing. -/// Helpful when throwing -/// +// Derived types to simplify testing. +// Helpful when throwing namespace Microsoft.IdentityModel.TestUtils { public class CustomCryptoProvider : ICryptoProvider @@ -33,7 +30,7 @@ public CustomCryptoProvider(string[] supportedAlgorithms) public IList AdditionalHashAlgorithms { get; private set; } = new List(); public HashAlgorithm HashAlgorithm { get; set; } - + public KeyWrapProvider KeyWrapProvider { get; set; } public RsaKeyWrapProvider RsaKeyWrapProvider { get; set; } @@ -49,7 +46,7 @@ public CustomCryptoProvider(string[] supportedAlgorithms) public object Create(string algorithm, params object[] args) { CreateCalled = true; - + if (IsHashAlgorithm(algorithm)) return HashAlgorithm; else @@ -334,8 +331,8 @@ public override bool Verify(byte[] input, byte[] signature) public class CustomSymmetricSignatureProvider : SymmetricSignatureProvider { - public CustomSymmetricSignatureProvider(SecurityKey key, string algorithm, bool willCreateSignatures ) - :base(key, algorithm, willCreateSignatures) + public CustomSymmetricSignatureProvider(SecurityKey key, string algorithm, bool willCreateSignatures) + : base(key, algorithm, willCreateSignatures) { } protected override void Dispose(bool disposing) diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/CustomSecurityKeys.cs b/test/Microsoft.IdentityModel.Tokens.Tests/CustomSecurityKeys.cs index 6b5b552f98..425a70f74d 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/CustomSecurityKeys.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/CustomSecurityKeys.cs @@ -1,14 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Security.Cryptography; using Microsoft.IdentityModel.Tokens; -/// -/// Derived types to simplify testing. -/// Helpful when throwing -/// +// Derived types to simplify testing. +// Helpful when throwing namespace Microsoft.IdentityModel.TestUtils { public class CustomRsaSecurityKey : RsaSecurityKey @@ -38,7 +35,7 @@ public CustomRsaSecurityKey(int keySize, PrivateKeyStatus privateKeyStatus, RSAP public override int KeySize => _keySize; - internal override string InternalId => ""; + internal override string InternalId => ""; } } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/EventBasedLRUCacheTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/EventBasedLRUCacheTests.cs index 58db5173ee..8713c1e81a 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/EventBasedLRUCacheTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/EventBasedLRUCacheTests.cs @@ -49,15 +49,15 @@ public void DoNotRemoveExpiredValues() var context = new CompareContext($"{this}.DoNotRemoveExpiredValues"); var cache = new EventBasedLRUCache(11, removeExpiredValuesIntervalInSeconds: 5, removeExpiredValues: false); for (int i = 0; i <= 10; i++) - cache.SetValue(i, i.ToString(), DateTime.UtcNow + TimeSpan.FromSeconds(5)); + cache.SetValue(i, i.ToString(), DateTime.UtcNow + TimeSpan.FromSeconds(5)); Thread.Sleep(5000); // expired items are not removed by default, so all added items should still be in the cache for (int i = 0; i <= 10; i++) { - if (!cache.Contains(i)) - context.AddDiff("The key value pair {" + i + ", '" + i.ToString() + "'} should remain in the cache, but the Contains() method returned false."); + if (!cache.Contains(i)) + context.AddDiff("The key value pair {" + i + ", '" + i.ToString() + "'} should remain in the cache, but the Contains() method returned false."); } TestUtilities.AssertFailIfErrors(context); @@ -346,7 +346,7 @@ internal bool IsDescending(LinkedList> data) var prev = data.First; var curr = data.First.Next; - while(curr != null) + while (curr != null) { if (prev.Value.Key < curr.Value.Key) { diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/IdentityComparerTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/IdentityComparerTests.cs index 15b0d16fb8..b803c8dc32 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/IdentityComparerTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/IdentityComparerTests.cs @@ -215,7 +215,7 @@ public void CompareJArrays() TestUtilities.WriteHeader($"{this}.CompareJArrays", true); var context = new CompareContext($"{this}.CompareJArrays"); var jArray1 = new JArray { Guid.NewGuid().ToString() }; - var jArray2 = new JArray { Guid.NewGuid().ToString(), Guid.NewGuid().ToString()}; + var jArray2 = new JArray { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; IdentityComparer.AreEqual(jArray1, jArray2, context); Assert.True(context.Diffs.Count(s => s == "Count:") == 1); @@ -399,7 +399,7 @@ public void CompareSamlAssertions() { TestUtilities.WriteHeader($"{this}.CompareSamlAssertions", true); var context = new CompareContext($"{this}.CompareSamlAssertions"); - var samlAssertion1 = new SamlAssertion(Guid.NewGuid().ToString(), Default.Issuer, DateTime.Parse(Default.IssueInstantString), null, new SamlAdvice(), new List { new SamlAttributeStatement(new SamlSubject(), new List { new SamlAttribute("1", "2", "3") } )}); + var samlAssertion1 = new SamlAssertion(Guid.NewGuid().ToString(), Default.Issuer, DateTime.Parse(Default.IssueInstantString), null, new SamlAdvice(), new List { new SamlAttributeStatement(new SamlSubject(), new List { new SamlAttribute("1", "2", "3") }) }); var samlAssertion2 = new SamlAssertion(Guid.NewGuid().ToString(), Default.Issuer, DateTime.Parse(Default.IssueInstantString), null, new SamlAdvice(), new List { new SamlAttributeStatement(new SamlSubject(), new List { new SamlAttribute("1", "2", "3") }) }); IdentityComparer.AreEqual(samlAssertion1, samlAssertion2, context); @@ -480,10 +480,10 @@ public void CompareSamlAuthorizationDecisionStatements() var context = new CompareContext($"{this}.CompareSamlAuthorizationDecisionStatements"); var samlAction = new SamlAction(Guid.NewGuid().ToString()); var samlAttributeStatement1 = - new SamlAuthorizationDecisionStatement(new SamlSubject(), + new SamlAuthorizationDecisionStatement(new SamlSubject(), Guid.NewGuid().ToString(), Default.SamlAccessDecision, new List { samlAction }); var samlAttributeStatement2 = - new SamlAuthorizationDecisionStatement(new SamlSubject(), + new SamlAuthorizationDecisionStatement(new SamlSubject(), Guid.NewGuid().ToString(), Default.SamlAccessDecision, new List { samlAction }); IdentityComparer.AreEqual(samlAttributeStatement1, samlAttributeStatement2, context); @@ -503,7 +503,7 @@ public void CompareSamlSecurityTokens() new SamlAttributeStatement(new SamlSubject(), new List {new SamlAttribute("1", "2", "3")}) })); - var samlSecurityToken2 = + var samlSecurityToken2 = new SamlSecurityToken(new SamlAssertion(Guid.NewGuid().ToString(), Default.Issuer, DateTime.Parse(Default.IssueInstantString), null, new SamlAdvice(), new List @@ -535,8 +535,8 @@ public void CompareSignatures() { TestUtilities.WriteHeader($"{this}.CompareSignatures", true); var context = new CompareContext($"{this}.CompareSignatures"); - var signature1 = new Signature {SignatureValue = Guid.NewGuid().ToString() }; - var signature2 = new Signature {SignatureValue = Guid.NewGuid().ToString()}; + var signature1 = new Signature { SignatureValue = Guid.NewGuid().ToString() }; + var signature2 = new Signature { SignatureValue = Guid.NewGuid().ToString() }; IdentityComparer.AreEqual(signature1, signature2, context); Assert.True(context.Diffs.Count(s => s == "SignatureValue:") == 1); @@ -609,9 +609,9 @@ public void CompareTokenValidationParameters() TestUtilities.WriteHeader($"{this}.CompareTokenValidationParameters", true); var context = new CompareContext($"{this}.CompareTokenValidationParameters"); var tokenValidationParameters1 = - new TokenValidationParameters {AuthenticationType = Guid.NewGuid().ToString()}; + new TokenValidationParameters { AuthenticationType = Guid.NewGuid().ToString() }; var tokenValidationParameters2 = - new TokenValidationParameters() {AuthenticationType = Guid.NewGuid().ToString()}; + new TokenValidationParameters() { AuthenticationType = Guid.NewGuid().ToString() }; IdentityComparer.AreEqual(tokenValidationParameters1, tokenValidationParameters2, context); Assert.True(context.Diffs.Count(s => s == "AuthenticationType:") == 1); diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Json/DataSets.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Json/DataSets.cs index 54a3ad905c..4975aa608b 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Json/DataSets.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Json/DataSets.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; -/// -/// Data sets for testing -/// +// Data sets for testing namespace Microsoft.IdentityModel.Tokens.Json.Tests { public class DataSets @@ -292,7 +290,7 @@ public static JsonWebKey JsonWebKey2 ""use"":""sig"" }"; - public static JsonWebKey JsonWebKeyBadX509Data + public static JsonWebKey JsonWebKeyBadX509Data { get { diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonData.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonData.cs index 7c2c11767f..f1fe4a5c31 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonData.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonData.cs @@ -26,7 +26,7 @@ public static class JsonData // Claim - the name:value pair, that can be inserted into a Json object: string jsonboject = $$"""{{{ArrayClaim}}}"""; // Object - the Claim is wrapped inside an object, simplifies wrting tests that read the json, // otherwise each test would have to write: string jsonString = $$"""{{{ArrayClaim}}}"""; - public static string ArrayStrings= + public static string ArrayStrings = """ "arrayValue", "arrayValue" """; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerPrimitivesTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerPrimitivesTests.cs index 26a7cf4d34..8deea5edd3 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerPrimitivesTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerPrimitivesTests.cs @@ -43,7 +43,7 @@ public void RoundTripObjects(JsonSerializerTheoryData theoryData) IdentityComparer.AreEqual(obj, theoryData.ReadObject, context); theoryData.ExpectedException.ProcessNoException(context); } - catch(Exception ex) + catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } @@ -70,7 +70,7 @@ public static TheoryData RoundTripObjectsTheoryData DateTime dateTime = DateTime.UtcNow; AddFloatDoubleVariations(theoryData); - AddListVariations(new List{"string1", "string2"}, theoryData); + AddListVariations(new List { "string1", "string2" }, theoryData); AddMinMaxVariations(DateTime.MaxValue, DateTime.MinValue, dateTime, theoryData); AddMinMaxVariations(float.MaxValue, float.MinValue, (float)0, theoryData); AddMinMaxVariations(double.MaxValue, double.MinValue, (double)0, theoryData); @@ -95,25 +95,25 @@ public static TheoryData RoundTripObjectsTheoryData theoryData.Add(new JsonSerializerTheoryData("Dictionary_object_object>") { - Object = new Dictionary{{"string1", "value1"}}, + Object = new Dictionary { { "string1", "value1" } }, ReadObject = jsonElement }); theoryData.Add(new JsonSerializerTheoryData("Dictionary_string_string") { - Object = new Dictionary{{"string1", "value1"}}, + Object = new Dictionary { { "string1", "value1" } }, ReadObject = jsonElement }); theoryData.Add(new JsonSerializerTheoryData("IDictionary_string_string") { - Object = new Dictionary{{"string1", "value1"}} as IDictionary, + Object = new Dictionary { { "string1", "value1" } } as IDictionary, ReadObject = jsonElement }); theoryData.Add(new JsonSerializerTheoryData("Dictionary_object_string>") { - Object = new Dictionary{{"string1","value1"}}, + Object = new Dictionary { { "string1", "value1" } }, ReadObject = jsonElement }); #endregion @@ -122,19 +122,19 @@ public static TheoryData RoundTripObjectsTheoryData // objects embeded in a dictionary or list theoryData.Add(new JsonSerializerTheoryData("Dictionary_Guid") { - Object = new Dictionary{{"key1", new Dictionary{{"guid", guid}}}}, + Object = new Dictionary { { "key1", new Dictionary { { "guid", guid } } } }, ReadObject = JsonUtilities.CreateJsonElement($$$"""{"key1":{"guid":"{{{guid.ToString()}}}"}}""") }); theoryData.Add(new JsonSerializerTheoryData("Dictionary_Dictionary_List_string") { - Object = new Dictionary{{"key1", new Dictionary{{"key2", new List {"string1", "string2"}}}}}, + Object = new Dictionary { { "key1", new Dictionary { { "key2", new List { "string1", "string2" } } } } }, ReadObject = JsonUtilities.CreateJsonElement("""{"key1":{"key2":["string1","string2"]}}""") }); theoryData.Add(new JsonSerializerTheoryData("List_Dictionary_String_List_String}") { - Object = new List{"list",new Dictionary{{"string1", "string2"}},new List{"string3", "string4"}}, + Object = new List { "list", new Dictionary { { "string1", "string2" } }, new List { "string3", "string4" } }, ReadObject = JsonUtilities.CreateJsonElement("""["list",{"string1":"string2"},["string3","string4"]]""") }); @@ -146,7 +146,7 @@ public static TheoryData RoundTripObjectsTheoryData """; theoryData.Add(new JsonSerializerTheoryData("ListWithPrimitiveTypes") { - Object = new List{"string1", guid, int.MaxValue, long.MaxValue, true, double.MaxValue, null, decimal.MaxValue }, + Object = new List { "string1", guid, int.MaxValue, long.MaxValue, true, double.MaxValue, null, decimal.MaxValue }, ReadObject = JsonUtilities.CreateJsonElement(jsonElementString) }); #else @@ -169,7 +169,7 @@ public static TheoryData RoundTripObjectsTheoryData private static void AddListVariations(List strings, TheoryData theoryData) { string jsonElementString = "["; - for (int i = 0; i < strings.Count -1; i++) + for (int i = 0; i < strings.Count - 1; i++) jsonElementString += $@"""{strings[i]}"","; jsonElementString += $@"""{strings[strings.Count - 1]}""]"; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerTheoryData.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerTheoryData.cs index 8aa1299a21..ea6e3a9f27 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerTheoryData.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerTheoryData.cs @@ -20,7 +20,7 @@ public JsonSerializerTheoryData(string testId) : base(testId) public ExpectedException JsonSerializerExpectedException { get; set; } = ExpectedException.NoExceptionExpected; - public string PropertyName { get; set; } + public string PropertyName { get; set; } public object Object { get; set; } } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonUtilities.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonUtilities.cs index ecba2a32ce..0649ecf303 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonUtilities.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonUtilities.cs @@ -245,7 +245,7 @@ public static string SetAdditionalDataKeysToUpperCase(string json, JsonWebKey js return json; } - public static void SetAdditionalDataKeysToUpperCase(IDictionary additionalData) + public static void SetAdditionalDataKeysToUpperCase(IDictionary additionalData) { List keys = [.. additionalData.Keys]; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyConverterTest.cs b/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyConverterTest.cs index e6d09746c0..76a777cb71 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyConverterTest.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyConverterTest.cs @@ -24,7 +24,7 @@ public void ConvertSecurityKeyToJsonWebKey(JsonWebKeyConverterTheoryData theoryD if (convertedKey.ConvertedSecurityKey.GetType() != theoryData.SecurityKey.GetType()) context.AddDiff($"theoryData.JsonWebKey.RelatedSecurityKey.GetType(): '{theoryData.JsonWebKey.ConvertedSecurityKey.GetType()}' != theoryData.SecurityKey.GetType(): '{theoryData.SecurityKey.GetType()}'."); } - catch(Exception ex) + catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } @@ -95,7 +95,7 @@ public static TheoryData ConvertSecurityKeyToJson public static TheoryData ConvertToJsonWebKeyToSecurityKeyTheoryData { - get + get { return ConversionKeyTheoryData; } @@ -159,10 +159,10 @@ public static TheoryData ConversionKeyTheoryData { SecurityKey = KeyingMaterial.Ecdsa256Key_Public, JsonWebKey = KeyingMaterial.CreateJsonWebKeyEC( - JsonWebKeyECTypes.P256, + JsonWebKeyECTypes.P256, KeyingMaterial.Ecdsa256Key_Public.KeyId, null, - Base64UrlEncoder.Encode(KeyingMaterial.Ecdsa256Parameters_Public.Q.X), + Base64UrlEncoder.Encode(KeyingMaterial.Ecdsa256Parameters_Public.Q.X), Base64UrlEncoder.Encode(KeyingMaterial.Ecdsa256Parameters_Public.Q.Y) ), TestId = nameof(KeyingMaterial.Ecdsa256Key_Public) diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyTests.cs index 436663c534..6d9f9886d5 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/JsonWebKeyTests.cs @@ -338,7 +338,7 @@ public static TheoryData ComputeJwkThumbprintTheoryData TestId = "ValidRsa" }, new JwkThumbprintTheoryData - { + { JWK = new JsonWebKey() { Kty = JsonWebAlgorithmsKeyTypes.EllipticCurve, diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/JweUsingEchdTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/JweUsingEchdTests.cs index ccded87693..161834b4ad 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/JweUsingEchdTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/JweUsingEchdTests.cs @@ -88,7 +88,7 @@ public static TheoryData CreateEcdhEsTestcases theoryData.Add(EcdhEsCurveP256AEnc256KWNullApuApv()); theoryData.Add(EcdhEsCurveP384EncA256KW()); theoryData.Add(EcdhEsCurveP512EncA256KW()); - theoryData.Add(EcdhEsCurveP256EncA192KW()); + theoryData.Add(EcdhEsCurveP256EncA192KW()); theoryData.Add(EcdhEsCurveP256EncA128KW()); return theoryData; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/KeyVaultVerify.cs b/test/Microsoft.IdentityModel.Tokens.Tests/KeyVaultVerify.cs index 6d27b0aa9f..62ac0781ce 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/KeyVaultVerify.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/KeyVaultVerify.cs @@ -111,7 +111,7 @@ public class KeyWrapTestParams public override string ToString() { - return TestId + ", " + Algorithm + ", " + Key.KeyId; + return TestId + ", " + Algorithm + ", " + Key.KeyId; } } } diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/ReferenceTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/ReferenceTests.cs index 57b25b2d7d..56b4de05da 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/ReferenceTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/ReferenceTests.cs @@ -46,7 +46,7 @@ public void ECDH_ESReferenceTest() // assert // compare KDFs are the same and they're matching with expected - if (!Utility.AreEqual(((SymmetricSecurityKey)aliceCek).Key, ((SymmetricSecurityKey)bobCek).Key)) + if (!Utility.AreEqual(((SymmetricSecurityKey)aliceCek).Key, ((SymmetricSecurityKey)bobCek).Key)) context.AddDiff($"!Utility.AreEqual(aliceCek, bobCek)"); if (!Utility.AreEqual(((SymmetricSecurityKey)aliceCek).Key, ECDH_ES.DerivedKeyBytes)) context.AddDiff($"!Utility.AreEqual(aliceCek, ECDH_ES.DerivedKeyBytes)"); diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/SecurityTokenExceptionTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/SecurityTokenExceptionTests.cs index e1d6d77cb9..11bba38b64 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/SecurityTokenExceptionTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/SecurityTokenExceptionTests.cs @@ -234,7 +234,7 @@ public static TheoryData ExceptionTestData #pragma warning restore CS0618 // Type or member is obsolete }; } - } + } } public class SecurityTokenExceptionTheoryData : TheoryDataBase diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/SignatureProviderTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/SignatureProviderTests.cs index 4f23ffbafd..f30a601628 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/SignatureProviderTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/SignatureProviderTests.cs @@ -265,7 +265,7 @@ public static TheoryData SymmetricSignAndVerifyTheo new SignatureProviderTheoryData("SymmetricSecurityKey10", ALG.RsaSha256Signature, ALG.RsaSha512Signature, KEY.SymmetricSecurityKey2_256, KEY.SymmetricSecurityKey2_256, EE.NotSupportedException("IDX10634:")), new SignatureProviderTheoryData("SymmetricSecurityKey11", ALG.HmacSha256Signature, ALG.HmacSha256Signature, KEY.DefaultSymmetricSecurityKey_256, KEY.DefaultSymmetricSecurityKey_256), new SignatureProviderTheoryData("SymmetricSecurityKey12", - ALG.HmacSha256Signature, + ALG.HmacSha256Signature, ALG.HmacSha256Signature, new FaultingSymmetricSecurityKey(Default.SymmetricSigningKey256, new CryptographicException("Inner CryptographicException"), null, null, Default.SymmetricSigningKey256.Key), KEY.SymmetricSecurityKey2_256, @@ -341,7 +341,7 @@ private void SignatureProvider_DisposeVariation(string testCase, SignatureProvid expectedException.ProcessNoException(); } - catch(Exception ex) + catch (Exception ex) { expectedException.ProcessException(ex); } @@ -628,7 +628,7 @@ public void SymmetricVerify4Tests(SignatureProviderTheoryData theoryData) TestUtilities.AssertFailIfErrors(context); } - + public static TheoryData SymmetricVerifySignatureSizeInternalTheoryData { get @@ -869,7 +869,7 @@ private void AsymmetricProviderDispose(string testId, SecurityKey securityKey, s ee.ProcessNoException(); } - catch(Exception ex) + catch (Exception ex) { ee.ProcessException(ex); } @@ -943,10 +943,10 @@ public void SignatureTampering(SignatureProviderTheoryData theoryData) { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - Console.WriteLine("OSX is excluded as the SignatureTampering test is slow (~6 minutes).") ; + Console.WriteLine("OSX is excluded as the SignatureTampering test is slow (~6 minutes)."); } else - { + { TestUtilities.WriteHeader($"{this}.SignatureTampering", theoryData); var copiedSignature = theoryData.Signature.CloneByteArray(); for (int i = 0; i < theoryData.Signature.Length; i++) @@ -1527,7 +1527,7 @@ public SignTheoryData(string testId) : base(testId) { } public class SignatureProvider2K : SignatureProvider { - public SignatureProvider2K(SecurityKey key, string algorithm):base(key, algorithm){} + public SignatureProvider2K(SecurityKey key, string algorithm) : base(key, algorithm) { } public override byte[] Sign(byte[] input) => new byte[2048]; diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/SupportedAlgorithmTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/SupportedAlgorithmTests.cs index 4a207eb9bc..9ec12420e6 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/SupportedAlgorithmTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/SupportedAlgorithmTests.cs @@ -13,7 +13,7 @@ public class SupportedAlgorithmTests { /// /// This test ensures that: - /// 1. CryptoProviderFactory.IsSupportedAlgorithm && SecurityKey.IsSupportedAlgorithm have same logic. + /// 1. CryptoProviderFactory.IsSupportedAlgorithm && SecurityKey.IsSupportedAlgorithm have same logic. /// 2. Our default algorithms are supported. /// /// @@ -29,7 +29,7 @@ public void IsSupportedAlgorithmAndKey(SupportedAlgorithmTheoryData theoryData) theoryData.ExpectedException.ProcessNoException(context); } - catch(Exception ex) + catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } @@ -131,7 +131,7 @@ public static TheoryData IsSupportedAlgorithmAndKe theoryData); // SymmetricSecurityKey - foreach(var alg in SupportedAlgorithms.SymmetricEncryptionAlgorithms) + foreach (var alg in SupportedAlgorithms.SymmetricEncryptionAlgorithms) SupportedAlgorithmTheoryData.AddTestCase(alg, KeyingMaterial.DefaultSymmetricSecurityKey_256, true, $"Symmetric_{alg}", theoryData); foreach (var alg in SupportedAlgorithms.SymmetricKeyWrapAlgorithms) diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/TokenValidationParametersTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/TokenValidationParametersTests.cs index 920f801ee5..38ab7b0af7 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/TokenValidationParametersTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/TokenValidationParametersTests.cs @@ -265,7 +265,7 @@ public void Clone() var compareContext = new CompareContext(); TokenValidationParameters validationParameters = CreateTokenValidationParameters(); - + compareContext.PropertiesToIgnoreWhenComparing.Add(typeof(TokenValidationParameters), new List { "InstancePropertyBag", "IsClone" }); TokenValidationParameters validationParametersClone = validationParameters.Clone(); IdentityComparer.AreEqual(validationParametersClone, validationParameters, compareContext); diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs index 43a6d3e313..f8519cf748 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/SigningKeyValidationResultTests.cs @@ -318,16 +318,16 @@ public static TheoryData SigningKeyValidationTes new SecurityTokenInvalidSigningKeyException())) }, }; - } } } + } - public class SigningKeyValidationTheoryData: TheoryDataBase - { - public SecurityKey SecurityKey { get; set; } - public SecurityToken SecurityToken { get; set; } - public TokenValidationParameters ValidationParameters { get; set; } - public BaseConfiguration BaseConfiguration { get; set; } - internal SigningKeyValidationResult SigningKeyValidationResult { get; set; } - } + public class SigningKeyValidationTheoryData : TheoryDataBase + { + public SecurityKey SecurityKey { get; set; } + public SecurityToken SecurityToken { get; set; } + public TokenValidationParameters ValidationParameters { get; set; } + public BaseConfiguration BaseConfiguration { get; set; } + internal SigningKeyValidationResult SigningKeyValidationResult { get; set; } } +} diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/TokenTypeValidationResultTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/TokenTypeValidationResultTests.cs index 79dd4fce77..a93b8d9243 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/TokenTypeValidationResultTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/TokenTypeValidationResultTests.cs @@ -43,7 +43,7 @@ public static TheoryData TokenTypeValidationTestCases get { String[] validTypesNoJwt = { "ID Token", "Refresh Token", "Access Token" }; - String[] validTypesWithJwt = { "ID Token", "Refresh Token", "Access Token", "JWT" }; + String[] validTypesWithJwt = { "ID Token", "Refresh Token", "Access Token", "JWT" }; return new TheoryData { diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidatorsTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidatorsTests.cs index 181c05e926..cf3944eaf8 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidatorsTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidatorsTests.cs @@ -361,14 +361,14 @@ public void Lifetime(DateTime? notBefore, DateTime? expires, SecurityToken secur dataset.Add(DateTime.UtcNow - TimeSpan.FromHours(2), DateTime.UtcNow + TimeSpan.FromHours(1), null, new TokenValidationParameters(), ExpectedException.NoExceptionExpected); // clock skew, positive then negative - dataset.Add(DateTime.UtcNow + TimeSpan.FromMinutes(2), DateTime.UtcNow + TimeSpan.FromHours(1), null, new TokenValidationParameters{ ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.NoExceptionExpected); - dataset.Add(DateTime.UtcNow - TimeSpan.FromMinutes(2), DateTime.UtcNow - TimeSpan.FromMinutes(1), null, new TokenValidationParameters{ ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.NoExceptionExpected); + dataset.Add(DateTime.UtcNow + TimeSpan.FromMinutes(2), DateTime.UtcNow + TimeSpan.FromHours(1), null, new TokenValidationParameters { ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.NoExceptionExpected); + dataset.Add(DateTime.UtcNow - TimeSpan.FromMinutes(2), DateTime.UtcNow - TimeSpan.FromMinutes(1), null, new TokenValidationParameters { ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.NoExceptionExpected); notBefore = EpochTime.DateTime(EpochTime.GetIntDate((DateTime.UtcNow + TimeSpan.FromMinutes(6)).ToUniversalTime())); expires = EpochTime.DateTime(EpochTime.GetIntDate((DateTime.UtcNow + TimeSpan.FromHours(1)).ToUniversalTime())); - dataset.Add(notBefore, expires, null, new TokenValidationParameters{ ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.SecurityTokenNotYetValidException("IDX10222:", propertiesExpected: new Dictionary { { "NotBefore", notBefore } })); + dataset.Add(notBefore, expires, null, new TokenValidationParameters { ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.SecurityTokenNotYetValidException("IDX10222:", propertiesExpected: new Dictionary { { "NotBefore", notBefore } })); - dataset.Add(DateTime.UtcNow - TimeSpan.FromHours(2), DateTime.UtcNow - TimeSpan.FromMinutes(6), null, new TokenValidationParameters{ ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.SecurityTokenExpiredException("IDX10223:")); + dataset.Add(DateTime.UtcNow - TimeSpan.FromHours(2), DateTime.UtcNow - TimeSpan.FromMinutes(6), null, new TokenValidationParameters { ClockSkew = TimeSpan.FromMinutes(5) }, ExpectedException.SecurityTokenExpiredException("IDX10223:")); return dataset; } diff --git a/test/Microsoft.IdentityModel.Validators.Tests/MicrosoftIdentityIssuerValidatorTest.cs b/test/Microsoft.IdentityModel.Validators.Tests/MicrosoftIdentityIssuerValidatorTest.cs index b747c65338..908ae78870 100644 --- a/test/Microsoft.IdentityModel.Validators.Tests/MicrosoftIdentityIssuerValidatorTest.cs +++ b/test/Microsoft.IdentityModel.Validators.Tests/MicrosoftIdentityIssuerValidatorTest.cs @@ -816,7 +816,7 @@ public void Validate_CanFetchMetadataWithoutConfigurationProvider(ProtocolVersio return ValidatorConstants.AuthorityV1PPE; }; - + var context = new CompareContext(); var tidClaim = new Claim(ValidatorConstants.ClaimNameTid, ValidatorConstants.TenantIdAsGuid); @@ -826,7 +826,7 @@ public void Validate_CanFetchMetadataWithoutConfigurationProvider(ProtocolVersio var authority = authorityUrlProvider(authorityVersion); var aadIssuerValidator = AadIssuerValidator.GetAadIssuerValidator(authority, _httpClient); - + // set LKG var actualIssuer = aadIssuerValidator.Validate(issuer, jwtSecurityToken, new TokenValidationParameters()); IdentityComparer.AreEqual(issuer, actualIssuer, context); @@ -893,7 +893,7 @@ public void Validate_UsesLKGWithConfigurationProvider() IdentityComparer.AreEqual(v2TokenIssuer, actualIssuer, context); TestUtilities.AssertFailIfErrors(context); - + // refresh config to a one with a broken issuer and validate with LKG v2ConfigurationManager.RefreshedConfiguration = v2ConfigurationRefreshed; v2ConfigurationManager.RequestRefresh(); @@ -907,7 +907,7 @@ public void Validate_UsesLKGWithConfigurationProvider() var v1JwtSecurityToken = new JwtSecurityToken(issuer: v1TokenIssuer, claims: new[] { issClaim, tidClaim }); // before testing v1 LKG setup v1 LKG for v2 manager for cross version validation - _ = aadIssuerValidator.Validate(v1TokenIssuer, v1JwtSecurityToken, new TokenValidationParameters()); + _ = aadIssuerValidator.Validate(v1TokenIssuer, v1JwtSecurityToken, new TokenValidationParameters()); // V1 token and authority behaves like v2 token and authority actualIssuer = v1AadIssuerValidator.Validate(v1TokenIssuer, v1JwtSecurityToken, new TokenValidationParameters()); diff --git a/test/Microsoft.IdentityModel.Xml.Tests/DSigSerializerTests.cs b/test/Microsoft.IdentityModel.Xml.Tests/DSigSerializerTests.cs index 4e833b6a2f..0d06983895 100644 --- a/test/Microsoft.IdentityModel.Xml.Tests/DSigSerializerTests.cs +++ b/test/Microsoft.IdentityModel.Xml.Tests/DSigSerializerTests.cs @@ -76,7 +76,7 @@ public static TheoryData ReadKeyInfoTheoryData { //KeyInfoTest(KeyInfoTestSet.MalformedCertificate, new ExpectedException(typeof(XmlReadException), "IDX30017:", typeof(FormatException)), true), KeyInfoTest(KeyInfoTestSet.KeyInfoFullyPopulated), - KeyInfoTest(KeyInfoTestSet.MultipleCertificates), + KeyInfoTest(KeyInfoTestSet.MultipleCertificates), KeyInfoTest(KeyInfoTestSet.MultipleIssuerSerial, new ExpectedException(typeof(XmlReadException), "IDX30015:")), KeyInfoTest(KeyInfoTestSet.MultipleSKI, new ExpectedException(typeof(XmlReadException), "IDX30015:")), KeyInfoTest(KeyInfoTestSet.MultipleSubjectName, new ExpectedException(typeof(XmlReadException), "IDX30015:")), @@ -280,7 +280,7 @@ public static DSigSerializerTheoryData SignatureTest(SignatureTestSet testSet, E return new DSigSerializerTheoryData { ExpectedException = expectedException ?? ExpectedException.NoExceptionExpected, - First = first, + First = first, Signature = testSet.Signature, TestId = testSet.TestId ?? nameof(testSet), Xml = testSet.Xml, @@ -369,7 +369,7 @@ public static TheoryData WriteSignedInfoTheoryData // ExpectedException.DefaultVerbose = true; return new TheoryData - { + { SignedInfoTest(SignedInfoTestSet.SignedInfoFullyPopulated) }; } @@ -570,7 +570,7 @@ public void WriteReference(DSigSerializerTheoryData theoryData) theoryData.ExpectedException.ProcessNoException(); } - catch(Exception ex) + catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex); } diff --git a/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureReaderTests.cs b/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureReaderTests.cs index b819aa1624..431fe671fe 100644 --- a/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureReaderTests.cs +++ b/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureReaderTests.cs @@ -92,7 +92,7 @@ public void ReadSignedXml(EnvelopedSignatureTheoryData theoryData) try { var envelopedReader = XmlUtilities.CreateEnvelopedSignatureReader(theoryData.Xml); - while (envelopedReader.Read()); + while (envelopedReader.Read()) ; if (theoryData.ExpectSignature) { @@ -179,7 +179,7 @@ public void ReadXmlElements(EnvelopedSignatureTheoryData theoryData) else envelopedReader = new EnvelopedSignatureReader(reader, theoryData.XmlElementReader); - while (envelopedReader.Read()); + while (envelopedReader.Read()) ; if (theoryData.XmlElementReader != null) { @@ -215,7 +215,7 @@ public static TheoryData ReadXmlElementsTheoryData var samlpMesage = File.ReadAllText("SamlpMessage.xml"); var samlpTokenKey = new X509SecurityKey(new X509Certificate2(Convert.FromBase64String("MIIGvzCCBKegAwIBAgICAZUwDQYJKoZIhvcNAQELBQAwgYYxCzAJBgNVBAYTAkNaMQ8wDQYDVQQHEwZQcmFndWUxGTAXBgNVBAoTEENaLk5JQywgei5zLnAuby4xMTAvBgNVBAMTKENaLk5JQyBTSEEyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGDAWBgkqhkiG9w0BCQEWCWNhQG5pYy5jejAeFw0xODAyMDYxMDM5MDJaFw0yMDAyMDYxMDM5MDJaMH0xCzAJBgNVBAYTAkNaMQ8wDQYDVQQHEwZQcmFndWUxDzANBgNVBAoTBkNaLk5JQzEwMC4GA1UEAxMnbW9qZWlkLnJlZ3Rlc3QubmljLmN6IHNpZGFzYW1sIG1ldGFkYXRhMRowGAYJKoZIhvcNAQkBFgtyb290QG5pYy5jejCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANUq8haz+ZNnLBWRLPLQKSyg7TlQDVyLxxMmxFhCT8OXArkjIsZvcwNNeMDB6aOhk0Zs97t+7lEgC2MuiY9GnoC0DV+TAUf7+MzlHuE0oCmR9jiJPsikBEsRDHpvHi9rZv4HK2TCsee/5dDi7tP7bMnRvDOAt7lR+KuLQNaXtDWrXC4bjeNdO/mcy3UeKy+dW2Diqz8YMbRrxM29wAweaUSJ6npU9KTnx0/dq/+IM4R1gO62t+6vjxqiryEFcvdb6lGHc6qC9TYuHaGZBfXiT2goK4NbOr9dfLuixQ8Jd3oN88Qqt7r5u20VLCB06BIQHBgzJTHaSsi5MT5ymtx8lTpkR6MHXGue//QTZPi5DVBonb1B+ilgWdG7jK5yTBA6BkQSbbFp4uHM3IWdExErV/FPeyN9T7Au0kf7Jp73m7gMjD6ytC9xSI082ELufkjmerLTB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uANMvyZW3Ol5ScvLl/KRZM4f4CB6rmYinyHfXIoPF+uCjavyOYnW1RDBASg0Ld/WUJlWb75m5GNkRELIc4c5FU54ysMW9o5wnGpQvtXNdCBJK8tAyZO9Wf2hjZeOZgJ6r1IngfSeSFu7EOFqWnwVOF+3juwWOLCwxrKcURAEngwH01ydwU3oG/rN+7JtdS3IwfaBt9sfDiLQ60qec/6PQc643UztE6oToHLRXsidwrObwyAKLSFJoh/uxWT85JgAoekq5zBen94HfELfMEc9tex6Qlf1tLDs7OWD6Mlw6j9aAcw/4Nfh"))); var samlpKey = new X509SecurityKey(new X509Certificate2(Convert.FromBase64String("MIIGvzCCBKegAwIBAgICAZUwDQYJKoZIhvcNAQELBQAwgYYxCzAJBgNVBAYTAkNaMQ8wDQYDVQQHEwZQcmFndWUxGTAXBgNVBAoTEENaLk5JQywgei5zLnAuby4xMTAvBgNVBAMTKENaLk5JQyBTSEEyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGDAWBgkqhkiG9w0BCQEWCWNhQG5pYy5jejAeFw0xODAyMDYxMDM5MDJaFw0yMDAyMDYxMDM5MDJaMH0xCzAJBgNVBAYTAkNaMQ8wDQYDVQQHEwZQcmFndWUxDzANBgNVBAoTBkNaLk5JQzEwMC4GA1UEAxMnbW9qZWlkLnJlZ3Rlc3QubmljLmN6IHNpZGFzYW1sIG1ldGFkYXRhMRowGAYJKoZIhvcNAQkBFgtyb290QG5pYy5jejCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANUq8haz + ZNnLBWRLPLQKSyg7TlQDVyLxxMmxFhCT8OXArkjIsZvcwNNeMDB6aOhk0Zs97t + 7lEgC2MuiY9GnoC0DV + TAUf7 + MzlHuE0oCmR9jiJPsikBEsRDHpvHi9rZv4HK2TCsee / 5dDi7tP7bMnRvDOAt7lR + KuLQNaXtDWrXC4bjeNdO / mcy3UeKy + dW2Diqz8YMbRrxM29wAweaUSJ6npU9KTnx0 / dq / +IM4R1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n7hxgJdd5ljHE6wmDXLJ8gHuVBNwvc5iHDjHYh7jL5c5jCDBcr1fFCsIARU05RAkfpWurl8GKY8t6IPm7iopOLjru3Gl45ZBdVrAPMQ8Fz1M9VElUJ6ngeKkXHkSwGhCBG3X0MYsltND6mZSkJqN0nOs+cJ6HHO8IZW1f2pH3aCTUSDYWoaZbK74NC6d61sr5Rth4foLQnMzCS5RaXuANMvyZW3Ol5ScvLl/KRZM4f4CB6rmYinyHfXIoPF+uCjavyOYnW1RDBASg0Ld/WUJlWb75m5GNkRELIc4c5FU54ysMW9o5wnGpQvtXNdCBJK8tAyZO9Wf2hjZeOZgJ6r1IngfSeSFu7EOFqWnwVOF+3juwWOLCwxrKcURAEngwH01ydwU3oG/rN+7JtdS3IwfaBt9sfDiLQ60qec/6PQc643UztE6oToHLRXsidwrObwyAKLSFJoh/uxWT85JgAoekq5zBen94HfELfMEc9tex6Qlf1tLDs7OWD6Mlw6j9aAcw/4Nfh"))); - var xmlWithTwoSamlTokens = CreateSignedXmlWithEmbededTokens(new List { CreateSamlToken(), CreateSamlToken()}, Default.SymmetricSigningCredentials, Default.AsymmetricSigningCredentials); + var xmlWithTwoSamlTokens = CreateSignedXmlWithEmbededTokens(new List { CreateSamlToken(), CreateSamlToken() }, Default.SymmetricSigningCredentials, Default.AsymmetricSigningCredentials); var xmlWithSamlAndSaml2Tokens = CreateSignedXmlWithEmbededTokens(new List { CreateSamlToken(), CreateSaml2Token() }, Default.SymmetricSigningCredentials, Default.AsymmetricSigningCredentials); var xmlWithSaml2AndSamlTokens = CreateSignedXmlWithEmbededTokens(new List { CreateSaml2Token(), CreateSamlToken() }, Default.SymmetricSigningCredentials, Default.AsymmetricSigningCredentials); var xmlWithTwoSaml2Tokens = CreateSignedXmlWithEmbededTokens(new List { CreateSaml2Token(), CreateSaml2Token() }, Default.SymmetricSigningCredentials, Default.AsymmetricSigningCredentials); @@ -333,7 +333,7 @@ public static TheoryData ReadXmlElementsTheoryData } } - private static string CreateSignedXmlWithEmbededTokens(IList samlTokens, SigningCredentials xmlSigningCredentials, SigningCredentials tokenSigningCredentials ) + private static string CreateSignedXmlWithEmbededTokens(IList samlTokens, SigningCredentials xmlSigningCredentials, SigningCredentials tokenSigningCredentials) { var ms = new MemoryStream(); var writer = XmlDictionaryWriter.CreateTextWriter(ms, Encoding.UTF8, false); diff --git a/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureWriterTests.cs b/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureWriterTests.cs index 0eda03aebe..3aec7aef96 100644 --- a/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureWriterTests.cs +++ b/test/Microsoft.IdentityModel.Xml.Tests/EnvelopedSignatureWriterTests.cs @@ -76,7 +76,7 @@ public void CreateSignatureWithoutSpecifyingDigest(EnvelopedSignatureTheoryData // read and verify signatures EnvelopedSignatureReader envelopedReader = new EnvelopedSignatureReader(XmlUtilities.CreateDictionaryReader(Encoding.UTF8.GetString(buffer.ToArray()))); - while (envelopedReader.Read()); + while (envelopedReader.Read()) ; envelopedReader.Signature.Verify(theoryData.SigningCredentials.Key, theoryData.SigningCredentials.Key.CryptoProviderFactory); theoryData.ExpectedException.ProcessNoException(context); @@ -113,12 +113,12 @@ public static TheoryData CreateSignatureWithoutSpe theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSha512Signature, null, SecurityAlgorithms.RsaSha512Signature + "_DigestNULL")); #if NET_CORE - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha256, null, SecurityAlgorithms.RsaSsaPssSha256 + "_DigestNULL")); - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha256Signature, null, SecurityAlgorithms.RsaSsaPssSha256Signature + "_DigestNULL")); - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha384, null, SecurityAlgorithms.RsaSsaPssSha384 + "_DigestNULL")); - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha384Signature, null, SecurityAlgorithms.RsaSsaPssSha384Signature + "_DigestNULL")); - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha512, null, SecurityAlgorithms.RsaSsaPssSha512 + "_DigestNULL")); - theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha512Signature, null, SecurityAlgorithms.RsaSsaPssSha512Signature + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha256, null, SecurityAlgorithms.RsaSsaPssSha256 + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha256Signature, null, SecurityAlgorithms.RsaSsaPssSha256Signature + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha384, null, SecurityAlgorithms.RsaSsaPssSha384 + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha384Signature, null, SecurityAlgorithms.RsaSsaPssSha384Signature + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha512, null, SecurityAlgorithms.RsaSsaPssSha512 + "_DigestNULL")); + theoryData.Add(CreateSignatureTestCase(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaSsaPssSha512Signature, null, SecurityAlgorithms.RsaSsaPssSha512Signature + "_DigestNULL")); #endif // Symmetric diff --git a/test/Microsoft.IdentityModel.Xml.Tests/SignatureTests.cs b/test/Microsoft.IdentityModel.Xml.Tests/SignatureTests.cs index 9d76237902..59d6fee2e7 100644 --- a/test/Microsoft.IdentityModel.Xml.Tests/SignatureTests.cs +++ b/test/Microsoft.IdentityModel.Xml.Tests/SignatureTests.cs @@ -39,7 +39,7 @@ public void GetSets() } [Fact] - public void Publics( ) + public void Publics() { var signature = new Signature(); var properties = new List() @@ -48,7 +48,7 @@ public void Publics( ) "SignedInfo", }; - var context = new GetSetContext( ); + var context = new GetSetContext(); foreach (string property in properties) { TestUtilities.SetGet(signature, property, null, ExpectedException.ArgumentNullException(substringExpected: "value"), context); @@ -98,7 +98,7 @@ public static TheoryData ConstructorTheoryData } [Theory, MemberData(nameof(VerifyTheoryData))] - public void Verify( SignatureTheoryData theoryData ) + public void Verify(SignatureTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.Verify", theoryData); try diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/CreateAndValidateTokens.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/CreateAndValidateTokens.cs index 5e0bcb21b8..f34a4d45bb 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/CreateAndValidateTokens.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/CreateAndValidateTokens.cs @@ -897,7 +897,7 @@ public void CreateJWETokens(string testId, string jweToken, TokenValidationParam if (!IdentityComparer.AreEqual(outerToken.Payload, outerToken.InnerToken.Payload, context)) context.Diffs.Add("outerToken.Payload != outerToken.InnerToken.Payload"); - foreach(KeyValuePair claim in expectedPayload) + foreach (KeyValuePair claim in expectedPayload) { if (!outerToken.Payload.ContainsKey(claim.Key)) { @@ -983,7 +983,7 @@ public void CreateTokenNegativeCases() handler.CreateEncodedJwt((SecurityTokenDescriptor)null); ee.ProcessNoException(errors); } - catch(Exception ex) + catch (Exception ex) { ee.ProcessException(ex, errors); } @@ -1051,7 +1051,7 @@ public void ClaimSourceAndClaimName() string encodedJwt = jwtHandler.WriteToken(new JwtSecurityToken(new JwtHeader(), payload)); var validationParameters = new TokenValidationParameters { - IssuerValidator = (issuer, st, tvp) => { return issuer;}, + IssuerValidator = (issuer, st, tvp) => { return issuer; }, RequireSignedTokens = false, ValidateAudience = false, ValidateLifetime = false, @@ -1066,13 +1066,13 @@ public void ClaimSourceAndClaimName() JsonClaims.ClaimNamesAsDictionary); IdentityComparer.AreEqual(claimsPrincipal.Identity as ClaimsIdentity, expectedIdentity, context); - jwtToken = new JwtSecurityToken( new JwtHeader(), new JwtPayload(Default.Issuer, null, ClaimSets.EntityAsJsonClaim(Default.Issuer, Default.Issuer), null, null)); + jwtToken = new JwtSecurityToken(new JwtHeader(), new JwtPayload(Default.Issuer, null, ClaimSets.EntityAsJsonClaim(Default.Issuer, Default.Issuer), null, null)); encodedJwt = jwtHandler.WriteToken(jwtToken); SecurityToken validatedToken; var cp = jwtHandler.ValidateToken(encodedJwt, validationParameters, out validatedToken); IdentityComparer.AreEqual( cp.FindFirst(typeof(Entity).ToString()), - new Claim(typeof(Entity).ToString(), JsonSerializer.Serialize(Entity.Default), JsonClaimValueTypes.Json, Default.Issuer, Default.Issuer, cp.Identity as ClaimsIdentity ), + new Claim(typeof(Entity).ToString(), JsonSerializer.Serialize(Entity.Default), JsonClaimValueTypes.Json, Default.Issuer, Default.Issuer, cp.Identity as ClaimsIdentity), context); TestUtilities.AssertFailIfErrors(context.Diffs); } @@ -1110,7 +1110,7 @@ public void RoleClaims() CompareContext context = new CompareContext { IgnoreType = true }; IdentityComparer.AreEqual(principal.Claims, expectedIdentity.Claims, context); - TestUtilities.AssertFailIfErrors(GetType().ToString()+".RoleClaims", context.Diffs); + TestUtilities.AssertFailIfErrors(GetType().ToString() + ".RoleClaims", context.Diffs); } [Fact] @@ -1220,8 +1220,6 @@ public void NameAndRoleClaimDelegates() /// /// First string is expected, others are not. /// - /// - /// private void CheckNamesAndRole(string[] names, string[] roles, ClaimsPrincipal principal, string expectedNameClaimType = ClaimsIdentity.DefaultNameClaimType, string expectedRoleClaimType = ClaimsIdentity.DefaultRoleClaimType) { ClaimsIdentity identity = principal.Identity as ClaimsIdentity; @@ -1243,8 +1241,6 @@ private void CheckNamesAndRole(string[] names, string[] roles, ClaimsPrincipal p /// /// First role is expected, others are not. /// - /// - /// private void CheckForRoles(IEnumerable expectedRoles, IEnumerable unexpectedRoles, ClaimsPrincipal principal, string expectedRoleClaimType = ClaimsIdentity.DefaultRoleClaimType) { ClaimsIdentity identity = principal.Identity as ClaimsIdentity; diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtHeaderTests.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtHeaderTests.cs index c9109ad326..9e11b5fc03 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtHeaderTests.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtHeaderTests.cs @@ -242,8 +242,8 @@ public void Getx5cRoundTrip() public class JwtHeaderTheoryData : TheoryDataBase { - public IDictionary OutboundAlgorithmMap { get; set; } + public IDictionary OutboundAlgorithmMap { get; set; } public SigningCredentials SigningCredentials { get; set; } - } + } } diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenConverterTests.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenConverterTests.cs index 4d7859829d..fd7fddf748 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenConverterTests.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenConverterTests.cs @@ -87,7 +87,7 @@ public static TheoryData ConverterTheoryDat Assert.True(token.Header.ContainsKey(header.Type)); var otherHeader = token.Header[header.Type]; Assert.Equal(header.Value, otherHeader); - } + } foreach (var header in jweToken.InnerToken.Header.Claims((string)Default.PayloadDictionary[JwtRegisteredClaimNames.Iss])) { diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenHandlerTests.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenHandlerTests.cs index a67334bb45..3bbc83a453 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenHandlerTests.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenHandlerTests.cs @@ -109,7 +109,7 @@ public void CreateJWEWithAdditionalHeaderClaims(CreateTokenTheoryData theoryData } } } - catch(Exception ex) + catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } @@ -299,7 +299,7 @@ public void CheckExpectedDifferenceInAudClaimUsingSecurityTokenDescriptor(Create int expectedAudClaimCount = 0; int additionalAudClaimsForJwtHandler = 0; - + if (audMemberSet) { @@ -1811,7 +1811,7 @@ public static TheoryData ValidateAudienceTheoryData get { var tokenHandler = new JwtSecurityTokenHandler(); - var securityTokenDescriptorWithAudiences = new SecurityTokenDescriptor{ Issuer = Default.Issuer }; + var securityTokenDescriptorWithAudiences = new SecurityTokenDescriptor { Issuer = Default.Issuer }; foreach (var audience in Default.Audiences) securityTokenDescriptorWithAudiences.Audiences.Add(audience); diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenTests.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenTests.cs index 20436ac306..2c723e7c24 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenTests.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtSecurityTokenTests.cs @@ -76,7 +76,7 @@ public void DateTime2038Issue() expires: (new DateTime(2038, 1, 20)).ToUniversalTime(), signingCredentials: creds); - Assert.Equal(token.ValidTo, (new DateTime(2038,1,20)).ToUniversalTime()); + Assert.Equal(token.ValidTo, (new DateTime(2038, 1, 20)).ToUniversalTime()); } [Fact] @@ -380,7 +380,7 @@ private static void ParseJweParts(string jwe, out string headerPart, out string if (string.IsNullOrEmpty(jwe)) throw LogHelper.LogExceptionMessage(new ArgumentNullException(nameof(jwe))); - string[] parts = jwe.Split(new char[] {'.'}, 6); + string[] parts = jwe.Split(new char[] { '.' }, 6); if (parts.Length != 5) throw new ArgumentException(string.Format("The JWE token must have 5 parts. The JWE {0} has {1} parts.", jwe, parts.Length)); diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestData.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestData.cs index 9a6db857e6..7dd710dffc 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestData.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestData.cs @@ -218,7 +218,7 @@ public static TheoryData InvalidRegExSegmentsDataForReadToken(str theoryData.Add(new JwtTheoryData { CanRead = false, - TestId = "'invalidRegEx: first position'", + TestId = "'invalidRegEx: first position'", Token = invalidRegEx + "." + validRegEx + "." + validRegEx + "." + validRegEx + "." + validRegEx, ExpectedException = ExpectedException.SecurityTokenMalformedTokenException(errorString) }); diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestUtilities.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestUtilities.cs index 3339465ea1..8651a60f40 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestUtilities.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/JwtTestUtilities.cs @@ -16,7 +16,7 @@ namespace System.IdentityModel.Tokens.Jwt.Tests /// public class JwtSecurityTokenTestVariation { - public JwtSecurityTokenTestVariation() + public JwtSecurityTokenTestVariation() { } @@ -41,20 +41,20 @@ public JwtSecurityTokenTestVariation() public class JwtTestUtilities { - public static string GetJwtParts( string jwt, string whichParts ) + public static string GetJwtParts(string jwt, string whichParts) { - string[] parts = jwt.Split( '.' ); - if ( string.Equals( whichParts, "AllParts", StringComparison.OrdinalIgnoreCase ) ) + string[] parts = jwt.Split('.'); + if (string.Equals(whichParts, "AllParts", StringComparison.OrdinalIgnoreCase)) { - return string.Format( "{0}.{1}.{2}", parts[0], parts[1], parts[2] ); + return string.Format("{0}.{1}.{2}", parts[0], parts[1], parts[2]); } - - if ( string.Equals( whichParts, "Parts-0-1", StringComparison.OrdinalIgnoreCase ) ) + + if (string.Equals(whichParts, "Parts-0-1", StringComparison.OrdinalIgnoreCase)) { - return string.Format( "{0}.{1}.", parts[0], parts[1] ); + return string.Format("{0}.{1}.", parts[0], parts[1]); } - Console.WriteLine( string.Format("Hey, the 'whichParts' parameter wasn't recognized: '{0}'. Returning'string.Empty' hope that is what you wanted", whichParts ) ); + Console.WriteLine(string.Format("Hey, the 'whichParts' parameter wasn't recognized: '{0}'. Returning'string.Empty' hope that is what you wanted", whichParts)); return string.Empty; } } diff --git a/test/System.IdentityModel.Tokens.Jwt.Tests/References.cs b/test/System.IdentityModel.Tokens.Jwt.Tests/References.cs index 9249bb11ad..414354f4ad 100644 --- a/test/System.IdentityModel.Tokens.Jwt.Tests/References.cs +++ b/test/System.IdentityModel.Tokens.Jwt.Tests/References.cs @@ -447,39 +447,39 @@ public static string RSA_1_5_JWE public static class EncodedJwts { public static string Asymmetric_LocalSts { get => @"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwOi8vR290Snd0LmNvbSIsImF1ZCI6Imh0dHA6Ly9Db250b3NvLmNvbSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2NvdW50cnkiOiJVU0EiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9lbWFpbGFkZHJlc3MiOiJ1c2VyQGNvbnRvc28uY29tIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvZ2l2ZW5uYW1lIjoiVG9ueSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2hvbWVwaG9uZSI6IjU1NS4xMjEyIiwiaHR0cDovL3Nja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KehaiH0O_bQR0pRCdV6sfVuMPMsO4tARK1rUlIjROlZBKyLyNeR_YFZ50U1SSaAxnsnsk2MucTt5lfOUjFhXko-qWwHnib61lFJlnTMR-ntImTIj1XyMUcf2RZ6HdlZbvXjA92fRaQ2-3Mc7eeJscT3mW4W4Yoe3BccHEmyzSCHVNsskCF0AULjSs-bcE.6gXNNIY0ZAXi6tSbz6l6Fg"; - public static string ValidJwe = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string ValidJwe2 = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string InvalidJwe = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; // 4 parts - public static string InvalidJwe2 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; // 6 parts - public static string InvalidJwe3 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9*&"; // invalid characters - public static string InvalidJwe4 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // extra period at end - public static string InvalidJwe5 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // empty 5th segment - public static string InvalidJwe6 = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // empty 2nd and 5th segment - public static string JweTest1 = @"eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoiRGVmYXVsdFN5bW1ldHJpY1NlY3VyaXR5S2V5XzI1NiIsInR5cCI6IkpXVCJ9..CiER3OL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KgIILz-uysx_8sGUHw6Uig.Jzj6wn_rulSAuaADgUayVttM_h1CxzDeadddOaZ3sDzBu6Z0ffMQ9IKtjbpkLfzawFM0qBRjt1p75IUieTa7esZOWj5yoS8UQWg0e1n2pWpWEx9zpfeMsJjbwrsD4_tFxKRDjlAuDHYX2NehgT8CAiI2vI0dMgzIUR8VU6p7Srg_UpiZy_QnVcFG7hHhAK0R0affj6ViGhc7U_diMnpR5P3s8eG-GImB4iHMltlaUTcUqFDgSJBCmiQ0SK-lDTy9Q4Z3tGdhTZeofG9-fi68E234uznjdSj_Ql2t1E4nMOYc0kRcORlKJNQKUMLqW5ddwZwPqRd0HzccjLwnP20RqUbWntBidIdTTl94dT-1BrNGQMDMCTV7HQQxmf1JKbBN0DD0xkfOnO4UGEoHVhjOQhd1R1gAh7KtDNMJKPIdmGfMoy2SDJm_pPwmJ1ayw8rF4F5MoCDxUcKVfC25DAWOxVtnvvR4rJ9qkc9dWHr6sdFqZi7sRQIG9M7T2qqOktoZdoAEmduhii5_p5B456PsZlt8olRCsI8Xb_p4sR5clsEEMRatiUKvcXzNiVEK__17tGa2ALKGoutYb_8AasavGhz-sUjlLlHlCmaI9MA8s07MfhobBEepgNStymK1IBkl1wb1sidMmkNWSX4R18bA9J5tjAcUH0tsyyXzxix7DkKag-zl3pxxawS0NmjVIAnxXOFM_M8_DWQAySNO3atkHnMP__PneG3J-4vUoZhVeEQj66D-MCnCGzKi7YeEAjvLbPsQSeE6ptZ5lfiCmzmza0OkfeRnxRE8L1UA6-XydZ0Z6P1M7W-eV4OctVwIq1VNJeC461-D0ukouDWGBfVajW0k9Ws-U2l8Sp16TgEHkly1MnU7P7VkclldrIQ18yzd.j6_mHUzwEVeprRmNZMEY7A"; - public static string JWSEmptyHeader = @".eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string JWSEmptyPayload = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9"; - public static string JWEEmptyHeader = @".eyJhIjoiYiJ9.eyJhIjoiYiJ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J9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string ValidJwe2 = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string InvalidJwe = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; // 4 parts + public static string InvalidJwe2 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; // 6 parts + public static string InvalidJwe3 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9*&"; // invalid characters + public static string InvalidJwe4 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // extra period at end + public static string InvalidJwe5 = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // empty 5th segment + public static string InvalidJwe6 = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9."; // empty 2nd and 5th segment + public static string JweTest1 = @"eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoiRGVmYXVsdFN5bW1ldHJpY1NlY3VyaXR5S2V5XzI1NiIsInR5cCI6IkpXVCJ9..CiER3OL0oLzoaO-wk0zXtg.xYf9svt5_wzDIk8QjeENnKYUosWDgDjTf-Y2ULc5OJcnDzZdBpeq4y5RS0AUfB6HNMnfiMfwFpCO5TcMV2kWpLqHNvxc9wEcdBdOQFBdcwo2zbvMV4IjVfBUlyxqkO1tuRM2NkJBNbN90fHvr5D-P2Hnbsc6q5ev0nv8ZFAOAUlcXWr-KM6-Gy7jAXVduBzjkFYRMTvM2H2pRLTvXYcwmczI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-GImB4iHMltlaUTcUqFDgSJBCmiQ0SK-lDTy9Q4Z3tGdhTZeofG9-fi68E234uznjdSj_Ql2t1E4nMOYc0kRcORlKJNQKUMLqW5ddwZwPqRd0HzccjLwnP20RqUbWntBidIdTTl94dT-1BrNGQMDMCTV7HQQxmf1JKbBN0DD0xkfOnO4UGEoHVhjOQhd1R1gAh7KtDNMJKPIdmGfMoy2SDJm_pPwmJ1ayw8rF4F5MoCDxUcKVfC25DAWOxVtnvvR4rJ9qkc9dWHr6sdFqZi7sRQIG9M7T2qqOktoZdoAEmduhii5_p5B456PsZlt8olRCsI8Xb_p4sR5clsEEMRatiUKvcXzNiVEK__17tGa2ALKGoutYb_8AasavGhz-sUjlLlHlCmaI9MA8s07MfhobBEepgNStymK1IBkl1wb1sidMmkNWSX4R18bA9J5tjAcUH0tsyyXzxix7DkKag-zl3pxxawS0NmjVIAnxXOFM_M8_DWQAySNO3atkHnMP__PneG3J-4vUoZhVeEQj66D-MCnCGzKi7YeEAjvLbPsQSeE6ptZ5lfiCmzmza0OkfeRnxRE8L1UA6-XydZ0Z6P1M7W-eV4OctVwIq1VNJeC461-D0ukouDWGBfVajW0k9Ws-U2l8Sp16TgEHkly1MnU7P7VkclldrIQ18yzd.j6_mHUzwEVeprRmNZMEY7A"; + public static string JWSEmptyHeader = @".eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string JWSEmptyPayload = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9"; + public static string JWEEmptyHeader = @".eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; public static string JWEEmptyEncryptedKey = @"eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string JWEEmptyIV = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string JWEEmptyCiphertext = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9..eyJhIjoiYiJ9"; - public static string JWEEmptyAuthenticationTag = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; - public static string JWEInvalidHeader = @"e.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string JWEInvalidIV = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.e.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; - public static string JWEInvalidCiphertext = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.e.eyJhIjoiYiJ9"; - public static string JWEInvalidAuthenticationTag = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.e"; + public static string JWEEmptyIV = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9..eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string JWEEmptyCiphertext = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9..eyJhIjoiYiJ9"; + public static string JWEEmptyAuthenticationTag = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9."; + public static string JWEInvalidHeader = @"e.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string JWEInvalidIV = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.e.eyJhIjoiYiJ9.eyJhIjoiYiJ9"; + public static string JWEInvalidCiphertext = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.e.eyJhIjoiYiJ9"; + public static string JWEInvalidAuthenticationTag = @"eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.eyJhIjoiYiJ9.e"; public static string JwsKidNullX5t { From 399fcd8c3e5cd1091155f0ba9bc1338a8314a487 Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Mon, 5 Aug 2024 19:53:29 -0700 Subject: [PATCH 2/4] Fix up code generated by roslyn fixer --- src/Microsoft.IdentityModel.Logging/LogHelper.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.IdentityModel.Logging/LogHelper.cs b/src/Microsoft.IdentityModel.Logging/LogHelper.cs index b99ef5cad6..b2282954fc 100644 --- a/src/Microsoft.IdentityModel.Logging/LogHelper.cs +++ b/src/Microsoft.IdentityModel.Logging/LogHelper.cs @@ -340,15 +340,19 @@ public static void LogWarning(string message, params object[] args) Logger.Log(WriteEntry(eventLogLevel, innerException, message, null)); if (innerException != null) + { if (string.IsNullOrEmpty(argumentName)) return (T)Activator.CreateInstance(typeof(T), message, innerException); else return (T)Activator.CreateInstance(typeof(T), argumentName, message, innerException); + } else + { if (string.IsNullOrEmpty(argumentName)) - return (T)Activator.CreateInstance(typeof(T), message); - else - return (T)Activator.CreateInstance(typeof(T), argumentName, message); + return (T)Activator.CreateInstance(typeof(T), message); + else + return (T)Activator.CreateInstance(typeof(T), argumentName, message); + } } private static EventLogLevel EventLevelToEventLogLevel(EventLevel eventLevel) => From 73ca829728063ca00582d170976238c6e66215cf Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Tue, 6 Aug 2024 08:37:10 -0700 Subject: [PATCH 3/4] Updates for file headers Don't consider GlobalSuppressions.cs, or TrimmingAttributes.cs --- .editorconfig | 3 ++ .../LoggerContext.cs | 2 +- .../OpenIdConnectConfigurationSerializer.cs | 5 ++-- .../Json/JsonSerializerPrimitives.cs | 5 ++-- .../Json/JsonWebKeySerializer.cs | 5 ++-- .../Json/JsonWebKeySetSerializer.cs | 5 ++-- src/Microsoft.IdentityModel.Xml/Reference.cs | 28 ++----------------- .../IdentityUtilities.cs | 2 -- .../References.cs | 1 - .../TestSets.cs | 1 - 10 files changed, 14 insertions(+), 43 deletions(-) diff --git a/.editorconfig b/.editorconfig index 29be06e2e2..4761a0d5ba 100644 --- a/.editorconfig +++ b/.editorconfig @@ -181,6 +181,9 @@ dotnet_diagnostic.CA1845.severity = warning # CA1846: Prefer AsSpan over Substring dotnet_diagnostic.CA1846.severity = warning +[{GlobalSuppressions.cs,TrimmingAttributes.cs}] +dotnet_diagnostic.IDE0073.severity = none + # C++ Files [*.{cpp,h,in}] curly_bracket_next_line = true diff --git a/src/Microsoft.IdentityModel.Logging/LoggerContext.cs b/src/Microsoft.IdentityModel.Logging/LoggerContext.cs index 4aa7deb450..a6adc5554f 100644 --- a/src/Microsoft.IdentityModel.Logging/LoggerContext.cs +++ b/src/Microsoft.IdentityModel.Logging/LoggerContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; diff --git a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs index 6fa2a9bd8c..b41470dd29 100644 --- a/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs +++ b/src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs @@ -1,6 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. using System; #if NET8_0_OR_GREATER diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs index d94f9ec768..db68b15015 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs @@ -1,6 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. using System; using System.Collections; diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs index 0cf3e539b1..9429ebcec7 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySerializer.cs @@ -1,6 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. using System; #if NET8_0_OR_GREATER diff --git a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs index f4e64f7bf0..82c56cc63f 100644 --- a/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs +++ b/src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.cs @@ -1,6 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. using System; using System.IO; diff --git a/src/Microsoft.IdentityModel.Xml/Reference.cs b/src/Microsoft.IdentityModel.Xml/Reference.cs index 22d26824f7..dcae13c9b2 100644 --- a/src/Microsoft.IdentityModel.Xml/Reference.cs +++ b/src/Microsoft.IdentityModel.Xml/Reference.cs @@ -1,29 +1,5 @@ -//----------7-------------------------------------------------------------------- -// -// Copyright (c) Microsoft Corporation. -// All rights reserved. -// -// This code is licensed under the MIT License. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions : -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -//------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. using System; using System.Collections.Generic; diff --git a/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs b/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs index 130d0ab4a7..a0bdc02691 100644 --- a/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs +++ b/test/Microsoft.IdentityModel.TestUtils/IdentityUtilities.cs @@ -7,9 +7,7 @@ using System.Security.Claims; using System.Security.Cryptography; using System.Text; -using System.Xml; using Microsoft.IdentityModel.Tokens; -using Microsoft.IdentityModel.Tokens.Saml2; #if USING_SAML1 using Microsoft.IdentityModel.Tokens.Saml; diff --git a/test/Microsoft.IdentityModel.TestUtils/References.cs b/test/Microsoft.IdentityModel.TestUtils/References.cs index a4f6d5a051..b66cdf1040 100644 --- a/test/Microsoft.IdentityModel.TestUtils/References.cs +++ b/test/Microsoft.IdentityModel.TestUtils/References.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.IO.Compression; using Microsoft.IdentityModel.Tokens; namespace Microsoft.IdentityModel.TestUtils diff --git a/test/Microsoft.IdentityModel.TestUtils/TestSets.cs b/test/Microsoft.IdentityModel.TestUtils/TestSets.cs index 9646c9b1e7..c76fdb3451 100644 --- a/test/Microsoft.IdentityModel.TestUtils/TestSets.cs +++ b/test/Microsoft.IdentityModel.TestUtils/TestSets.cs @@ -9,7 +9,6 @@ using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens.Saml; using Microsoft.IdentityModel.Xml; -using static Microsoft.IdentityModel.Xml.XmlSignatureConstants; namespace Microsoft.IdentityModel.TestUtils { From 16fd58e6b43cd7ff74d193a5f1cdb8fab7055be5 Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Tue, 6 Aug 2024 09:41:50 -0700 Subject: [PATCH 4/4] Fix comments --- .../Validation/ValidationParameters.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs b/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs index 29b118f571..e86d89b92a 100644 --- a/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs +++ b/src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs @@ -512,25 +512,25 @@ public TypeValidatorDelegate TypeValidator public IList ValidAlgorithms { get; set; } /// - /// Gets the that contains valid audiences that will be used to check against the token's audience. + /// Gets the that contains valid audiences that will be used to check against the token's audience. /// The default is null. /// public IList ValidAudiences { get; } /// - /// Gets the that contains valid issuers that will be used to check against the token's issuer. + /// Gets the that contains valid issuers that will be used to check against the token's issuer. /// The default is null. /// public IList ValidIssuers { get; } /// - /// Gets the that contains valid types that will be used to check against the JWT header's 'typ' claim. + /// Gets the that contains valid types that will be used to check against the JWT header's 'typ' claim. /// If this property is not set, the 'typ' header claim will not be validated and all types will be accepted. /// In the case of a JWE, this property will ONLY apply to the inner token header. /// The default is an empty collection. /// /// Thrown when the value is set as null. - /// The that contains valid token types that will be used to check against the token's 'typ' claim. + /// The that contains valid token types that will be used to check against the token's 'typ' claim. public IList ValidTypes { get