Skip to content

Commit add645b

Browse files
committed
Merge main.
2 parents 1034c9f + 442baa3 commit add645b

File tree

63 files changed

+2038
-619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2038
-619
lines changed

src/Microsoft.IdentityModel.JsonWebTokens/InternalAPI.Unshipped.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler._telemetryClient -> Microsoft.IdentityModel.Telemetry.ITelemetryClient
2+
override Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateTokenAsync(Microsoft.IdentityModel.Tokens.SecurityToken token, Microsoft.IdentityModel.Tokens.ValidationParameters validationParameters, Microsoft.IdentityModel.Tokens.CallContext callContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Tokens.ValidationResult<Microsoft.IdentityModel.Tokens.ValidatedToken>>
3+
override Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateTokenAsync(string token, Microsoft.IdentityModel.Tokens.ValidationParameters validationParameters, Microsoft.IdentityModel.Tokens.CallContext callContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Tokens.ValidationResult<Microsoft.IdentityModel.Tokens.ValidatedToken>>
24
Microsoft.IdentityModel.JsonWebTokens.JsonWebToken.JsonWebToken(string header, string payload, Microsoft.IdentityModel.Tokens.ReadTokenPayloadValueDelegate readTokenPayloadValueDelegate) -> void
35
Microsoft.IdentityModel.JsonWebTokens.JsonWebToken.JsonWebToken(string jwtEncodedString, Microsoft.IdentityModel.Tokens.ReadTokenPayloadValueDelegate readTokenPayloadValueDelegate) -> void
46
Microsoft.IdentityModel.JsonWebTokens.JsonWebToken.JsonWebToken(System.ReadOnlyMemory<char> encodedTokenMemory, Microsoft.IdentityModel.Tokens.ReadTokenPayloadValueDelegate readTokenPayloadValueDelegate) -> void
@@ -12,4 +14,3 @@ static Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.WriteJweHeader(
1214
static Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.WriteJweHeader(Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor) -> byte[]
1315
static Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.WriteJwsHeader(ref System.Text.Json.Utf8JsonWriter writer, Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor) -> void
1416
static Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.WriteJwsHeader(ref System.Text.Json.Utf8JsonWriter writer, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, System.Collections.Generic.IDictionary<string, object> jweHeaderClaims, System.Collections.Generic.IDictionary<string, object> jwsHeaderClaims, string tokenType, bool includeKeyIdInHeader) -> void
15-
static Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.StackFrames.IssuerValidatorThrew -> System.Diagnostics.StackFrame

src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs

+6-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Collections.Generic;
6-
using System.Diagnostics;
76
using System.Linq;
87
using System.Text;
98
using Microsoft.IdentityModel.Logging;
@@ -31,49 +30,42 @@ internal ValidationResult<string> DecryptToken(
3130
{
3231
if (jwtToken == null)
3332
{
34-
StackFrame tokenNullStackFrame = StackFrames.DecryptionTokenNull ??= new StackFrame(true);
3533
return ValidationError.NullParameter(
3634
nameof(jwtToken),
37-
tokenNullStackFrame);
35+
ValidationError.GetCurrentStackFrame());
3836
}
3937

4038
if (validationParameters == null)
4139
{
42-
StackFrame validationParametersNullStackFrame = StackFrames.DecryptionValidationParametersNull ??= new StackFrame(true);
4340
return ValidationError.NullParameter(
4441
nameof(validationParameters),
45-
validationParametersNullStackFrame);
42+
ValidationError.GetCurrentStackFrame());
4643
}
4744

4845
if (string.IsNullOrEmpty(jwtToken.Enc))
4946
{
50-
StackFrame headerMissingStackFrame = StackFrames.DecryptionHeaderMissing ??= new StackFrame(true);
5147
return new ValidationError(
5248
new MessageDetail(TokenLogMessages.IDX10612),
5349
ValidationFailureType.TokenDecryptionFailed,
5450
typeof(SecurityTokenException),
55-
headerMissingStackFrame);
51+
ValidationError.GetCurrentStackFrame());
5652
}
5753

5854
(IList<SecurityKey>? contentEncryptionKeys, ValidationError? validationError) result =
5955
GetContentEncryptionKeys(jwtToken, validationParameters, configuration, callContext);
6056

6157
if (result.validationError != null)
62-
{
63-
StackFrame decryptionGetKeysStackFrame = StackFrames.DecryptionGetEncryptionKeys ??= new StackFrame(true);
64-
return result.validationError.AddStackFrame(decryptionGetKeysStackFrame);
65-
}
58+
return result.validationError.AddCurrentStackFrame();
6659

6760
if (result.contentEncryptionKeys == null || result.contentEncryptionKeys.Count == 0)
6861
{
69-
StackFrame noKeysTriedStackFrame = StackFrames.DecryptionNoKeysTried ??= new StackFrame(true);
7062
return new ValidationError(
7163
new MessageDetail(
7264
TokenLogMessages.IDX10609,
7365
LogHelper.MarkAsSecurityArtifact(jwtToken, JwtTokenUtilities.SafeLogJwtToken)),
7466
ValidationFailureType.TokenDecryptionFailed,
7567
typeof(SecurityTokenDecryptionFailedException),
76-
noKeysTriedStackFrame);
68+
ValidationError.GetCurrentStackFrame());
7769
}
7870

7971
return JwtTokenUtilities.DecryptJwtToken(
@@ -211,7 +203,6 @@ internal ValidationResult<string> DecryptToken(
211203
return (unwrappedKeys, null);
212204
else
213205
{
214-
StackFrame decryptionKeyUnwrapFailedStackFrame = StackFrames.DecryptionKeyUnwrapFailed ??= new StackFrame(true);
215206
ValidationError validationError = new(
216207
new MessageDetail(
217208
TokenLogMessages.IDX10618,
@@ -220,7 +211,7 @@ internal ValidationResult<string> DecryptToken(
220211
LogHelper.MarkAsSecurityArtifact(jwtToken, JwtTokenUtilities.SafeLogJwtToken)),
221212
ValidationFailureType.TokenDecryptionFailed,
222213
typeof(SecurityTokenKeyWrapException),
223-
decryptionKeyUnwrapFailedStackFrame);
214+
ValidationError.GetCurrentStackFrame());
224215

225216
return (null, validationError);
226217
}

src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.ReadToken.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Diagnostics;
65
using Microsoft.IdentityModel.Tokens;
76

87
#nullable enable
@@ -28,10 +27,9 @@ internal static ValidationResult<SecurityToken> ReadToken(
2827
{
2928
if (string.IsNullOrEmpty(token))
3029
{
31-
StackFrame nullTokenStackFrame = StackFrames.ReadTokenNullOrEmpty ?? new StackFrame(true);
3230
return ValidationError.NullParameter(
3331
nameof(token),
34-
nullTokenStackFrame);
32+
ValidationError.GetCurrentStackFrame());
3533
}
3634

3735
try
@@ -43,12 +41,11 @@ internal static ValidationResult<SecurityToken> ReadToken(
4341
catch (Exception ex)
4442
#pragma warning restore CA1031 // Do not catch general exception types
4543
{
46-
StackFrame malformedTokenStackFrame = StackFrames.ReadTokenMalformed ?? new StackFrame(true);
4744
return new ValidationError(
4845
new MessageDetail(LogMessages.IDX14107),
4946
ValidationFailureType.TokenReadingFailed,
5047
typeof(SecurityTokenMalformedException),
51-
malformedTokenStackFrame,
48+
ValidationError.GetCurrentStackFrame(),
5249
ex);
5350
}
5451
}

0 commit comments

Comments
 (0)