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(); } } }