refactor: Umbenennung von CryptoFactory in RSAPool und ICryptoFactory in IAsymmetricKeyPool

This commit is contained in:
Developer 02 2025-03-14 10:47:28 +01:00
parent 0523308083
commit b8de148c52
6 changed files with 30 additions and 32 deletions

View File

@ -1,7 +1,7 @@
using System.Security.Cryptography;
namespace DigitalData.Core.Abstractions.Security
{
namespace DigitalData.Core.Abstractions.Security;
public interface IAsymmetricKeyFactory
{
string CreatePrivateKeyPem(int? keySizeInBits = null, bool encrypt = false);
@ -20,4 +20,3 @@ namespace DigitalData.Core.Abstractions.Security
IAsymmetricDecryptor CreateDecryptor(string pem, string? issuer = null, string? audience = null, bool encrypt = false, RSAEncryptionPadding? padding = null);
}
}

View File

@ -0,0 +1,10 @@
namespace DigitalData.Core.Abstractions.Security;
public interface IAsymmetricKeyPool : IAsymmetricKeyFactory
{
IEnumerable<IAsymmetricDecryptor> Decryptors { get; }
IAsymmetricDecryptor VaultDecryptor { get; }
IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; }
}

View File

@ -1,11 +0,0 @@
namespace DigitalData.Core.Abstractions.Security
{
public interface ICryptoFactory : IAsymmetricKeyFactory
{
IEnumerable<IAsymmetricDecryptor> Decryptors { get; }
IAsymmetricDecryptor VaultDecryptor { get; }
IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; }
}
}

View File

@ -19,7 +19,7 @@ namespace DigitalData.Core.Security
public static IServiceCollection AddCryptoFactory(this IServiceCollection services, IConfiguration configuration) => services
.Configure<CryptoFactoryParams>(configuration)
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<ICryptoFactory, CryptoFactory>()
.AddSingleton<IAsymmetricKeyPool, RSAPool>()
.AddSingleton<IAsymmetricKeyFactory, RSAFactory>()
.AddHostedService<PemFileInitalizer>();

View File

@ -13,9 +13,9 @@ public class JwtSignatureHandler<TPrincipal> : JwtSecurityTokenHandler, IJwtSign
private readonly IMapper _mapper;
private readonly ICryptoFactory _cryptoFactory;
private readonly IAsymmetricKeyPool _cryptoFactory;
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, ICryptoFactory cryptoFactory)
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IAsymmetricKeyPool cryptoFactory)
{
_claimDescriptor = claimDescriptorOptions.Value;
_mapper = mapper;

View File

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
namespace DigitalData.Core.Security.Services;
public class CryptoFactory : RSAFactory, ICryptoFactory, IAsymmetricKeyFactory
public class RSAPool : RSAFactory, IAsymmetricKeyPool, IAsymmetricKeyFactory
{
private readonly CryptoFactoryParams _params;
@ -18,7 +18,7 @@ public class CryptoFactory : RSAFactory, ICryptoFactory, IAsymmetricKeyFactory
public IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; init; } = new List<IAsymmetricTokenDescriptor>();
public CryptoFactory(IOptions<CryptoFactoryParams> cryptoFactoryParamsOptions, ILogger<CryptoFactory>? logger = null)
public RSAPool(IOptions<CryptoFactoryParams> cryptoFactoryParamsOptions, ILogger<RSAPool>? logger = null)
{
_params = cryptoFactoryParamsOptions.Value;