| | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.ServiceBus.Primitives |
| | 5 | | { |
| | 6 | | using System; |
| | 7 | | using System.Collections.ObjectModel; |
| | 8 | | using System.IdentityModel.Tokens; |
| | 9 | | using System.IdentityModel.Tokens.Jwt; |
| | 10 | |
|
| | 11 | | /// <summary> |
| | 12 | | /// Extends SecurityToken for JWT specific properties |
| | 13 | | /// </summary> |
| | 14 | | public class JsonSecurityToken : SecurityToken |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// Creates a new instance of the <see cref="JsonSecurityToken"/> class. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="rawToken">Raw JSON Web Token string</param> |
| | 20 | | /// <param name="audience">The audience</param> |
| | 21 | | public JsonSecurityToken(string rawToken, string audience) |
| 0 | 22 | | : base(rawToken, GetExpirationDateTimeUtcFromToken(rawToken), audience, Constants.JsonWebTokenType) |
| | 23 | | { |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | static DateTime GetExpirationDateTimeUtcFromToken(string token) |
| | 27 | | { |
| 0 | 28 | | var jwtSecurityToken = new JwtSecurityToken(token); |
| 0 | 29 | | return jwtSecurityToken.ValidTo; |
| | 30 | | } |
| | 31 | | } |
| | 32 | | } |