Skip to content

Commit

Permalink
formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyyangsong committed Apr 3, 2024
1 parent 399ee2c commit c79125d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Microsoft.IdentityModel.Tokens/ValidatorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ internal static void ValidateLifetime(DateTime? notBefore, DateTime? expires, Se

if (notBefore.HasValue && expires.HasValue && (notBefore.Value > expires.Value))
throw LogHelper.LogExceptionMessage(new SecurityTokenInvalidLifetimeException(LogHelper.FormatInvariant(LogMessages.IDX10224, LogHelper.MarkAsNonPII(notBefore.Value), LogHelper.MarkAsNonPII(expires.Value)))
{ NotBefore = notBefore, Expires = expires });
{
NotBefore = notBefore,
Expires = expires
});

DateTime utcNow = DateTime.UtcNow;
if (notBefore.HasValue && (notBefore.Value > DateTimeUtil.Add(utcNow, validationParameters.ClockSkew)))
throw LogHelper.LogExceptionMessage(new SecurityTokenNotYetValidException(LogHelper.FormatInvariant(LogMessages.IDX10222, LogHelper.MarkAsNonPII(notBefore.Value), LogHelper.MarkAsNonPII(utcNow)))
{ NotBefore = notBefore.Value });
{
NotBefore = notBefore.Value
});

if (expires.HasValue && (expires.Value < DateTimeUtil.Add(utcNow, validationParameters.ClockSkew.Negate())))
throw LogHelper.LogExceptionMessage(new SecurityTokenExpiredException(LogHelper.FormatInvariant(LogMessages.IDX10223, LogHelper.MarkAsNonPII(expires.Value), LogHelper.MarkAsNonPII(utcNow)))
{ Expires = expires.Value });
{
Expires = expires.Value
});

// if it reaches here, that means lifetime of the token is valid
LogHelper.LogInformation(LogMessages.IDX10239);
Expand Down

0 comments on commit c79125d

Please sign in to comment.