diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs index 4cd4f53a2d..468a1de4a8 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs @@ -1311,7 +1311,7 @@ internal IEnumerable GetContentEncryptionKeys(JsonWebToken jwtToken } if (key != null) - keys = new List { key }; + keys = [key]; } // on decryption for ECDH-ES, we get the public key from the EPK value see: https://datatracker.ietf.org/doc/html/rfc7518#appendix-C diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs index 3d7882e8d6..3132ad2863 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs @@ -901,7 +901,7 @@ private static JsonWebToken ValidateSignature(JsonWebToken jwtToken, TokenValida if (key != null) { kidMatched = true; - keys = new List { key }; + keys = [key]; } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs index 608e7ff958..9b70430151 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs @@ -1037,7 +1037,7 @@ private SamlSecurityToken ValidateSignature(SamlSecurityToken samlToken, string { // remember that key was matched for throwing exception SecurityTokenSignatureKeyNotFoundException keyMatched = true; - keys = new List { securityKey }; + keys = [securityKey]; } } diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlTokenUtilities.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlTokenUtilities.cs index 122be3cd98..2feb0aa25c 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlTokenUtilities.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlTokenUtilities.cs @@ -47,44 +47,6 @@ internal static SecurityKey ResolveTokenSigningKey(KeyInfo tokenKeyInfo, TokenVa return null; } - /// - /// Returns all to use when validating the signature of a token. - /// - /// The representation of the token that is being validated. - /// The that is being validated. - /// The field of the token being validated - /// A required for validation. - /// A to represent if a a issuer signing key matched with token kid or x5t - /// Returns all to use for signature validation. - internal static IEnumerable GetKeysForTokenSignatureValidation(string token, SecurityToken samlToken, KeyInfo tokenKeyInfo, TokenValidationParameters validationParameters, out bool keyMatched) - { - keyMatched = false; - - if (validationParameters.IssuerSigningKeyResolver != null) - { - return validationParameters.IssuerSigningKeyResolver(token, samlToken, tokenKeyInfo?.Id, validationParameters); - } - else - { - SecurityKey key = ResolveTokenSigningKey(tokenKeyInfo, validationParameters); - - if (key != null) - { - keyMatched = true; - return new List { key }; - } - else - { - keyMatched = false; - if (validationParameters.TryAllIssuerSigningKeys) - { - return TokenUtilities.GetAllSigningKeys(validationParameters: validationParameters); - } - } - } - return null; - } - /// /// Creates 's from . /// diff --git a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs index a588d4d467..4100330a51 100644 --- a/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs +++ b/src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs @@ -430,7 +430,7 @@ private Saml2SecurityToken ValidateSignature(Saml2SecurityToken samlToken, strin { // remember that key was matched for throwing exception SecurityTokenSignatureKeyNotFoundException keyMatched = true; - keys = new List { key }; + keys = [key]; } } diff --git a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs index ceecfa7c7c..bfb2c022e7 100644 --- a/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs +++ b/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs @@ -1344,7 +1344,7 @@ private JwtSecurityToken ValidateSignature(string token, JwtSecurityToken jwtTok if (key != null) { kidMatched = true; - keys = new List { key }; + keys = [key]; } } @@ -1812,7 +1812,7 @@ internal IEnumerable GetContentEncryptionKeys(JwtSecurityToken jwtT { var key = ResolveTokenDecryptionKey(jwtToken.RawData, jwtToken, validationParameters); if (key != null) - keys = new List { key }; + keys = [key]; } // control gets here if: