/* Copyright 2013 Google Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ using System.Collections.Generic; namespace Google.Apis.Auth { /// /// JSON Web Token (JWT) implementation as specified in /// http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-08. /// public class JsonWebToken { /// /// JWT Header as specified in http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-08#section-5. /// public class Header { /// /// Gets or sets type header parameter used to declare the type of this object or null. /// [Newtonsoft.Json.JsonPropertyAttribute("typ")] public string Type { get; set; } /// /// Gets or sets content type header parameter used to declare structural information about the JWT or /// null. /// [Newtonsoft.Json.JsonPropertyAttribute("cty")] public string ContentType { get; set; } } /// /// JWT Payload as specified in http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-08#section-4.1. /// public class Payload { /// /// Gets or sets issuer claim that identifies the principal that issued the JWT or null. /// [Newtonsoft.Json.JsonPropertyAttribute("iss")] public string Issuer { get; set; } /// /// Gets or sets subject claim identifying the principal that is the subject of the JWT or null. /// [Newtonsoft.Json.JsonPropertyAttribute("sub")] public string Subject { get; set; } /// /// Gets or sets audience claim that identifies the audience that the JWT is intended for (should either be /// a string or list) or null. /// [Newtonsoft.Json.JsonPropertyAttribute("aud")] public object Audience { get; set; } /// /// Gets or sets expiration time claim that identifies the expiration time (in seconds) on or after which /// the token MUST NOT be accepted for processing or null. /// [Newtonsoft.Json.JsonPropertyAttribute("exp")] public long? ExpirationTimeSeconds { get; set; } /// /// Gets or sets not before claim that identifies the time (in seconds) before which the token MUST NOT be /// accepted for processing or null. /// [Newtonsoft.Json.JsonPropertyAttribute("nbf")] public long? NotBeforeTimeSeconds { get; set; } /// /// Gets or sets issued at claim that identifies the time (in seconds) at which the JWT was issued or /// null. /// [Newtonsoft.Json.JsonPropertyAttribute("iat")] public long? IssuedAtTimeSeconds { get; set; } /// /// Gets or sets JWT ID claim that provides a unique identifier for the JWT or null. /// [Newtonsoft.Json.JsonPropertyAttribute("jti")] public string JwtId { get; set; } /// /// Gets or sets type claim that is used to declare a type for the contents of this JWT Claims Set or /// null. /// [Newtonsoft.Json.JsonPropertyAttribute("typ")] public string Type { get; set; } /// Gets the audience property as a list. [Newtonsoft.Json.JsonIgnoreAttribute] public IEnumerable AudienceAsList { get { var asList = Audience as List; if (asList != null) { return asList; } var list = new List(); var asString = Audience as string; if (asString != null) { list.Add(asString); } return list; } } } } }