refactor: Umbenennung von CryptoFactory in RSAPool und ICryptoFactory in IAsymmetricKeyPool
This commit is contained in:
parent
0523308083
commit
b8de148c52
@ -1,23 +1,22 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace DigitalData.Core.Abstractions.Security
|
namespace DigitalData.Core.Abstractions.Security;
|
||||||
|
|
||||||
|
public interface IAsymmetricKeyFactory
|
||||||
{
|
{
|
||||||
public interface IAsymmetricKeyFactory
|
string CreatePrivateKeyPem(int? keySizeInBits = null, bool encrypt = false);
|
||||||
{
|
|
||||||
string CreatePrivateKeyPem(int? keySizeInBits = null, bool encrypt = false);
|
|
||||||
|
|
||||||
string CreateEncryptedPrivateKeyPem(
|
string CreateEncryptedPrivateKeyPem(
|
||||||
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,
|
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,
|
||||||
HashAlgorithmName? hashAlgorithmName = null,
|
HashAlgorithmName? hashAlgorithmName = null,
|
||||||
int? iterationCount = null,
|
int? iterationCount = null,
|
||||||
int? keySizeInBits = null,
|
int? keySizeInBits = null,
|
||||||
string? password = null);
|
string? password = null);
|
||||||
|
|
||||||
string CreateEncryptedPrivateKeyPem(
|
string CreateEncryptedPrivateKeyPem(
|
||||||
PbeParameters pbeParameters,
|
PbeParameters pbeParameters,
|
||||||
int? keySizeInBits = null,
|
int? keySizeInBits = null,
|
||||||
string? password = null);
|
string? password = null);
|
||||||
|
|
||||||
IAsymmetricDecryptor CreateDecryptor(string pem, string? issuer = null, string? audience = null, bool encrypt = false, RSAEncryptionPadding? padding = null);
|
IAsymmetricDecryptor CreateDecryptor(string pem, string? issuer = null, string? audience = null, bool encrypt = false, RSAEncryptionPadding? padding = null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
10
DigitalData.Core.Abstractions/Security/IAsymmetricKeyPool.cs
Normal file
10
DigitalData.Core.Abstractions/Security/IAsymmetricKeyPool.cs
Normal 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; }
|
||||||
|
}
|
||||||
@ -1,11 +0,0 @@
|
|||||||
namespace DigitalData.Core.Abstractions.Security
|
|
||||||
{
|
|
||||||
public interface ICryptoFactory : IAsymmetricKeyFactory
|
|
||||||
{
|
|
||||||
IEnumerable<IAsymmetricDecryptor> Decryptors { get; }
|
|
||||||
|
|
||||||
IAsymmetricDecryptor VaultDecryptor { get; }
|
|
||||||
|
|
||||||
IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -19,7 +19,7 @@ namespace DigitalData.Core.Security
|
|||||||
public static IServiceCollection AddCryptoFactory(this IServiceCollection services, IConfiguration configuration) => services
|
public static IServiceCollection AddCryptoFactory(this IServiceCollection services, IConfiguration configuration) => services
|
||||||
.Configure<CryptoFactoryParams>(configuration)
|
.Configure<CryptoFactoryParams>(configuration)
|
||||||
.AddAutoMapper(typeof(MappingProfile).Assembly)
|
.AddAutoMapper(typeof(MappingProfile).Assembly)
|
||||||
.AddSingleton<ICryptoFactory, CryptoFactory>()
|
.AddSingleton<IAsymmetricKeyPool, RSAPool>()
|
||||||
.AddSingleton<IAsymmetricKeyFactory, RSAFactory>()
|
.AddSingleton<IAsymmetricKeyFactory, RSAFactory>()
|
||||||
.AddHostedService<PemFileInitalizer>();
|
.AddHostedService<PemFileInitalizer>();
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,9 @@ public class JwtSignatureHandler<TPrincipal> : JwtSecurityTokenHandler, IJwtSign
|
|||||||
|
|
||||||
private readonly IMapper _mapper;
|
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;
|
_claimDescriptor = claimDescriptorOptions.Value;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
|
|||||||
|
|
||||||
namespace DigitalData.Core.Security.Services;
|
namespace DigitalData.Core.Security.Services;
|
||||||
|
|
||||||
public class CryptoFactory : RSAFactory, ICryptoFactory, IAsymmetricKeyFactory
|
public class RSAPool : RSAFactory, IAsymmetricKeyPool, IAsymmetricKeyFactory
|
||||||
{
|
{
|
||||||
private readonly CryptoFactoryParams _params;
|
private readonly CryptoFactoryParams _params;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public class CryptoFactory : RSAFactory, ICryptoFactory, IAsymmetricKeyFactory
|
|||||||
|
|
||||||
public IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; init; } = new List<IAsymmetricTokenDescriptor>();
|
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;
|
_params = cryptoFactoryParamsOptions.Value;
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user