refactor(RSAExtensions): GetRSADecryptor, TryGetRSADecryptor, GetRSAEncryptor und TryGetRSADecryptor Methoden hinzugefügt.
This commit is contained in:
parent
f28b43cc06
commit
683b95c205
@ -17,5 +17,28 @@ namespace DigitalData.Core.Security.Extensions
|
|||||||
|
|
||||||
public static IRSAEncryptor? GetEncryptor(this IDictionary<string, IRSAEncryptor> pairs, string issuer, string audience)
|
public static IRSAEncryptor? GetEncryptor(this IDictionary<string, IRSAEncryptor> pairs, string issuer, string audience)
|
||||||
=> pairs.TryGetEncryptor(issuer: issuer, audience: audience, out var encryptor) ? encryptor : null;
|
=> pairs.TryGetEncryptor(issuer: issuer, audience: audience, out var encryptor) ? encryptor : null;
|
||||||
|
|
||||||
|
public static IRSADecryptor GetRSADecryptor(this ICryptFactory factory, string issuer, string audience)
|
||||||
|
=> factory[$"{issuer}:{audience}"];
|
||||||
|
|
||||||
|
public static bool TryGetRSADecryptor(this ICryptFactory factory, string issuer, string audience, out IRSADecryptor? decryptor)
|
||||||
|
=> factory.TryGetRSADecryptor($"{issuer}:{audience}", out decryptor);
|
||||||
|
|
||||||
|
public static IRSAEncryptor GetRSAEncryptor(this ICryptFactory factory, string issuer, string audience)
|
||||||
|
=> factory[$"{issuer}:{audience}"].Encryptor;
|
||||||
|
|
||||||
|
public static bool TryGetRSADecryptor(this ICryptFactory factory, string issuer, string audience, out IRSAEncryptor? encryptor)
|
||||||
|
{
|
||||||
|
if(factory.TryGetRSADecryptor($"{issuer}:{audience}", out var decryptor) && decryptor is not null)
|
||||||
|
{
|
||||||
|
encryptor = decryptor.Encryptor;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
encryptor = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user