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
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public IDictionary<string, string> InboundClaimTypeMap
/// <para>'false' if token.Length is greater than <see cref="TokenHandler.MaximumTokenSizeInBytes"/>.</para>
/// <para>'true' if the token is in JSON compact serialization format.</para>
/// </returns>
public virtual bool CanReadToken(string token)
public override bool CanReadToken(string token)
{
if (string.IsNullOrWhiteSpace(token))
return false;
Expand Down
11 changes: 0 additions & 11 deletions src/Microsoft.IdentityModel.Tokens/SecurityTokenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ public virtual bool CanReadToken(XmlReader reader)
return false;
}

/// <summary>
/// Indicates whether the current token string can be read as a token
/// of the type handled by this instance.
/// </summary>
/// <param name="tokenString">The token string thats needs to be read.</param>
/// <returns>'True' if the ReadToken method can parse the token string.</returns>
public virtual bool CanReadToken(string tokenString)
{
return false;
}

/// <summary>
/// Gets security token.
/// </summary>
Expand Down
23 changes: 23 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 @@ -75,6 +76,28 @@ public int TokenLifetimeInMinutes
/// <returns>A <see cref="TokenValidationResult"/></returns>
public virtual Task<TokenValidationResult> ValidateTokenAsync(SecurityToken token, TokenValidationParameters validationParameters) => throw new NotImplementedException();

/// <summary>
/// Indicates whether the current token string can be read as a token
/// of the type handled by this instance.
/// </summary>
/// <param name="tokenString">The token string thats needs to be read.</param>
/// <returns>'True' if the ReadToken method can parse the token string.</returns>
public virtual bool CanReadToken(string tokenString) => false;

/// <summary>
/// Creates a <see cref="SecurityToken"/> as a <see cref="string"/> 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 CreateSecurityTokenAsString(SecurityTokenDescriptor tokenDescriptor) => throw new NotImplementedException();

/// <summary>
/// Creates a <see cref="SecurityToken"/> as described by the provided <see cref="SecurityTokenDescriptor"/>.
/// </summary>
/// <param name="tokenDescriptor"><see cref="SecurityTokenDescriptor"/></param>
public virtual SecurityToken CreateSecurityToken(SecurityTokenDescriptor tokenDescriptor) => throw new NotImplementedException();

/// <summary>
/// Converts a string into an instance of <see cref="SecurityToken"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ internal static IDictionary<string, object> AddCtyClaimDefaultValue(IDictionary<
/// <para>'false' if token.Length is greater than <see cref="TokenHandler.MaximumTokenSizeInBytes"/>.</para>
/// <para>'true' if the token is in JSON compact serialization format.</para>
/// </returns>
public virtual bool CanReadToken(string token)
public override bool CanReadToken(string token)
{
if (string.IsNullOrWhiteSpace(token))
return false;
Expand Down
Loading