Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add base methods to tokenhandler #2630

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Microsoft.IdentityModel.Tokens/TokenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.ComponentModel;
using System.Security.Claims;
using System.Text.Json;
using System.Threading.Tasks;
using static Microsoft.IdentityModel.Logging.LogHelper;

Expand Down Expand Up @@ -53,8 +54,23 @@ public int TokenLifetimeInMinutes
set => _defaultTokenLifetimeInMinutes = (value < 1) ? throw LogExceptionMessage(new ArgumentOutOfRangeException(nameof(value), FormatInvariant(LogMessages.IDX10104, LogHelper.MarkAsNonPII(value)))) : value;
}

/// <summary>
/// Gets the <see cref="JsonTokenType"/> of the token.
/// </summary>
public JsonTokenType TokenType { get; }
westin-m marked this conversation as resolved.
Show resolved Hide resolved

#region methods

/// <summary>
/// Validates a token.
/// On a validation failure, no exception will be thrown; instead, the exception will be set in the returned TokenValidationResult.Exception property.
/// Callers should always check the TokenValidationResult.IsValid property to verify the validity of the result.
/// </summary>
/// <param name="token">The token to be validated.</param>
/// <param name="validationParameters">A <see cref="TokenValidationParameters"/> required for validation.</param>
/// <returns>A <see cref="TokenValidationResult"/></returns>
public virtual TokenValidationResult ValidateToken(string token, TokenValidationParameters validationParameters) => throw new NotImplementedException();

/// <summary>
/// Validates a token.
/// On a validation failure, no exception will be thrown; instead, the exception will be set in the returned TokenValidationResult.Exception property.
Expand All @@ -75,6 +91,21 @@ public int TokenLifetimeInMinutes
/// <returns>A <see cref="TokenValidationResult"/></returns>
public virtual Task<TokenValidationResult> ValidateTokenAsync(SecurityToken token, TokenValidationParameters validationParameters) => throw new NotImplementedException();

/// <summary>
/// Evaluates whether a token can be converted into an instance of <see cref="SecurityToken"/>.
/// </summary>
/// <param name="token">The string to be evaluated.</param>
/// <returns>A <see cref="bool"/>.</returns>
public virtual bool CanReadToken(string token) => throw new NotImplementedException();

/// <summary>
/// Creates a token as described by the provided <see cref="SecurityTokenDescriptor"/>.
/// </summary>
/// <param name="tokenDescriptor">The <see cref="SecurityTokenDescriptor"/> used to create the token.</param>
/// <returns>A <see cref="string"/>.</returns>
/// <exception cref="NotImplementedException"></exception>
public virtual string CreateToken(SecurityTokenDescriptor tokenDescriptor) => throw new NotImplementedException();
westin-m marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Converts a string into an instance of <see cref="SecurityToken"/>.
/// </summary>
Expand Down
Loading