From 5c09d7775be84fd95e14c6943d9f6a30f719e9a1 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Sat, 7 Dec 2024 01:25:35 +0100 Subject: [PATCH] =?UTF-8?q?feat(RSACryptographer):=20Virtuelle=20FileNotFo?= =?UTF-8?q?undEvent-Methode=20f=C3=BCr=20nicht=20gefundene=20Pem-Datei=20h?= =?UTF-8?q?inzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cryptographer/RSACryptographer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs index b7b15c7..163d4bf 100644 --- a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs +++ b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs @@ -30,15 +30,20 @@ namespace DigitalData.Core.Security.Cryptographer internal RSACryptographer() { } + public virtual void FileNotFoundEvent() => throw new FileNotFoundException( + $"Pem is not initialized and pem file is not found in {PemPath}. Issuer is {Issuer} and audience {Audience}."); + // TODO: make file read asynchronous, consider multiple routing public virtual void Init() { if(_pem is null) { + if(PemPath is null) + throw new InvalidOperationException($"Pem is not initialized and pem file is null. Issuer is {Issuer} and audience {Audience}."); if (File.Exists(PemPath)) _pem = File.ReadAllText(PemPath); else - throw new FileNotFoundException($"Pem is not assigned. Furthermore Pem file is not found in {PemPath}. Issuer is {Issuer} and audience {Audience}."); + FileNotFoundEvent(); } } }