//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace System.IdentityModel.Protocols.WSTrust { using System; using System.Diagnostics; /// /// Used in the RequestSecurityToken or RequestSecurityTokenResponse to indicated the desired or /// required lifetime of a token. Everything here is stored in Utc format. /// public class Lifetime { DateTime? _created; DateTime? _expires; /// /// Instantiates a LifeTime object with token creation and expiration time in Utc. /// /// Token creation time in Utc. /// Token expiration time in Utc. /// When the given expiration time is /// before the given creation time. public Lifetime( DateTime created, DateTime expires ) : this( (DateTime?)created, (DateTime?)expires ) { } /// /// Instantiates a LifeTime object with token creation and expiration time in Utc. /// /// Token creation time in Utc. /// Token expiration time in Utc. /// When the given expiration time is /// before the given creation time. public Lifetime( DateTime? created, DateTime? expires ) { if ( created != null && expires != null && expires.Value <= created.Value ) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentException( SR.GetString( SR.ID2000 ) ) ); _created = DateTimeUtil.ToUniversalTime( created ); _expires = DateTimeUtil.ToUniversalTime( expires ); } /// /// Gets the token creation time in UTC time. /// public DateTime? Created { get { return _created; } set { _created = value; } } /// /// Gets the token expiration time in UTC time. /// public DateTime? Expires { get { return _expires; } set { _expires = value; } } } }