Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IsValidAssertion #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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