refactor(IAsymCryptHandler): Umbenannt in ICryptograph

This commit is contained in:
Developer 02 2025-01-07 12:01:39 +01:00
parent e8c98115b6
commit d9d61368e3
4 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
namespace DigitalData.Core.Abstractions.Security
{
public interface IAsymCryptHandler : IAsymmetricKeyFactory
public interface ICryptograph : IAsymmetricKeyFactory
{
IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }

View File

@ -6,7 +6,7 @@ using Microsoft.Extensions.Options;
namespace DigitalData.Core.Security
{
public class AsymCryptHandler : RSAFactory<AsymCryptParams>, IAsymCryptHandler, IAsymmetricKeyFactory
public class AsymCryptHandler : RSAFactory<AsymCryptParams>, ICryptograph, IAsymmetricKeyFactory
{
public IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }

View File

@ -16,7 +16,7 @@ namespace DigitalData.Core.Security
private static IServiceCollection AddAsymCryptHandler(this IServiceCollection services) => services
.AddParamsConfigureOptions<AsymCryptParams>()
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<IAsymCryptHandler, AsymCryptHandler>();
.AddSingleton<ICryptograph, AsymCryptHandler>();
/// <summary>
/// Registers a custom asym crypt service with specified parameters from the given configuration section.

View File

@ -15,14 +15,14 @@ namespace DigitalData.Core.Security
private readonly TokenParams _params;
private readonly IAsymCryptHandler _cryptHandler;
private readonly ICryptograph _cryptograph;
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<TokenParams> tokenParamOptions, IAsymCryptHandler asymCryptHandler)
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<TokenParams> tokenParamOptions, ICryptograph cryptograph)
{
_claimDescriptor = claimDescriptorOptions.Value;
_mapper = mapper;
_params = tokenParamOptions.Value;
_cryptHandler = asymCryptHandler;
_cryptograph = cryptograph;
}
public SecurityToken CreateToken(TPrincipal subject, TokenDescription description)
@ -38,7 +38,7 @@ namespace DigitalData.Core.Security
var description = _params.Descriptions?.Get(issuer: issuer, audience: audience)
?? throw new InvalidOperationException($"No or multiple token description found for issuer '{issuer}' and audience '{audience}'.");
description.SigningCredentials = _cryptHandler.PrivateKeys
description.SigningCredentials = _cryptograph.PrivateKeys
.Get(issuer: issuer, audience: audience)
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);
@ -50,7 +50,7 @@ namespace DigitalData.Core.Security
var description = _params.Descriptions.SingleOrDefault(description => description.ApiRoute == apiRoute)
?? throw new InvalidOperationException($"No or multiple token description found for api route '{apiRoute}'.");
description.SigningCredentials = _cryptHandler.PrivateKeys
description.SigningCredentials = _cryptograph.PrivateKeys
.Get(issuer: description.Issuer, audience: description.Audience)
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);