From baf1f5e045fc467f087ff7bd686d55083f98bb68 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 5 Dec 2024 14:58:44 +0100 Subject: [PATCH] =?UTF-8?q?refactor(CryptographerExtensions):=20Aktualisie?= =?UTF-8?q?rt,=20um=20IRSACryptographer=20anstelle=20von=20RSACryptographe?= =?UTF-8?q?r=20zu=20verwenden,=20um=20die=20Abstraktion=20zu=20erh=C3=B6he?= =?UTF-8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cryptographer/CryptographerExtensions.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/DigitalData.Core.Security/Cryptographer/CryptographerExtensions.cs b/DigitalData.Core.Security/Cryptographer/CryptographerExtensions.cs index 5c892c5..47ce618 100644 --- a/DigitalData.Core.Security/Cryptographer/CryptographerExtensions.cs +++ b/DigitalData.Core.Security/Cryptographer/CryptographerExtensions.cs @@ -1,24 +1,26 @@ -namespace DigitalData.Core.Security.Cryptographer +using DigitalData.Core.Abstractions.Security; + +namespace DigitalData.Core.Security.Cryptographer { public static class CryptographerExtensions { - public static IEnumerable GetByIssuer(this IEnumerable cryptographers, string issuer) where TRSACryptographer: RSACryptographer + public static IEnumerable GetByIssuer(this IEnumerable cryptographers, string issuer) where TRSACryptographer: IRSACryptographer => cryptographers.Where(c => c.Issuer == issuer); - public static IEnumerable GetByAudience(this IEnumerable cryptographers, string audience) where TRSACryptographer : RSACryptographer + public static IEnumerable GetByAudience(this IEnumerable cryptographers, string audience) where TRSACryptographer : IRSACryptographer => cryptographers.Where(c => c.Audience == audience); - public static TRSACryptographer Get(this IEnumerable cryptographers, string issuer, string audience) where TRSACryptographer : RSACryptographer + public static TRSACryptographer Get(this IEnumerable cryptographers, string issuer, string audience) where TRSACryptographer : IRSACryptographer => cryptographers.Where(c => c.Issuer == issuer && c.Audience == audience).SingleOrDefault() ?? throw new InvalidOperationException($"No {typeof(TRSACryptographer).GetType().Name.TrimStart('I')} found with Issuer: {issuer} and Audience: {audience}."); - public static bool TryGet(this IEnumerable cryptographers, string issuer, string audience, out TRSACryptographer? cryptographer) where TRSACryptographer : RSACryptographer + public static bool TryGet(this IEnumerable cryptographers, string issuer, string audience, out TRSACryptographer? cryptographer) where TRSACryptographer : IRSACryptographer { cryptographer = cryptographers.SingleOrDefault(c => c.Issuer == issuer && c.Audience == audience); return cryptographer is not null; } - public static RSACryptographerList ToCryptographerList(this IEnumerable cryptographers, Func keyGenerator) where TRSACryptographer : RSACryptographer + public static RSACryptographerList ToCryptographerList(this IEnumerable cryptographers, Func keyGenerator) where TRSACryptographer : IRSACryptographer => new(keyGenerator: keyGenerator, cryptographers: cryptographers); } } \ No newline at end of file