Skip to content

Commit

Permalink
All DateTime properties are clearly marked as UTC (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
mafurman authored Oct 18, 2019
1 parent 38d5cb1 commit affefe0
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Uri AuthenticationMethod
}

/// <summary>
/// Gets or sets the AuthenticationInstant
/// Gets or sets the AuthenticationInstant. This value should be in UTC.
/// </summary>
public DateTime AuthenticationInstant { get; set; }

Expand All @@ -76,7 +76,7 @@ public Uri AuthenticationMethod
public string DnsName { get; set; }

/// <summary>
/// Gets or sets the time that the session referred to in the session index MUST be considered ended.
/// Gets or sets the time that the session referred to in the session index MUST be considered ended. This value should be in UTC.
/// </summary>
public DateTime? NotOnOrAfter { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public SamlAuthenticationStatement(
}

/// <summary>
/// Gets or sets the instant of authentication.
/// Gets or sets the instant of authentication. This value should be in UTC.
/// </summary>
public DateTime AuthenticationInstant
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ IEnumerable<SamlCondition> conditions
public ICollection<SamlCondition> Conditions { get; }

/// <summary>
/// Gets or sets the earliest time instant at which the assertion is valid.
/// Gets or sets the earliest time instant at which the assertion is valid. This value should be in UTC.
/// </summary>
public DateTime NotBefore { get; set; } = DateTimeUtil.GetMinValue(DateTimeKind.Utc);

/// <summary>
/// Gets or sets the time instant at which the assertion has expired.
/// Gets or sets the time instant at which the assertion has expired. This value should be in UTC.
/// </summary>
public DateTime NotOnOrAfter { get; set; } = DateTimeUtil.GetMaxValue(DateTimeKind.Utc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override SecurityKey SigningKey
}

/// <summary>
/// Gets the time the token is valid from.
/// Gets the time the token is valid from. This value is always in UTC.
/// </summary>
public override DateTime ValidFrom
{
Expand All @@ -112,7 +112,7 @@ public override DateTime ValidFrom
}

/// <summary>
/// Gets the time the token is valid to.
/// Gets the time the token is valid to. This value is always in UTC.
/// </summary>
public override DateTime ValidTo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Uri AuthenticationMethod
}

/// <summary>
/// Gets or sets the AuthenticationInstant
/// Gets or sets the AuthenticationInstant. This value should be in UTC.
/// </summary>
public DateTime AuthenticationInstant { get; set; }

Expand All @@ -69,7 +69,7 @@ public Uri AuthenticationMethod
public string DnsName { get; set; }

/// <summary>
/// Gets or sets the time that the session referred to in the session index MUST be considered ended.
/// Gets or sets the time that the session referred to in the session index MUST be considered ended. This value should be in UTC.
/// </summary>
public DateTime? NotOnOrAfter { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public Saml2AuthenticationContext AuthenticationContext
}

/// <summary>
/// Gets or sets the time at which the authentication took place. [Saml2Core, 2.7.2]
/// Gets or sets the time at which the authentication took place. If the provided DateTime is not in UTC, it will
/// be converted to UTC. [Saml2Core, 2.7.2]
/// </summary>
/// <exception cref="ArgumentNullException">if 'value' is null.</exception>
public DateTime AuthenticationInstant
Expand All @@ -95,7 +96,8 @@ public string SessionIndex
/// <summary>
/// Gets or sets the time instant at which the session between the principal
/// identified by the subject and the SAML authority issuing this statement
/// must be considered ended. [Saml2Core, 2.7.2]
/// must be considered ended. If the provided DateTime is not in UTC, it will
/// be converted to UTC. [Saml2Core, 2.7.2]
/// </summary>
public DateTime? SessionNotOnOrAfter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public ICollection<Saml2AudienceRestriction> AudienceRestrictions
}

/// <summary>
/// Gets or sets the earliest time instant at which the assertion is valid.
/// Gets or sets the earliest time instant at which the assertion is valid. If the provided DateTime is not in UTC, it will
/// be converted to UTC.
/// [Saml2Core, 2.5.1]
/// </summary>
/// <exception cref="ArgumentException">if 'value' is greater or equal to <see cref="NotOnOrAfter"/>.</exception>
Expand All @@ -93,7 +94,8 @@ public DateTime? NotBefore
}

