| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.IdentityModel.Protocols.WSTrust |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Used in the RequestSecurityToken or RequestSecurityTokenResponse to indicated the desired or |
| | | 10 | | /// required lifetime of a token. Everything here is stored in Utc format. |
| | | 11 | | /// </summary> |
| | | 12 | | public class Lifetime |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Instantiates a LifeTime object with token creation and expiration time in Utc. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="created">Token creation time in Utc.</param> |
| | | 18 | | /// <param name="expires">Token expiration time in Utc.</param> |
| | | 19 | | /// <exception cref="ArgumentException">When the given expiration time is |
| | | 20 | | /// before the given creation time.</exception> |
| | | 21 | | public Lifetime(DateTime created, DateTime expires) |
| | 0 | 22 | | : this((DateTime?)created, (DateTime?)expires) |
| | | 23 | | { |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Instantiates a LifeTime object with token creation and expiration time in Utc. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="created">Token creation time in Utc.</param> |
| | | 30 | | /// <param name="expires">Token expiration time in Utc.</param> |
| | | 31 | | /// <exception cref="ArgumentException">When the given expiration time is |
| | | 32 | | /// before the given creation time.</exception> |
| | 0 | 33 | | public Lifetime(DateTime? created, DateTime? expires) |
| | | 34 | | { |
| | 0 | 35 | | if (created != null && expires != null && expires.Value <= created.Value) |
| | 0 | 36 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.ID2000))); |
| | | 37 | | |
| | 0 | 38 | | Created = DateTimeUtil.ToUniversalTime(created); |
| | 0 | 39 | | Expires = DateTimeUtil.ToUniversalTime(expires); |
| | 0 | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets the token creation time in UTC time. |
| | | 44 | | /// </summary> |
| | 0 | 45 | | public DateTime? Created { get; set; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets the token expiration time in UTC time. |
| | | 49 | | /// </summary> |
| | 0 | 50 | | public DateTime? Expires { get; set; } |
| | | 51 | | } |
| | | 52 | | } |