Skip to content

Commit

Permalink
Removed primary constructor from ValidatedToken in favour of clarity …
Browse files Browse the repository at this point in the history
…with a regular constructor with validations
  • Loading branch information
iNinja committed Jan 14, 2025
1 parent 00090eb commit 0cb18a9
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@ namespace Microsoft.IdentityModel.Tokens
/// <summary>
/// Contains the results of successfully validating a <see cref="SecurityToken"/>.
/// </summary>
/// <remarks>
/// Creates an instance of <see cref="ValidatedToken"/>
/// </remarks>
/// <param name="securityToken">The <see cref="SecurityToken"/> that is being validated.</param>
/// <param name="tokenHandler">The <see cref="TokenHandler"/> that is being used to validate the token.</param>
/// <param name="validationParameters">The <see cref="ValidationParameters"/> to be used for validating the token.</param>
internal class ValidatedToken(
SecurityToken securityToken,
TokenHandler tokenHandler,
ValidationParameters validationParameters)
internal class ValidatedToken
{
/// <summary>
/// Initializes a new instance of <see cref="ValidatedToken"/>.
/// </summary>
/// <param name="securityToken">The <see cref="SecurityToken"/> that was validated.</param>
/// <param name="tokenHandler">The <see cref="TokenHandler"/> that was used to validate the token.</param>
/// <param name="validationParameters">The <see cref="ValidationParameters"/> used to validate the token.</param>
/// <exception cref="ArgumentNullException">If <paramref name="securityToken"/>, <paramref name="tokenHandler"/>, or <paramref name="validationParameters"/> is null.</exception>
public ValidatedToken(
SecurityToken securityToken,
TokenHandler tokenHandler,
ValidationParameters validationParameters)
{
SecurityToken = securityToken ?? throw new ArgumentNullException(nameof(securityToken));
TokenHandler = tokenHandler ?? throw new ArgumentNullException(nameof(tokenHandler));
ValidationParameters = validationParameters ?? throw new ArgumentNullException(nameof(validationParameters));
}

/// <summary>
/// Logs the validation result.
/// </summary>
Expand All @@ -41,17 +49,17 @@ ActorValidationResult is not null
/// <summary>
/// The <see cref="SecurityToken"/> that was validated.
/// </summary>
public SecurityToken SecurityToken { get; private set; } = securityToken ?? throw new ArgumentNullException(nameof(securityToken));
public SecurityToken SecurityToken { get; }

/// <summary>
/// The <see cref="TokenHandler"/> that was used to validate the token.
/// </summary>
public TokenHandler TokenHandler { get; private set; } = tokenHandler ?? throw new ArgumentNullException(nameof(tokenHandler));
public TokenHandler TokenHandler { get; }

/// <summary>
/// The <see cref="ValidationParameters"/> that were used to validate the token.
/// </summary>
public ValidationParameters ValidationParameters { get; private set; } = validationParameters ?? throw new ArgumentNullException(nameof(validationParameters));
public ValidationParameters ValidationParameters { get; }

#region Validated Properties
/// <summary>
Expand Down

0 comments on commit 0cb18a9

Please sign in to comment.