Skip to content

Commit

Permalink
Add initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
henkmollema committed Jan 2, 2016
1 parent 9b92959 commit 667c50a
Show file tree
Hide file tree
Showing 12 changed files with 591 additions and 195 deletions.
203 changes: 9 additions & 194 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,196 +1,11 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studo 2015 cache/options directory
[Bb]in/
.nuget/
packages/
artifacts/
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
*.[Cc]ache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt
debugSettings.json
project.lock.json
*.user
*.suo
nuget.exe
32 changes: 32 additions & 0 deletions Jwt.NET.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.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
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JsonWebTokens", "src\JsonWebTokens\JsonWebTokens.xproj", "{046E9A92-AECE-49B2-B33C-78CB06A15EC7}"
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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{046E9A92-AECE-49B2-B33C-78CB06A15EC7} = {27CE9B86-3C2B-4DC5-A4A4-9B7CE5B19FD1}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# Jwt.NET
.NET JSON Web Tokens implementation (including CoreCLR)
JSON Web Tokens implementation for .NET (including CoreCLR).

## Installation
Jwt.NET is avaiable on [NuGet](https://www.nuget.org/packages/Jwt.NET).

## Usage
### Creating tokens

```csharp
var payload = new Dictionary<string, object>()
{
{ "key1", 1 },
{ "key2", "the-value" }
};
var secret = "SOME_SECRET_KEY";
var token = Jwt.JsonWebToken.Encode(payload, secretKey, Jwt.JwtHashAlgorithm.HS256);
```
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
}
}
20 changes: 20 additions & 0 deletions src/JsonWebTokens/DefaultJsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json;

namespace Jwt
{
/// <summary>
/// <see cref="IJsonSerializer"/> implementation using Json.NET.
/// </summary>
public class DefaultJsonSerializer : IJsonSerializer
{
public string Serialize(object value)
{
return JsonConvert.SerializeObject(value);
}

public T Deserialize<T>(string value)
{
return JsonConvert.DeserializeObject<T>(value);
}
}
}
23 changes: 23 additions & 0 deletions src/JsonWebTokens/IJsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Jwt
{
/// <summary>
/// Specifies a contract for a JSON serializer implementation.
/// </summary>
public interface IJsonSerializer
{
/// <summary>
/// Serializes an object to a JSON string.
/// </summary>
/// <param name="value">The value to serialize.</param>
/// <returns>A JSON string representing of the object.</returns>
string Serialize(object value);

/// <summary>
/// Deserializes a JSON string to a typed object of type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the object.</typeparam>
/// <param name="value">A JSON string representing the object.</param>
/// <returns>A typed object of type <typeparamref name="T"/>.</returns>
T Deserialize<T>(string value);
}
}
Loading

0 comments on commit 667c50a

Please sign in to comment.