From 8e3e4cd866c3a9ae84f8be5220d5addc23efde73 Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Thu, 2 Jan 2025 10:14:18 -0800 Subject: [PATCH] Removed unused property on JsonWebToken --- .../JsonWebToken.cs | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs index 48af759d86..985836f1c4 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs @@ -19,9 +19,6 @@ public partial class JsonWebToken : SecurityToken { internal const string ClassName = "Microsoft.IdentityModel.JsonWebTokens.JsonWebToken"; - private ClaimsIdentity _claimsIdentity; - private bool _wasClaimsIdentitySet; - private string _act; private string _authenticationTag; private string _ciphertext; @@ -629,61 +626,6 @@ public Claim GetClaim(string key) /// internal IReadOnlyCollection PayloadClaimNames => Payload._jsonClaims.Keys; - internal ClaimsIdentity ClaimsIdentity - { - get - { - if (!_wasClaimsIdentitySet) - { - _wasClaimsIdentitySet = true; - string actualIssuer = ActualIssuer ?? Issuer; - - foreach (Claim claim in Claims) - { - string claimType = claim.Type; - if (claimType == ClaimTypes.Actor) - { - if (_claimsIdentity.Actor != null) - throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX14112, LogHelper.MarkAsNonPII(JwtRegisteredClaimNames.Actort), claim.Value))); - -#pragma warning disable CA1031 // Do not catch general exception types - try - { - JsonWebToken actorToken = new JsonWebToken(claim.Value); - _claimsIdentity.Actor = ActorClaimsIdentity; - } - catch - { - - } -#pragma warning restore CA1031 // Do not catch general exception types - } - - if (claim.Properties.Count == 0) - { - _claimsIdentity.AddClaim(new Claim(claimType, claim.Value, claim.ValueType, actualIssuer, actualIssuer, _claimsIdentity)); - } - else - { - Claim newClaim = new Claim(claimType, claim.Value, claim.ValueType, actualIssuer, actualIssuer, _claimsIdentity); - - foreach (var kv in claim.Properties) - newClaim.Properties[kv.Key] = kv.Value; - - _claimsIdentity.AddClaim(newClaim); - } - } - } - - return _claimsIdentity; - } - - set - { - _claimsIdentity = value; - } - } - /// /// Try to get a representing the { key, 'value' } pair corresponding to the provided . /// The value is obtained from the Payload.