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