OLD | NEW |
(Empty) | |
| 1 /* |
| 2 Copyright 2013 Google Inc |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 */ |
| 16 |
| 17 using System.Collections.Generic; |
| 18 |
| 19 namespace Google.Apis.Auth |
| 20 { |
| 21 /// <summary> |
| 22 /// JSON Web Token (JWT) implementation as specified in· |
| 23 /// http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-08. |
| 24 /// </summary> |
| 25 public class JsonWebToken |
| 26 { |
| 27 /// <summary> |
| 28 /// JWT Header as specified in http://tools.ietf.org/html/draft-ietf-oau
th-json-web-token-08#section-5. |
| 29 /// </summary> |
| 30 public class Header |
| 31 { |
| 32 /// <summary> |
| 33 /// Gets or sets type header parameter used to declare the type of t
his object or <c>null</c>. |
| 34 /// </summary> |
| 35 [Newtonsoft.Json.JsonPropertyAttribute("typ")] |
| 36 public string Type { get; set; } |
| 37 |
| 38 /// <summary> |
| 39 /// Gets or sets content type header parameter used to declare struc
tural information about the JWT or· |
| 40 /// <c>null</c>. |
| 41 /// </summary> |
| 42 [Newtonsoft.Json.JsonPropertyAttribute("cty")] |
| 43 public string ContentType { get; set; } |
| 44 } |
| 45 |
| 46 /// <summary> |
| 47 /// JWT Payload as specified in http://tools.ietf.org/html/draft-ietf-oa
uth-json-web-token-08#section-4.1. |
| 48 /// </summary> |
| 49 public class Payload |
| 50 { |
| 51 /// <summary> |
| 52 /// Gets or sets issuer claim that identifies the principal that iss
ued the JWT or <c>null</c>. |
| 53 /// </summary> |
| 54 [Newtonsoft.Json.JsonPropertyAttribute("iss")] |
| 55 public string Issuer { get; set; } |
| 56 |
| 57 /// <summary> |
| 58 /// Gets or sets subject claim identifying the principal that is the
subject of the JWT or <c>null</c>. |
| 59 /// </summary> |
| 60 [Newtonsoft.Json.JsonPropertyAttribute("sub")] |
| 61 public string Subject { get; set; } |
| 62 |
| 63 /// <summary> |
| 64 /// Gets or sets audience claim that identifies the audience that th
e JWT is intended for (should either be |
| 65 /// a string or list) or <c>null</c>. |
| 66 /// </summary> |
| 67 [Newtonsoft.Json.JsonPropertyAttribute("aud")] |
| 68 public object Audience { get; set; } |
| 69 |
| 70 /// <summary> |
| 71 /// Gets or sets expiration time claim that identifies the expiratio
n time (in seconds) on or after which· |
| 72 /// the token MUST NOT be accepted for processing or <c>null</c>. |
| 73 /// </summary> |
| 74 [Newtonsoft.Json.JsonPropertyAttribute("exp")] |
| 75 public long? ExpirationTimeSeconds { get; set; } |
| 76 |
| 77 /// <summary> |
| 78 /// Gets or sets not before claim that identifies the time (in secon
ds) before which the token MUST NOT be |
| 79 /// accepted for processing or <c>null</c>. |
| 80 /// </summary> |
| 81 [Newtonsoft.Json.JsonPropertyAttribute("nbf")] |
| 82 public long? NotBeforeTimeSeconds { get; set; } |
| 83 |
| 84 /// <summary> |
| 85 /// Gets or sets issued at claim that identifies the time (in second
s) at which the JWT was issued or· |
| 86 /// <c>null</c>. |
| 87 /// </summary> |
| 88 [Newtonsoft.Json.JsonPropertyAttribute("iat")] |
| 89 public long? IssuedAtTimeSeconds { get; set; } |
| 90 |
| 91 /// <summary> |
| 92 /// Gets or sets JWT ID claim that provides a unique identifier for
the JWT or <c>null</c>. |
| 93 /// </summary> |
| 94 [Newtonsoft.Json.JsonPropertyAttribute("jti")] |
| 95 public string JwtId { get; set; } |
| 96 |
| 97 /// <summary> |
| 98 /// Gets or sets type claim that is used to declare a type for the c
ontents of this JWT Claims Set or· |
| 99 /// <c>null</c>. |
| 100 /// </summary> |
| 101 [Newtonsoft.Json.JsonPropertyAttribute("typ")] |
| 102 public string Type { get; set; } |
| 103 |
| 104 /// <summary>Gets the audience property as a list.</summary> |
| 105 [Newtonsoft.Json.JsonIgnoreAttribute] |
| 106 public IEnumerable<string> AudienceAsList |
| 107 { |
| 108 get |
| 109 { |
| 110 var asList = Audience as List<string>; |
| 111 if (asList != null) |
| 112 { |
| 113 return asList; |
| 114 } |
| 115 var list = new List<string>(); |
| 116 var asString = Audience as string; |
| 117 if (asString != null) |
| 118 { |
| 119 list.Add(asString); |
| 120 } |
| 121 |
| 122 return list; |
| 123 } |
| 124 } |
| 125 } |
| 126 } |
| 127 } |
OLD | NEW |