-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding IAlgFactory to master (v3) branch (#102)
* Adding IAlgorithmFactory by default implemented by AlgorithmFactory. Using IAlgorithmFactory in JwtDecoder * Renaming AlgorithmFactory to HMACSHAAlgorithmFactory * Adding RSAlgorithmFactory inheriting HMACSHAAlgorithmFactory * Adding DotSettings with abbreviations * Fixing build, adding missed using * Moving IAlgorithmFactory to the Algorithms namespace/folder * Adding missing xml docs * Bumping nuget version
- Loading branch information
1 parent
977cb10
commit 8137c59
Showing
10 changed files
with
93 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HMACSHA/@EntryIndexedValue">HMACSHA</s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RS/@EntryIndexedValue">RS</s:String> | ||
</wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace JWT.Algorithms | ||
{ | ||
/// <summary> | ||
/// Provides IJwtAlgorithms. | ||
/// </summary> | ||
public interface IAlgorithmFactory | ||
{ | ||
/// <summary> | ||
/// Creates an AlgorithmFactory using the provided algorithm name. | ||
/// </summary> | ||
/// <param name="algorithmName">The name of the algorithm.</param> | ||
IJwtAlgorithm Create(string algorithmName); | ||
|
||
/// <summary> | ||
/// Creates an AlgorithmFactory using the provided algorithm enum. | ||
/// </summary> | ||
/// <param name="algorithm">The enum value of the algorithm.</param> | ||
IJwtAlgorithm Create(JwtHashAlgorithm algorithm); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
namespace JWT.Algorithms | ||
{ | ||
/// <inheritdoc /> | ||
public sealed class RSAlgorithmFactory : HMACSHAAlgorithmFactory | ||
{ | ||
private readonly Func<X509Certificate2> _certFactory; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RSAlgorithmFactory"/> class | ||
/// </summary> | ||
/// <param name="certFactory">Func that returns <see cref="X509Certificate2" /> which will be used to instantiate <see cref="RS256Algorithm" /></param> | ||
public RSAlgorithmFactory(Func<X509Certificate2> certFactory) | ||
{ | ||
_certFactory = certFactory; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override IJwtAlgorithm Create(JwtHashAlgorithm algorithm) | ||
{ | ||
return algorithm == JwtHashAlgorithm.RS256 ? | ||
new RS256Algorithm(_certFactory()) : | ||
base.Create(algorithm); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace JWT | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters