From 9158933333737fb363086307d536d541df1da3e1 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 30 Jun 2025 14:36:55 +0200 Subject: [PATCH] Refactor security key handling and culture info setup Updated `IssuerSigningKeyResolver` to use array syntax for returning security keys. Changed supported culture names declaration to use square brackets and modified the creation of the `CultureInfo` list to utilize the spread operator. Adjusted exception handling to throw `InvalidOperationException` when no supported culture is found. --- EnvelopeGenerator.GeneratorAPI/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/EnvelopeGenerator.GeneratorAPI/Program.cs b/EnvelopeGenerator.GeneratorAPI/Program.cs index fbc06fd9..02390820 100644 --- a/EnvelopeGenerator.GeneratorAPI/Program.cs +++ b/EnvelopeGenerator.GeneratorAPI/Program.cs @@ -129,7 +129,7 @@ try { var clientParams = deferredProvider.GetOptions(); var publicKey = clientParams!.PublicKeys.Get(authTokenKeys.Issuer, authTokenKeys.Audience); - return new List() { publicKey.SecurityKey }; + return [publicKey.SecurityKey]; }, ValidateIssuer = true, ValidIssuer = authTokenKeys.Issuer, @@ -205,10 +205,10 @@ try app.UseCors("AllowSpecificOriginsPolicy"); // Localizer - string[] supportedCultureNames = { "de-DE", "en-US" }; - IList list = supportedCultureNames.Select((string cn) => new CultureInfo(cn)).ToList(); - CultureInfo cultureInfo = list.FirstOrDefault() ?? throw new ArgumentNullException("supportedCultureNames", "Supported cultures cannot be empty."); - RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions + string[] supportedCultureNames = ["de-DE", "en-US"]; + IList list = [.. supportedCultureNames.Select(cn => new CultureInfo(cn))]; + var cultureInfo = list.FirstOrDefault() ?? throw new InvalidOperationException("There is no supported culture."); + var requestLocalizationOptions = new RequestLocalizationOptions { SupportedCultures = list, SupportedUICultures = list