-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
84827df
commit 7c84f2a
Showing
10 changed files
with
197 additions
and
100 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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{27CE9B86-3C2B-4DC5-A4A4-9B7CE5B19FD1}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EB12BB02-C15C-469F-B4A4-6DE0E187C8DB}" | ||
ProjectSection(SolutionItems) = preProject | ||
global.json = global.json | ||
NuGet.Config = NuGet.Config | ||
EndProjectSection | ||
EndProject | ||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JsonWebTokens", "src\JsonWebTokens\JsonWebTokens.xproj", "{046E9A92-AECE-49B2-B33C-78CB06A15EC7}" | ||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JsonWebTokens", "src\JsonWebTokens\JsonWebTokens.xproj", "{BCDB458E-A10B-425D-81D1-A78930978394}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{046E9A92-AECE-49B2-B33C-78CB06A15EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{046E9A92-AECE-49B2-B33C-78CB06A15EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{046E9A92-AECE-49B2-B33C-78CB06A15EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{046E9A92-AECE-49B2-B33C-78CB06A15EC7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{BCDB458E-A10B-425D-81D1-A78930978394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BCDB458E-A10B-425D-81D1-A78930978394}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BCDB458E-A10B-425D-81D1-A78930978394}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BCDB458E-A10B-425D-81D1-A78930978394}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{046E9A92-AECE-49B2-B33C-78CB06A15EC7} = {27CE9B86-3C2B-4DC5-A4A4-9B7CE5B19FD1} | ||
{BCDB458E-A10B-425D-81D1-A78930978394} = {27CE9B86-3C2B-4DC5-A4A4-9B7CE5B19FD1} | ||
EndGlobalSection | ||
EndGlobal |
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,6 +1,3 @@ | ||
{ | ||
"projects": [ "src", "test" ], | ||
"sdk": { | ||
"version": "1.0.0-rc1-update1" | ||
} | ||
"projects": [ "src" ] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>046e9a92-aece-49b2-b33c-78cb06a15ec7</ProjectGuid> | ||
<ProjectGuid>bcdb458e-a10b-425d-81d1-a78930978394</ProjectGuid> | ||
<RootNamespace>Jwt</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
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,103 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Jwt | ||
{ | ||
/// <summary> | ||
/// Builder for <see cref="JwtData"/> objects. | ||
/// </summary> | ||
public class JwtBuilder | ||
{ | ||
private readonly JwtData _data = new JwtData(); | ||
|
||
/// <summary> | ||
/// Adds the specified payload to the JWT. | ||
/// </summary> | ||
/// <param name="payload">The payload.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithPayload(object payload) | ||
{ | ||
_data.Payload = payload; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Marks the specified payload as already serialized. | ||
/// </summary> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder IsSerialized() | ||
{ | ||
_data.Serialized = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the specified key string to the JWT. | ||
/// </summary> | ||
/// <param name="key">The string representation of the key.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithKey(string key) | ||
{ | ||
_data.Key = key; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the specified key bytes to the JWT. | ||
/// </summary> | ||
/// <param name="keyBytes">The bytes representation of the key.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithKey(byte[] keyBytes) | ||
{ | ||
_data.KeyBytes = keyBytes; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Specifies the algorithm being used for hashing the JWT. | ||
/// </summary> | ||
/// <param name="algorithm">The algorithm being used for hashing the JWT.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithAlgorithm(JwtHashAlgorithm algorithm) | ||
{ | ||
_data.Algorithm = algorithm; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the specified key/value pair as header to the JWT. | ||
/// </summary> | ||
/// <param name="key">The key of the key/value pair.</param> | ||
/// <param name="value">The value of the key/value pair.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithHeader(string key, object value) | ||
{ | ||
if (_data.ExtraHeaders == null) | ||
{ | ||
_data.ExtraHeaders = new Dictionary<string, object>(); | ||
} | ||
|
||
_data.ExtraHeaders.Add(key, value); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the specified dictionary as headers to the JWT. | ||
/// </summary> | ||
/// <param name="dict">The dictionary with the headers of the JWT.</param> | ||
/// <returns>The <see cref="JwtBuilder"/> instance.</returns> | ||
public JwtBuilder WithHeaders(IDictionary<string, object> dict) | ||
{ | ||
_data.ExtraHeaders = dict; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Builds the data to a <see cref="JwtData"/> object. | ||
/// </summary> | ||
/// <returns>A <see cref="JwtData"/> object.</returns> | ||
public JwtData Build() | ||
{ | ||
return _data; | ||
} | ||
} | ||
} |
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,23 @@ | ||
namespace Jwt | ||
{ | ||
/// <summary> | ||
/// Represents the hashing algorithm being used used. | ||
/// </summary> | ||
public enum JwtHashAlgorithm | ||
{ | ||
/// <summary> | ||
/// Hash-based Message Authentication Code (HMAC) using SHA256. | ||
/// </summary> | ||
HS256, | ||
|
||
/// <summary> | ||
/// Hash-based Message Authentication Code (HMAC) using SHA256. | ||
/// </summary> | ||
HS384, | ||
|
||
/// <summary> | ||
/// Hash-based Message Authentication Code (HMAC) using SHA256. | ||
/// </summary> | ||
HS512 | ||
} | ||
} |
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
Oops, something went wrong.