Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions DotNetCasClient/Validation/SamlUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,27 @@ public static bool IsValidAssertion(DateTime notBefore, DateTime notOnOrAfter, l
ProtoLogger.Debug("Assertion has no bounding dates. Will not process.");
return false;
}
ProtoLogger.Debug("Assertion validity window: {0} - {1} +/- {2}ms", notBefore, notOnOrAfter, toleranceTicks / 10000);


ProtoLogger.Debug("Assertion validity window: {0} - {1} +/- {2}ms", notBefore, notOnOrAfter, toleranceTicks / 10000);

long utcNowTicks = DateTime.UtcNow.Ticks;
if (utcNowTicks + toleranceTicks < notBefore.Ticks)
ProtoLogger.Debug("Current time: {0}", new DateTime(utcNowTicks));

if (notOnOrAfter < notBefore)
{
ProtoLogger.Debug("Assertion is not yet valid.");
ProtoLogger.Debug("Assertion has non-sequential bounding dates.");
return false;
}

if (notOnOrAfter.Ticks <= utcNowTicks - toleranceTicks)

if ((utcNowTicks + toleranceTicks) < notBefore.Ticks)
{
ProtoLogger.Debug("Assertion is not yet valid: ( {0} + {1} ) < {2}", utcNowTicks, toleranceTicks, notBefore.Ticks);
return false;
}

if (notOnOrAfter.Ticks <= (utcNowTicks - toleranceTicks))
{
ProtoLogger.Debug("Assertion is expired.");
ProtoLogger.Debug("Assertion is expired: {2} <= ( {0} + {1} )", utcNowTicks, toleranceTicks, notOnOrAfter.Ticks);
return false;
}

Expand Down