namespace IdentityShroud.Core; public class JwtSignerFactory(IEnumerable signers) : IJwtSignerFactory { private readonly IReadOnlyDictionary _signers = signers .SelectMany(s => s.Algorithms.Select(alg => (alg, signer: s))) .ToDictionary(x => x.alg, x => x.signer); public IJwtSigner Create(JwtSigAlgName algorithm) { if (_signers.TryGetValue(algorithm, out var signer)) return signer; throw new NotSupportedException($"JWT signing algorithm '{algorithm}' is not registered."); } }