Skip to content

Commit e209850

Browse files
CADBIMDeveloperabatishchev
authored andcommitted
add JSON Web Key definitions
1 parent f236a36 commit e209850

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/JWT/Jwk/JwtWebKey.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Newtonsoft.Json;
2+
3+
#if MODERN_DOTNET
4+
using System.Text.Json.Serialization;
5+
#endif
6+
7+
namespace JWT.Jwk
8+
{
9+
/// <summary>
10+
/// A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key
11+
/// specifed by RFC 7517, see https://datatracker.ietf.org/doc/html/rfc7517
12+
/// </summary>
13+
public sealed class JwtWebKey
14+
{
15+
#if MODERN_DOTNET
16+
[System.Text.Json.Serialization.JsonConstructor]
17+
public JwtWebKey()
18+
{
19+
20+
}
21+
#endif
22+
23+
[JsonProperty("kty")]
24+
#if MODERN_DOTNET
25+
[JsonPropertyName("kty")]
26+
#endif
27+
public string KeyType { get; set; }
28+
29+
[JsonProperty("kid")]
30+
#if MODERN_DOTNET
31+
[JsonPropertyName("kid")]
32+
#endif
33+
public string KeyId { get; set; }
34+
35+
[JsonProperty("n")]
36+
#if MODERN_DOTNET
37+
[JsonPropertyName("n")]
38+
#endif
39+
public string Modulus { get; set; }
40+
41+
[JsonProperty("e")]
42+
#if MODERN_DOTNET
43+
[JsonPropertyName("e")]
44+
#endif
45+
public string Exponent { get; set; }
46+
}
47+
}

src/JWT/Jwk/JwtWebKeySet.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
5+
#if MODERN_DOTNET
6+
using System.Text.Json.Serialization;
7+
#endif
8+
9+
namespace JWT.Jwk
10+
{
11+
/// <summary>
12+
/// A JWK Set JSON data structure that represents a set of JSON Web Keys
13+
/// specifed by RFC 7517, see https://datatracker.ietf.org/doc/html/rfc7517
14+
/// </summary>
15+
public sealed class JwtWebKeySet
16+
{
17+
#if MODERN_DOTNET
18+
[System.Text.Json.Serialization.JsonConstructor]
19+
public JwtWebKeySet()
20+
{
21+
22+
}
23+
#endif
24+
25+
[JsonProperty("keys")]
26+
#if MODERN_DOTNET
27+
[JsonPropertyName("keys")]
28+
#endif
29+
public IEnumerable<JwtWebKey> Keys { get; set; } = null!;
30+
}
31+
}

0 commit comments

Comments
 (0)