-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
13 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
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,16 @@ | ||
using System.Text; | ||
|
||
namespace GitHubJwt | ||
{ | ||
internal static class StringExtensions | ||
{ | ||
public static string HydrateRsaVariable(this string input) | ||
{ | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
stringBuilder.AppendLine("-----BEGIN RSA PRIVATE KEY-----"); | ||
stringBuilder.AppendLine(input); | ||
stringBuilder.AppendLine("-----END RSA PRIVATE KEY-----"); | ||
return stringBuilder.ToString(); | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace GitHubJwt | ||
{ | ||
public class StringPrivateKeySource : IPrivateKeySource | ||
{ | ||
protected readonly string Key; | ||
|
||
public StringPrivateKeySource(string key) | ||
{ | ||
if (string.IsNullOrEmpty(key)) | ||
{ | ||
throw new ArgumentNullException(nameof(key)); | ||
} | ||
|
||
Key = key; | ||
} | ||
|
||
public TextReader GetPrivateKeyReader() | ||
{ | ||
return new StringReader(Key.HydrateRsaVariable()); | ||
} | ||
} | ||
} |