diff --git a/Directory.Packages.props b/Directory.Packages.props
index a1075dac..c90bf9c6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -25,6 +25,7 @@
+
diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs
index 82f213d3..a26e73fb 100644
--- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs
+++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs
@@ -5,6 +5,7 @@
*/
using System.Buffers.Binary;
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
@@ -18,7 +19,6 @@ using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using Microsoft.IdentityModel.Tokens;
using Microsoft.Net.Http.Headers;
using Properties = OpenIddict.Client.AspNetCore.OpenIddictClientAspNetCoreConstants.Properties;
@@ -421,7 +421,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
try
{
// Extract the payload and validate the version marker.
- var payload = Base64UrlEncoder.DecodeBytes(value);
+ var payload = Base64Url.DecodeFromChars(value);
if (payload.Length < (1 + sizeof(uint)) || payload[0] is not 0x01)
{
context.Reject(
@@ -818,7 +818,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
Debug.Assert(written == count, SR.FormatID4016(written, count));
// Add the correlation cookie to the response headers.
- response.Cookies.Append(name, Base64UrlEncoder.Encode(payload), options);
+ response.Cookies.Append(name, Base64Url.EncodeToString(payload), options);
return ValueTask.CompletedTask;
}
@@ -1041,7 +1041,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
Debug.Assert(written == count, SR.FormatID4016(written, count));
// Add the correlation cookie to the response headers.
- response.Cookies.Append(name, Base64UrlEncoder.Encode(payload), options);
+ response.Cookies.Append(name, Base64Url.EncodeToString(payload), options);
return ValueTask.CompletedTask;
}
diff --git a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs
index 4b8975ec..b8eb47a7 100644
--- a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs
+++ b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs
@@ -4,12 +4,12 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Security.Claims;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using Microsoft.IdentityModel.Tokens;
using static OpenIddict.Client.DataProtection.OpenIddictClientDataProtectionConstants.Purposes;
using static OpenIddict.Client.OpenIddictClientHandlers.Protection;
using Schemes = OpenIddict.Client.DataProtection.OpenIddictClientDataProtectionConstants.Purposes.Schemes;
@@ -134,7 +134,7 @@ public static partial class OpenIddictClientDataProtectionHandlers
try
{
- using var buffer = new MemoryStream(protector.Unprotect(Base64UrlEncoder.DecodeBytes(context.Token)));
+ using var buffer = new MemoryStream(protector.Unprotect(Base64Url.DecodeFromChars(context.Token)));
using var reader = new BinaryReader(buffer);
// Note: since the data format relies on a data protector using different "purposes" strings
@@ -247,7 +247,7 @@ public static partial class OpenIddictClientDataProtectionHandlers
_options.CurrentValue.Formatter.WriteToken(writer, context.Principal);
- context.Token = Base64UrlEncoder.Encode(protector.Protect(buffer.ToArray()));
+ context.Token = Base64Url.EncodeToString(protector.Protect(buffer.ToArray()));
context.Logger.LogTrace(6016, SR.GetResourceString(SR.ID6016), context.TokenType,
context.Token, context.Principal.Claims);
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
index 24714ad7..af6d3e70 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
@@ -5,6 +5,7 @@
*/
using System.Buffers.Binary;
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
@@ -15,7 +16,6 @@ using System.Text.Json;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
-using Microsoft.IdentityModel.Tokens;
using Owin;
using static OpenIddict.Client.Owin.OpenIddictClientOwinConstants;
using Properties = OpenIddict.Client.Owin.OpenIddictClientOwinConstants.Properties;
@@ -432,7 +432,7 @@ public static partial class OpenIddictClientOwinHandlers
try
{
// Extract the payload and validate the version marker.
- var payload = Base64UrlEncoder.DecodeBytes(value);
+ var payload = Base64Url.DecodeFromChars(value);
if (payload.Length < (1 + sizeof(uint)) || payload[0] is not 0x01)
{
context.Reject(
@@ -846,7 +846,7 @@ public static partial class OpenIddictClientOwinHandlers
_options.CurrentValue.CookieOptions);
// Add the correlation cookie to the response headers.
- manager.AppendResponseCookie(response.Context, name, Base64UrlEncoder.Encode(payload), new CookieOptions
+ manager.AppendResponseCookie(response.Context, name, Base64Url.EncodeToString(payload), new CookieOptions
{
Domain = options.Domain,
HttpOnly = options.HttpOnly,
@@ -1090,7 +1090,7 @@ public static partial class OpenIddictClientOwinHandlers
_options.CurrentValue.CookieOptions);
// Add the correlation cookie to the response headers.
- manager.AppendResponseCookie(response.Context, name, Base64UrlEncoder.Encode(payload), new CookieOptions
+ manager.AppendResponseCookie(response.Context, name, Base64Url.EncodeToString(payload), new CookieOptions
{
Domain = options.Domain,
HttpOnly = options.HttpOnly,
diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
index 06aa54f7..867b62f8 100644
--- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
+++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.ComponentModel;
using System.IO.Pipes;
using System.Net;
@@ -14,7 +15,6 @@ using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
-using Microsoft.IdentityModel.Tokens;
using static OpenIddict.Client.SystemIntegration.OpenIddictClientSystemIntegrationAuthenticationMode;
namespace OpenIddict.Client.SystemIntegration;
@@ -96,13 +96,13 @@ public sealed class OpenIddictClientSystemIntegrationConfiguration : IConfigureO
// Note: only the left-most half of the hash is used to limit the length of the resulting discriminator,
// which is required on platforms like macOS, where the name of pipes is always prefixed with a static part
// (e.g /var/folders/5j/jjxtct5j1gvg35z6sdh2fz0w0000gn/T/CoreFxPipe_) and must not exceed 104 characters.
- options.ApplicationDiscriminator = Base64UrlEncoder.Encode(digest, 0, digest.Length / 2);
+ options.ApplicationDiscriminator = Base64Url.EncodeToString(digest.AsSpan(0, digest.Length / 2));
}
// If no explicit instance identifier was specified, use a 96-bit random identifier.
if (string.IsNullOrEmpty(options.InstanceIdentifier))
{
- options.InstanceIdentifier = Base64UrlEncoder.Encode(RandomNumberGenerator.GetBytes(count: 96 / 8));
+ options.InstanceIdentifier = Base64Url.EncodeToString(RandomNumberGenerator.GetBytes(count: 96 / 8));
}
// If no explicit pipe name was specified, build one using the application discriminator.
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
index 585cf772..8823c8eb 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpContext.cs
@@ -4,11 +4,11 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.ComponentModel;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
-using Microsoft.IdentityModel.Tokens;
namespace OpenIddict.Client.SystemNetHttp;
@@ -61,6 +61,6 @@ public sealed class OpenIddictClientSystemNetHttpContext
algorithm.TransformFinalBlock([], 0, 0);
- return Base64UrlEncoder.Encode(algorithm.Hash);
+ return Base64Url.EncodeToString(algorithm.Hash);
}
}
diff --git a/src/OpenIddict.Client/OpenIddict.Client.csproj b/src/OpenIddict.Client/OpenIddict.Client.csproj
index a244ca3d..590c71f9 100644
--- a/src/OpenIddict.Client/OpenIddict.Client.csproj
+++ b/src/OpenIddict.Client/OpenIddict.Client.csproj
@@ -26,6 +26,7 @@ To use the client feature on ASP.NET Core or OWIN/Katana, reference the OpenIddi
+
diff --git a/src/OpenIddict.Client/OpenIddictClientConfiguration.cs b/src/OpenIddict.Client/OpenIddictClientConfiguration.cs
index 664b3fec..0d5e9a66 100644
--- a/src/OpenIddict.Client/OpenIddictClientConfiguration.cs
+++ b/src/OpenIddict.Client/OpenIddictClientConfiguration.cs
@@ -4,11 +4,11 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
-using System.Security.Cryptography.X509Certificates;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@@ -178,14 +178,14 @@ public sealed class OpenIddictClientConfiguration : IPostConfigureOptions Base64UrlEncoder.Encode(
+ CodeChallengeMethods.Sha256 => Base64Url.EncodeToString(
SHA256.HashData(Encoding.ASCII.GetBytes(context.CodeVerifier))),
_ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0045))
@@ -5921,7 +5922,7 @@ public static partial class OpenIddictClientHandlers
context.ResponseType?.Split(Separators.Space) is IList types &&
(types.Contains(ResponseTypes.Code) || types.Contains(ResponseTypes.IdToken)))
{
- context.Request.Nonce = Base64UrlEncoder.Encode(
+ context.Request.Nonce = Base64Url.EncodeToString(
SHA256.HashData(Encoding.UTF8.GetBytes(context.Nonce)));
}
@@ -9180,7 +9181,7 @@ public static partial class OpenIddictClientHandlers
// Generate a new crypto-secure random identifier that will
// be used as the non-guessable part of the state token.
- context.RequestForgeryProtection = Base64UrlEncoder.Encode(
+ context.RequestForgeryProtection = Base64Url.EncodeToString(
RandomNumberGenerator.GetBytes(count: 256 / 8));
return ValueTask.CompletedTask;
@@ -9207,7 +9208,7 @@ public static partial class OpenIddictClientHandlers
ArgumentNullException.ThrowIfNull(context);
// Generate a new crypto-secure random identifier that will be used as the nonce.
- context.Nonce = Base64UrlEncoder.Encode(RandomNumberGenerator.GetBytes(count: 256 / 8));
+ context.Nonce = Base64Url.EncodeToString(RandomNumberGenerator.GetBytes(count: 256 / 8));
return ValueTask.CompletedTask;
}
diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs
index 2d78e6a7..7923a83a 100644
--- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs
+++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs
@@ -4,12 +4,12 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Security.Claims;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using Microsoft.IdentityModel.Tokens;
using static OpenIddict.Server.DataProtection.OpenIddictServerDataProtectionConstants.Purposes;
using static OpenIddict.Server.OpenIddictServerHandlers.Protection;
using Schemes = OpenIddict.Server.DataProtection.OpenIddictServerDataProtectionConstants.Purposes.Schemes;
@@ -229,7 +229,7 @@ public static partial class OpenIddictServerDataProtectionHandlers
try
{
- using var buffer = new MemoryStream(protector.Unprotect(Base64UrlEncoder.DecodeBytes(context.Token)));
+ using var buffer = new MemoryStream(protector.Unprotect(Base64Url.DecodeFromChars(context.Token)));
using var reader = new BinaryReader(buffer);
// Note: since the data format relies on a data protector using different "purposes" strings
@@ -382,7 +382,7 @@ public static partial class OpenIddictServerDataProtectionHandlers
_options.CurrentValue.Formatter.WriteToken(writer, context.Principal);
- context.Token = Base64UrlEncoder.Encode(protector.Protect(buffer.ToArray()));
+ context.Token = Base64Url.EncodeToString(protector.Protect(buffer.ToArray()));
context.Logger.LogTrace(6016, SR.GetResourceString(SR.ID6016), context.TokenType,
context.Token, context.Principal.Claims);
diff --git a/src/OpenIddict.Server/OpenIddict.Server.csproj b/src/OpenIddict.Server/OpenIddict.Server.csproj
index 0566a426..12cf0c52 100644
--- a/src/OpenIddict.Server/OpenIddict.Server.csproj
+++ b/src/OpenIddict.Server/OpenIddict.Server.csproj
@@ -24,6 +24,7 @@ To use the server feature on ASP.NET Core or OWIN/Katana, reference the OpenIddi
+
diff --git a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs
index b11d82b7..4930ac04 100644
--- a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs
+++ b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
@@ -141,14 +142,14 @@ public sealed class OpenIddictServerConfiguration : IPostConfigureOptions context.Request.CodeVerifier,
- CodeChallengeMethods.Sha256 => Base64UrlEncoder.Encode(
+ CodeChallengeMethods.Sha256 => Base64Url.EncodeToString(
SHA256.HashData(Encoding.ASCII.GetBytes(context.Request.CodeVerifier))),
null or { Length: 0 } => throw new InvalidOperationException(SR.GetResourceString(SR.ID0268)),
diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
index 7398f7a2..6ba9cb42 100644
--- a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
+++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
@@ -1179,7 +1180,7 @@ public static partial class OpenIddictServerHandlers
// If the thumbprint of the certificate doesn't match the hash
// resolved from the confirmation claim, return an error.
- var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256));
+ var hash = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256));
if (!CryptographicOperations.FixedTimeEquals(
left : MemoryMarshal.AsBytes(hash),
right: MemoryMarshal.AsBytes(thumbprint)))
@@ -1844,7 +1845,7 @@ public static partial class OpenIddictServerHandlers
else
{
// For other tokens, generate a base64url-encoded 256-bit random identifier.
- descriptor.ReferenceId = Base64UrlEncoder.Encode(RandomNumberGenerator.GetBytes(count: 256 / 8));
+ descriptor.ReferenceId = Base64Url.EncodeToString(RandomNumberGenerator.GetBytes(count: 256 / 8));
}
}
diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.cs
index b97512b4..29765677 100644
--- a/src/OpenIddict.Server/OpenIddictServerHandlers.cs
+++ b/src/OpenIddict.Server/OpenIddictServerHandlers.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
@@ -3667,7 +3668,7 @@ public static partial class OpenIddictServerHandlers
static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject
{
- [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256))
+ [JsonWebKeyParameterNames.X5tS256] = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256))
};
}
}
@@ -4196,7 +4197,7 @@ public static partial class OpenIddictServerHandlers
static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject
{
- [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256))
+ [JsonWebKeyParameterNames.X5tS256] = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256))
};
}
}
@@ -4489,7 +4490,7 @@ public static partial class OpenIddictServerHandlers
static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject
{
- [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256))
+ [JsonWebKeyParameterNames.X5tS256] = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256))
};
}
}
@@ -5316,7 +5317,7 @@ public static partial class OpenIddictServerHandlers
// Note: only the left-most half of the hash is used.
// See http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
- context.IdentityTokenPrincipal.SetClaim(Claims.AccessTokenHash, Base64UrlEncoder.Encode(digest, 0, digest.Length / 2));
+ context.IdentityTokenPrincipal.SetClaim(Claims.AccessTokenHash, Base64Url.EncodeToString(digest.AsSpan(0, digest.Length / 2)));
}
if (!string.IsNullOrEmpty(context.AuthorizationCode))
@@ -5325,7 +5326,7 @@ public static partial class OpenIddictServerHandlers
// Note: only the left-most half of the hash is used.
// See http://openid.net/specs/openid-connect-core-1_0.html#HybridIDToken
- context.IdentityTokenPrincipal.SetClaim(Claims.CodeHash, Base64UrlEncoder.Encode(digest, 0, digest.Length / 2));
+ context.IdentityTokenPrincipal.SetClaim(Claims.CodeHash, Base64Url.EncodeToString(digest.AsSpan(0, digest.Length / 2)));
}
return ValueTask.CompletedTask;
diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs
index 1cc8cac9..e3d8d3b2 100644
--- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs
+++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs
@@ -4,12 +4,12 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Security.Claims;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using Microsoft.IdentityModel.Tokens;
using static OpenIddict.Validation.DataProtection.OpenIddictValidationDataProtectionConstants.Purposes;
using static OpenIddict.Validation.OpenIddictValidationHandlers.Protection;
using Schemes = OpenIddict.Validation.DataProtection.OpenIddictValidationDataProtectionConstants.Purposes.Schemes;
@@ -127,7 +127,7 @@ public static partial class OpenIddictValidationDataProtectionHandlers
try
{
- using var buffer = new MemoryStream(protector.Unprotect(Base64UrlEncoder.DecodeBytes(context.Token)));
+ using var buffer = new MemoryStream(protector.Unprotect(Base64Url.DecodeFromChars(context.Token)));
using var reader = new BinaryReader(buffer);
// Note: since the data format relies on a data protector using different "purposes" strings
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
index 25906d18..6f1f3954 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs
@@ -4,10 +4,10 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.ComponentModel;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using Microsoft.IdentityModel.Tokens;
namespace OpenIddict.Validation.SystemNetHttp;
@@ -52,6 +52,6 @@ public sealed class OpenIddictValidationSystemNetHttpContext
algorithm.TransformFinalBlock([], 0, 0);
- return Base64UrlEncoder.Encode(algorithm.Hash);
+ return Base64Url.EncodeToString(algorithm.Hash);
}
}
diff --git a/src/OpenIddict.Validation/OpenIddict.Validation.csproj b/src/OpenIddict.Validation/OpenIddict.Validation.csproj
index eb5469ca..6f475b77 100644
--- a/src/OpenIddict.Validation/OpenIddict.Validation.csproj
+++ b/src/OpenIddict.Validation/OpenIddict.Validation.csproj
@@ -24,6 +24,7 @@ To use the validation feature on ASP.NET Core or OWIN/Katana, reference the Open
+
diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs
index b1753420..a2bc7523 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
@@ -866,7 +867,7 @@ public static partial class OpenIddictValidationHandlers
// If the thumbprint of the certificate doesn't match the hash
// resolved from the confirmation claim, return an error.
- var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256));
+ var hash = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256));
if (!CryptographicOperations.FixedTimeEquals(
left : MemoryMarshal.AsBytes(hash),
right: MemoryMarshal.AsBytes(thumbprint)))
diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs
index d094de36..6484c875 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
@@ -921,7 +922,7 @@ public static partial class OpenIddictValidationHandlers
// If the thumbprint of the certificate doesn't match the hash
// resolved from the confirmation claim, return an error.
- var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256));
+ var hash = Base64Url.EncodeToString(certificate.GetCertHash(HashAlgorithmName.SHA256));
if (!CryptographicOperations.FixedTimeEquals(
left : MemoryMarshal.AsBytes(hash),
right: MemoryMarshal.AsBytes(thumbprint)))
diff --git a/test/OpenIddict.Client.Tests/OpenIddictClientConfigurationTests.cs b/test/OpenIddict.Client.Tests/OpenIddictClientConfigurationTests.cs
index 99a993f6..8af5e6c4 100644
--- a/test/OpenIddict.Client.Tests/OpenIddictClientConfigurationTests.cs
+++ b/test/OpenIddict.Client.Tests/OpenIddictClientConfigurationTests.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Protocols;
-using Microsoft.IdentityModel.Tokens;
using Moq;
using Xunit;
diff --git a/test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs b/test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs
index b5e5b9bd..8e014b64 100644
--- a/test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs
+++ b/test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs
@@ -5,7 +5,6 @@
*/
using System.Buffers.Binary;
-using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Security.Cryptography;
diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs
index b2f487e5..f0bb1f9b 100644
--- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs
+++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using System.Buffers.Text;
using System.Collections.Immutable;
using System.Net.Http;
using System.Security.Cryptography;
@@ -1486,8 +1487,8 @@ public abstract partial class OpenIddictServerIntegrationTests
Assert.Null(key?[JsonWebKeyParameterNames.P]);
Assert.Null(key?[JsonWebKeyParameterNames.Q]);
- Assert.Equal(parameters.Exponent, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.E]));
- Assert.Equal(parameters.Modulus, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.N]));
+ Assert.Equal(parameters.Exponent, Base64Url.DecodeFromChars((string?) key?[JsonWebKeyParameterNames.E]));
+ Assert.Equal(parameters.Modulus, Base64Url.DecodeFromChars((string?) key?[JsonWebKeyParameterNames.N]));
}
[Theory]
@@ -1537,8 +1538,8 @@ public abstract partial class OpenIddictServerIntegrationTests
// Assert
Assert.Null(key?[JsonWebKeyParameterNames.D]);
- Assert.Equal(parameters.Q.X, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.X]));
- Assert.Equal(parameters.Q.Y, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.Y]));
+ Assert.Equal(parameters.Q.X, Base64Url.DecodeFromChars((string?) key?[JsonWebKeyParameterNames.X]));
+ Assert.Equal(parameters.Q.Y, Base64Url.DecodeFromChars((string?) key?[JsonWebKeyParameterNames.Y]));
}
[SkippableFact(typeof(PlatformNotSupportedException))]
@@ -1563,7 +1564,7 @@ public abstract partial class OpenIddictServerIntegrationTests
// Assert
Assert.Equal(JsonWebAlgorithmsKeyTypes.Akp, (string?) key?[JsonWebKeyParameterNames.Kty]);
Assert.Equal(SecurityAlgorithms.MlDsa44, (string?) key?[JsonWebKeyParameterNames.Alg]);
- Assert.Equal(blob, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.Pub]));
+ Assert.Equal(blob, Base64Url.DecodeFromChars((string?) key?[JsonWebKeyParameterNames.Pub]));
}
[Fact]
diff --git a/test/OpenIddict.Validation.Tests/OpenIddictValidationBuilderTests.cs b/test/OpenIddict.Validation.Tests/OpenIddictValidationBuilderTests.cs
index 9409fbc5..09dfbec7 100644
--- a/test/OpenIddict.Validation.Tests/OpenIddictValidationBuilderTests.cs
+++ b/test/OpenIddict.Validation.Tests/OpenIddictValidationBuilderTests.cs
@@ -6,7 +6,6 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Moq;
-using OpenIddict.Abstractions;
using Xunit;
using static OpenIddict.Validation.OpenIddictValidationEvents;