Skip to content

Commit

Permalink
Removed unused property on JsonWebToken (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
keegan-caruso authored Jan 3, 2025
1 parent e725d0e commit e6d316e
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -629,61 +626,6 @@ public Claim GetClaim(string key)
/// </summary>
internal IReadOnlyCollection<string> 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;
}
}

/// <summary>
/// Try to get a <see cref="Claim"/> representing the { key, 'value' } pair corresponding to the provided <paramref name="key"/>.
/// The value is obtained from the Payload.
Expand Down

0 comments on commit e6d316e

Please sign in to comment.