/// <summary>
/// Gets or sets the time instant at which the assertion has expired.
/// Gets or sets the time instant at which the assertion has expired. If the provided DateTime is not in UTC, it will
/// be converted to UTC.
/// [Saml2Core, 2.5.1]
/// </summary>
/// <exception cref="ArgumentException">if 'value' is less than or equal to <see cref="NotBefore"/>.</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override SecurityKey SigningKey
}

/// <summary>
/// Gets the time the token is valid from.
/// Gets the time the token is valid from. This value is always in UTC.
/// </summary>
public override DateTime ValidFrom
{
Expand All @@ -101,7 +101,7 @@ public override DateTime ValidFrom
}

/// <summary>
/// Gets the time the token is valid to.
/// Gets the time the token is valid to. This value is always in UTC.
/// </summary>
public override DateTime ValidTo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public ICollection<KeyInfo> KeyInfos
}

/// <summary>
/// Gets or sets a time instant before which the subject cannot be confirmed. [Saml2Core, 2.4.1.2]
/// Gets or sets a time instant before which the subject cannot be confirmed. If the provided DateTime is not in UTC, it will
/// be converted to UTC.[Saml2Core, 2.4.1.2]
/// </summary>
public DateTime? NotBefore
{
Expand All @@ -86,7 +87,8 @@ public DateTime? NotBefore
}

/// <summary>
/// Gets or sets a time instant at which the subject can no longer be confirmed. [Saml2Core, 2.4.1.2]
/// Gets or sets a time instant at which the subject can no longer be confirmed. If the provided DateTime is not in UTC, it will
/// be converted to UTC. [Saml2Core, 2.4.1.2]
/// </summary>
public DateTime? NotOnOrAfter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Microsoft.IdentityModel.Tokens
public class SecurityTokenExpiredException : SecurityTokenValidationException
{
/// <summary>
/// Gets or sets the Expires value that created the validation exception.
/// Gets or sets the Expires value that created the validation exception. This value is always in UTC.
/// </summary>
public DateTime Expires { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ namespace Microsoft.IdentityModel.Tokens
public class SecurityTokenInvalidLifetimeException : SecurityTokenValidationException
{
/// <summary>
/// Gets or sets the NotBefore value that created the validation exception.
/// Gets or sets the NotBefore value that created the validation exception. This value is always in UTC.
/// </summary>
public DateTime? NotBefore { get; set; }

/// <summary>
/// Gets or sets the Expires value that created the validation exception.
/// Gets or sets the Expires value that created the validation exception. This value is always in UTC.
/// </summary>
public DateTime? Expires { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Microsoft.IdentityModel.Tokens
public class SecurityTokenNotYetValidException : SecurityTokenValidationException
{
/// <summary>
/// Gets or sets the NotBefore value that created the validation exception.
/// Gets or sets the NotBefore value that created the validation exception. This value is always in UTC.
/// </summary>
public DateTime NotBefore { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.IdentityModel.Tokens/SecurityTokenDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class SecurityTokenDescriptor
public EncryptingCredentials EncryptingCredentials { get; set; }

/// <summary>
/// Gets or sets the value of the 'expiration' claim.
/// Gets or sets the value of the 'expiration' claim. This value should be in UTC.
/// </summary>
public DateTime? Expires { get; set; }

Expand All @@ -62,12 +62,12 @@ public class SecurityTokenDescriptor
public string Issuer { get; set; }

/// <summary>
/// Gets or sets the time the security token was issued.
/// Gets or sets the time the security token was issued. This value should be in UTC.
/// </summary>
public DateTime? IssuedAt { get; set; }

/// <summary>
/// Gets or sets the notbefore time for the security token.
/// Gets or sets the notbefore time for the security token. This value should be in UTC.
/// </summary>
public DateTime? NotBefore { get; set; }

Expand Down

0 comments on commit affefe0

Please sign in to comment.