| | | 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 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Provides information about a security token such as audience, expiry time, and the string token value. |
| | | 10 | | /// </summary> |
| | | 11 | | public class SecurityToken |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Token literal |
| | | 15 | | /// </summary> |
| | | 16 | | string token; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Expiry date-time |
| | | 20 | | /// </summary> |
| | | 21 | | DateTime expiresAtUtc; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Token audience |
| | | 25 | | /// </summary> |
| | | 26 | | string audience; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Token type |
| | | 30 | | /// </summary> |
| | | 31 | | string tokenType; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Creates a new instance of the <see cref="SecurityToken"/> class. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="tokenString">The token</param> |
| | | 37 | | /// <param name="expiresAtUtc">The expiration time</param> |
| | | 38 | | /// <param name="audience">The audience</param> |
| | | 39 | | /// <param name="tokenType">The type of the token</param> |
| | 0 | 40 | | public SecurityToken(string tokenString, DateTime expiresAtUtc, string audience, string tokenType) |
| | | 41 | | { |
| | 0 | 42 | | if (string.IsNullOrEmpty(tokenString)) |
| | | 43 | | { |
| | 0 | 44 | | throw Fx.Exception.ArgumentNullOrWhiteSpace(nameof(tokenString)); |
| | | 45 | | } |
| | | 46 | | |
| | 0 | 47 | | if (string.IsNullOrEmpty(audience)) |
| | | 48 | | { |
| | 0 | 49 | | throw Fx.Exception.ArgumentNullOrWhiteSpace(nameof(audience)); |
| | | 50 | | } |
| | | 51 | | |
| | 0 | 52 | | this.token = tokenString; |
| | 0 | 53 | | this.expiresAtUtc = expiresAtUtc; |
| | 0 | 54 | | this.audience = audience; |
| | 0 | 55 | | this.tokenType = tokenType; |
| | 0 | 56 | | } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets the audience of this token. |
| | | 60 | | /// </summary> |
| | 0 | 61 | | public string Audience => this.audience; |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Gets the expiration time of this token. |
| | | 65 | | /// </summary> |
| | 0 | 66 | | public DateTime ExpiresAtUtc => this.expiresAtUtc; |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// Gets the actual token. |
| | | 70 | | /// </summary> |
| | 0 | 71 | | public virtual string TokenValue => this.token; |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Gets the token type. |
| | | 75 | | /// </summary> |
| | 0 | 76 | | public virtual string TokenType => this.tokenType; |
| | | 77 | | } |
| | | 78 | | } |