Skip to content

Commit

Permalink
Merge pull request #1 from henkmollema/netstandard
Browse files Browse the repository at this point in the history
Migrate to .NETStandard 1.3
  • Loading branch information
henkmollema committed May 19, 2016
2 parents 84827df + f97e31d commit d8bc8f4
Show file tree
Hide file tree
Showing 17 changed files with 349 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[Oo]bj/
[Bb]in/
.nuget/
packages/
artifacts/
.vs/
debugSettings.json
project.lock.json
*.user
*.suo
nuget.exe
.build/
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: csharp
sudo: required
dist: trusty
addons:
apt:
packages:
- gettext
- libcurl4-openssl-dev
- libicu-dev
- libssl-dev
- libunwind8
- zlib1g
mono:
- 4.0.5
os:
- linux
- osx
osx_image: xcode7.1
script:
- ./build.sh verify
15 changes: 8 additions & 7 deletions Jwt.NET.sln
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Jwt.NET
JSON Web Tokens implementation for .NET (including CoreCLR).
JSON Web Tokens implementation for .NET Core.

<hr>

| Windows | Linux | OS X |
| --- | --- | --- |
| [![Build status](https://ci.appveyor.com/api/projects/status/kr49ieh4vp3c9cxt?svg=true)](https://ci.appveyor.com/project/henkmollema/jwt-net) | [![Build Status](https://travis-ci.org/henkmollema/Jwt.NET.svg)](https://travis-ci.org/henkmollema/Jwt.NET) | [![Build Status](https://travis-ci.org/henkmollema/Jwt.NET.svg)](https://travis-ci.org/henkmollema/Jwt.NET) |

--

## Installation
Jwt.NET is avaiable on [NuGet](https://www.nuget.org/packages/JsonWebTokens).
Expand Down
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
init:
- git config --global core.autocrlf true
build_script:
- build.cmd verify
clone_depth: 1
test: off
deploy: off
2 changes: 2 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
67 changes: 67 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
$ErrorActionPreference = "Stop"

function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
{
while($true)
{
try
{
Invoke-WebRequest $url -OutFile $downloadLocation
break
}
catch
{
$exceptionMessage = $_.Exception.Message
Write-Host "Failed to download '$url': $exceptionMessage"
if ($retries -gt 0) {
$retries--
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
Start-Sleep -Seconds 10

}
else
{
$exception = $_.Exception
throw $exception
}
}
}
}

cd $PSScriptRoot

$repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder

$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if ($env:KOREBUILD_ZIP)
{
$koreBuildZip=$env:KOREBUILD_ZIP
}

$buildFolder = ".build"
$buildFile="$buildFolder\KoreBuild.ps1"

if (!(Test-Path $buildFolder)) {
Write-Host "Downloading KoreBuild from $koreBuildZip"

$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
New-Item -Path "$tempFolder" -Type directory | Out-Null

$localZipFile="$tempFolder\korebuild.zip"

DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6

Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)

New-Item -Path "$buildFolder" -Type directory | Out-Null
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse

# Cleanup
if (Test-Path $tempFolder) {
Remove-Item -Recurse -Force $tempFolder
}
}

&"$buildFile" $args
46 changes: 46 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder

koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP
fi

buildFolder=".build"
buildFile="$buildFolder/KoreBuild.sh"

if test ! -d $buildFolder; then
echo "Downloading KoreBuild from $koreBuildZip"

tempFolder="/tmp/KoreBuild-$(uuidgen)"
mkdir $tempFolder

localZipFile="$tempFolder/korebuild.zip"

retries=6
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
do
echo "Failed to download '$koreBuildZip'"
if [ "$retries" -le 0 ]; then
exit 1
fi
retries=$((retries - 1))
echo "Waiting 10 seconds before retrying. Retries left: $retries"
sleep 10s
done

unzip -q -d $tempFolder $localZipFile

mkdir $buildFolder
cp -r $tempFolder/**/build/** $buildFolder

chmod +x $buildFile

# Cleanup
if test ! -d $tempFolder; then
rm -rf $tempFolder
fi
fi

$buildFile -r $repoFolder "$@"
5 changes: 1 addition & 4 deletions global.json
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" ]
}
2 changes: 2 additions & 0 deletions src/JsonWebTokens/DefaultJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ namespace Jwt
/// </summary>
public class DefaultJsonSerializer : IJsonSerializer
{
/// <inheritdoc />
public string Serialize(object value)
{
return JsonConvert.SerializeObject(value);
}

/// <inheritdoc />
public T Deserialize<T>(string value)
{
return JsonConvert.DeserializeObject<T>(value);
Expand Down
11 changes: 2 additions & 9 deletions src/JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

namespace Jwt
{
public enum JwtHashAlgorithm
{
HS256,
HS384,
HS512
}

/// <summary>
/// Provides methods for encoding and decoding JSON Web Tokens.
/// </summary>
Expand Down Expand Up @@ -303,7 +296,7 @@ private static JwtHashAlgorithm GetHashAlgorithm(string algorithm)
}
}

public static string Base64UrlEncode(byte[] input)
private static string Base64UrlEncode(byte[] input)
{
var output = Convert.ToBase64String(input);
output = output.Split('=')[0]; // Remove any trailing '='s
Expand All @@ -312,7 +305,7 @@ public static string Base64UrlEncode(byte[] input)
return output;
}

public static byte[] Base64UrlDecode(string input)
private static byte[] Base64UrlDecode(string input)
{
var output = input;
output = output.Replace('-', '+'); // 62nd char of encoding
Expand Down
14 changes: 7 additions & 7 deletions src/JsonWebTokens/JsonWebTokens.xproj
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>
Loading

0 comments on commit d8bc8f4

Please sign in to comment.