-
Notifications
You must be signed in to change notification settings - Fork 2
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
12 changed files
with
306 additions
and
91 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,2 @@ | ||
<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:Boolean x:Key="/Default/UserDictionary/Words/=Gabo/@EntryIndexedValue">True</s:Boolean></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
51 changes: 51 additions & 0 deletions
51
src/dotnet-decode-jwt/Infrastructure/NonThreadSafeConsole.cs
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,51 @@ | ||
namespace Gabo.DotNet.DecodeJwt.Infrastructure; | ||
|
||
public interface IConsole | ||
{ | ||
void WriteBoringLine(string value); | ||
void WriteDullLine(string value); | ||
void WriteInfoLine(string value); | ||
void WriteFancyLine(string value); | ||
void WriteErrorLine(string value); | ||
} | ||
|
||
internal class NonThreadSafeConsole : IConsole | ||
{ | ||
internal const ConsoleColor BoringColor = ConsoleColor.Gray; | ||
internal const ConsoleColor DullColor = ConsoleColor.DarkGray; | ||
internal const ConsoleColor InfoColor = ConsoleColor.Yellow; | ||
internal const ConsoleColor FancyColor = ConsoleColor.Green; | ||
internal const ConsoleColor ErrorColor = ConsoleColor.Red; | ||
|
||
public void WriteBoringLine(string value) | ||
{ | ||
WriteColoredLine(BoringColor, value); | ||
} | ||
|
||
public void WriteDullLine(string value) | ||
{ | ||
WriteColoredLine(DullColor, value); | ||
} | ||
|
||
public void WriteInfoLine(string value) | ||
{ | ||
WriteColoredLine(InfoColor, value); | ||
} | ||
|
||
public void WriteFancyLine(string value) | ||
{ | ||
WriteColoredLine(FancyColor, value); | ||
} | ||
|
||
public void WriteErrorLine(string value) | ||
{ | ||
WriteColoredLine(ErrorColor, value); | ||
} | ||
|
||
private static void WriteColoredLine(ConsoleColor color, string value) | ||
{ | ||
Console.ForegroundColor = color; | ||
Console.WriteLine(value); | ||
Console.ResetColor(); | ||
} | ||
} |
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,4 @@ | ||
namespace DotNet.Decode.Jwt; | ||
namespace Gabo.DotNet.DecodeJwt; | ||
|
||
public static class JwtClaimsDecoder | ||
{ | ||
|
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,35 @@ | ||
namespace DotNet.Decode.Jwt; | ||
namespace Gabo.DotNet.DecodeJwt; | ||
|
||
internal class Program | ||
internal static class Program | ||
{ | ||
private static void Main(string[] args) | ||
internal const int SuccessExitCode = 0; | ||
internal const int FailureExitCode = 1; | ||
|
||
internal static IConsole AbstractedConsole; | ||
|
||
internal static int Main(string[] args) | ||
{ | ||
AbstractedConsole ??= new NonThreadSafeConsole(); | ||
|
||
if (args.Length != 1) | ||
{ | ||
Console.WriteLine("A single argument should be provided:"); | ||
Console.WriteLine("dotnet decode-jwt eyJhbGciOiJub25lIn0.ewogICAgImlzcyI6ICJiZXN0LWlzc3VlciIsCiAgICAic3ViIjogIm5pY2Utc3ViamVjdCIsCiAgICAiYXVkIjogWyJhdWRpZW5jZS1vbmUiLCAiYXVkaWVuY2UtdHdvIl0sCiAgICAiZXhwIjogMTUyODY5MTM1MCwKICAgICJuYmYiOiAxNTI4NjkwNzUwLAogICAgImlhdCI6IDE1Mjg2OTA3NTAsCiAgICAianRpIjogImMzMTk3ZGNiLWUxMTMtNDc3OC04OTc5LWI5NTZmNjg0MDA3ZiIsCiAgICAiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvZW1haWxhZGRyZXNzIjogImhpQG1lLmNvbSIsCiAgICAic29tZS1udW1iZXIiOiAxMi41NiwKICAgICJuZXN0ZWQtY2xhaW0iOiB7CiAgICAgICAgImhpIjogIkknbSIsCiAgICAgICAgImEiOiAibmVzdGVkIGNsYWltIgogICAgfQp9Cg==."); | ||
return; | ||
AbstractedConsole.WriteBoringLine("A single argument should be provided:"); | ||
AbstractedConsole.WriteBoringLine("dotnet decode-jwt eyJhbGciOiJub25lIn0.ewogICAgImlzcyI6ICJiZXN0LWlzc3VlciIsCiAgICAic3ViIjogIm5pY2Utc3ViamVjdCIsCiAgICAiYXVkIjogWyJhdWRpZW5jZS1vbmUiLCAiYXVkaWVuY2UtdHdvIl0sCiAgICAiZXhwIjogMTUyODY5MTM1MCwKICAgICJuYmYiOiAxNTI4NjkwNzUwLAogICAgImlhdCI6IDE1Mjg2OTA3NTAsCiAgICAianRpIjogImMzMTk3ZGNiLWUxMTMtNDc3OC04OTc5LWI5NTZmNjg0MDA3ZiIsCiAgICAiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvZW1haWxhZGRyZXNzIjogImhpQG1lLmNvbSIsCiAgICAic29tZS1udW1iZXIiOiAxMi41NiwKICAgICJuZXN0ZWQtY2xhaW0iOiB7CiAgICAgICAgImhpIjogIkknbSIsCiAgICAgICAgImEiOiAibmVzdGVkIGNsYWltIgogICAgfQp9Cg==."); | ||
return FailureExitCode; | ||
} | ||
|
||
var console = new SimplifiedConsole(); | ||
var claimsDisplayer = new ClaimsDisplayer(console, TimeZoneInfo.Local); | ||
var claimsDisplayer = new ClaimsDisplayer(AbstractedConsole, TimeZoneInfo.Local); | ||
|
||
try | ||
{ | ||
var claims = JwtClaimsDecoder.GetClaims(args[0]); | ||
claimsDisplayer.DisplayClaims(claims); | ||
return SuccessExitCode; | ||
} | ||
catch (FormatException e) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine(e.Message); | ||
} | ||
finally | ||
{ | ||
Console.ResetColor(); | ||
AbstractedConsole.WriteErrorLine(e.Message); | ||
return FailureExitCode; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,4 +1,4 @@ | ||
namespace DotNet.Decode.Jwt.Tests; | ||
namespace Gabo.DotNet.DecodeJwt.Tests; | ||
|
||
public class JwtClaimsDecoderTests | ||
{ | ||
|
Oops, something went wrong.