From 079f0c69c7eb673c15fb116eae161e97b08011ec Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 9 Jan 2025 20:10:45 +0100 Subject: [PATCH] fix(Kryptograph): Umbenannt in Krypto-Fabrik. --- .../Security/{ICryptograph.cs => ICryptoFactory.cs} | 2 +- .../{Cryptograph.cs => CryptoFactory.cs} | 4 ++-- DigitalData.Core.Security/DIExtensions.cs | 2 +- DigitalData.Core.Security/JwtSignatureHandler.cs | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) rename DigitalData.Core.Abstractions/Security/{ICryptograph.cs => ICryptoFactory.cs} (81%) rename DigitalData.Core.Security/{Cryptograph.cs => CryptoFactory.cs} (87%) diff --git a/DigitalData.Core.Abstractions/Security/ICryptograph.cs b/DigitalData.Core.Abstractions/Security/ICryptoFactory.cs similarity index 81% rename from DigitalData.Core.Abstractions/Security/ICryptograph.cs rename to DigitalData.Core.Abstractions/Security/ICryptoFactory.cs index 7f67228..09316a1 100644 --- a/DigitalData.Core.Abstractions/Security/ICryptograph.cs +++ b/DigitalData.Core.Abstractions/Security/ICryptoFactory.cs @@ -1,6 +1,6 @@ namespace DigitalData.Core.Abstractions.Security { - public interface ICryptograph : IAsymmetricKeyFactory + public interface ICryptoFactory : IAsymmetricKeyFactory { IEnumerable Decryptors { get; } diff --git a/DigitalData.Core.Security/Cryptograph.cs b/DigitalData.Core.Security/CryptoFactory.cs similarity index 87% rename from DigitalData.Core.Security/Cryptograph.cs rename to DigitalData.Core.Security/CryptoFactory.cs index 818c784..661f6f2 100644 --- a/DigitalData.Core.Security/Cryptograph.cs +++ b/DigitalData.Core.Security/CryptoFactory.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Options; namespace DigitalData.Core.Security { - public class Cryptograph : RSAFactory, ICryptograph, IAsymmetricKeyFactory + public class CryptoFactory : RSAFactory, ICryptoFactory, IAsymmetricKeyFactory { public IEnumerable Decryptors { get; } @@ -17,7 +17,7 @@ namespace DigitalData.Core.Security public IEnumerable TokenDescriptors { get; init; } = new List(); - public Cryptograph(IOptions options, ILogger? logger = null) : base(options) + public CryptoFactory(IOptions options, ILogger? logger = null) : base(options) { logger?.LogInformation("Core.Secrets version: {Version}, Created on: {CreationDate}.", Secrets.Version, Secrets.CreationDate.ToString("dd.MM.yyyy")); diff --git a/DigitalData.Core.Security/DIExtensions.cs b/DigitalData.Core.Security/DIExtensions.cs index cb3a1a8..d1e9534 100644 --- a/DigitalData.Core.Security/DIExtensions.cs +++ b/DigitalData.Core.Security/DIExtensions.cs @@ -16,7 +16,7 @@ namespace DigitalData.Core.Security private static IServiceCollection AddCryptograph(this IServiceCollection services) => services .AddParamsConfigureOptions() .AddAutoMapper(typeof(MappingProfile).Assembly) - .AddSingleton(); + .AddSingleton(); /// /// Registers a custom asym crypt service with specified parameters from the given configuration section. diff --git a/DigitalData.Core.Security/JwtSignatureHandler.cs b/DigitalData.Core.Security/JwtSignatureHandler.cs index cfaa009..007bb74 100644 --- a/DigitalData.Core.Security/JwtSignatureHandler.cs +++ b/DigitalData.Core.Security/JwtSignatureHandler.cs @@ -13,13 +13,13 @@ namespace DigitalData.Core.Security private readonly IMapper _mapper; - private readonly ICryptograph _cryptograph; + private readonly ICryptoFactory _cryptoFactory; - public JwtSignatureHandler(IOptions> claimDescriptorOptions, IMapper mapper, ICryptograph cryptograph) + public JwtSignatureHandler(IOptions> claimDescriptorOptions, IMapper mapper, ICryptoFactory cryptoFactory) { _claimDescriptor = claimDescriptorOptions.Value; _mapper = mapper; - _cryptograph = cryptograph; + _cryptoFactory = cryptoFactory; } public SecurityToken CreateToken(TPrincipal subject, IAsymmetricTokenDescriptor descriptor) @@ -32,14 +32,14 @@ namespace DigitalData.Core.Security public SecurityToken CreateToken(TPrincipal subject, string issuer, string audience) { - var descriptor = _cryptograph.TokenDescriptors.Get(issuer: issuer, audience: audience) + var descriptor = _cryptoFactory.TokenDescriptors.Get(issuer: issuer, audience: audience) ?? throw new InvalidOperationException($"No or multiple token description found for issuer '{issuer}' and audience '{audience}'."); return CreateToken(subject: subject, descriptor: descriptor); } public SecurityToken CreateToken(TPrincipal subject, string apiRoute) { - var desc = _cryptograph.TokenDescriptors.SingleOrDefault(desc => desc.ApiRoute == apiRoute) + var desc = _cryptoFactory.TokenDescriptors.SingleOrDefault(desc => desc.ApiRoute == apiRoute) ?? throw new InvalidOperationException($"No or multiple token description found for api route '{apiRoute}'."); return CreateToken(subject: subject, descriptor: desc);