-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend RSAlgorithmFactory to support all ctors of RS256Algorithm #221
Extend RSAlgorithmFactory to support all ctors of RS256Algorithm #221
Conversation
Hi, thanks for the contribution! |
This was done to avoid confusing if inside switch statement. All Func can be rewritten with: switch (algorithm)
{
case JwtHashAlgorithm.RS256:
{
if (_publicKey != null)
{
return new RS256Algorithm(publicKey);
}
var certificate = _certFactory();
#if NETSTANDARD1_3
return new RS256Algorithm((RSACryptoServiceProvider)certificate.GetRSAPublicKey(), certificate.GetRSAPrivateKey());
#else
return new RS256Algorithm((RSACryptoServiceProvider)certificate.PublicKey.Key, (RSA)certificate.PrivateKey);
#endif
}
default:
throw new NotSupportedException($"For algorithm {Enum.GetName(typeof(JwtHashAlgorithm), algorithm)} please use the appropriate factory by implementing {nameof(IAlgorithmFactory)}");
} If this is better from your point of view, I can rollback previous changes and commit this. What should I do @abatishchev ? |
I was thinking more about this factory and realized we might not need it at all. Since it supports a single algorithm anyway. So it just mimics the algorithm's own constrictors. Does it add any value in top of it? |
I'd remove |
Actually I got your idea and I like it. It's better than mine in #224. Can you please rebase on the latest master? |
@flerka thanks for your contribution, much appreciated. |
This is my draft implantation for #220