From ed29c9f9901dfe01e4cec345e99167e40240424f Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 19 Dec 2024 01:52:00 +0100 Subject: [PATCH] =?UTF-8?q?feat(RSACryptographer):=20RsaSecurityKey.get=20?= =?UTF-8?q?Eigenschaft=20mit=20Lazy=20Loading=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cryptographer/RSACryptographer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs index 8590139..f8d57ee 100644 --- a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs +++ b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs @@ -1,4 +1,5 @@ using DigitalData.Core.Abstractions.Security; +using Microsoft.IdentityModel.Tokens; using System.Reflection; using System.Security.Cryptography; @@ -24,8 +25,15 @@ namespace DigitalData.Core.Security.Cryptographer public string Audience { get; init; } = string.Empty; + private readonly Lazy _lazyRsaSecurityKey; + + public RsaSecurityKey RsaSecurityKey => _lazyRsaSecurityKey.Value; + #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - internal RSACryptographer() { } + internal RSACryptographer() + { + _lazyRsaSecurityKey = new(() => new RsaSecurityKey(RSA)); + } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. } } \ No newline at end of file