SimpleSAML_XML_Shib13_AuthnResponse::checkDateConditions PHP Method

checkDateConditions() protected static method

Note that this function allows a 10-minute leap from the initial time as marked by $start.
Author: Andreas Solberg, UNINETT AS ([email protected])
Author: Olav Morken, UNINETT AS ([email protected])
protected static checkDateConditions ( string | null $start = null, string | null $end = null ) : boolean
$start string | null A SAML2 timestamp marking the start of the period to check. Defaults to null, in which case there's no limitations in the past.
$end string | null A SAML2 timestamp marking the end of the period to check. Defaults to null, in which case there's no limitations in the future.
return boolean True if the current time belongs to the period specified by $start and $end. False otherwise.
    protected static function checkDateConditions($start = null, $end = null)
    {
        $currentTime = time();
        if (!empty($start)) {
            $startTime = \SAML2\Utils::xsDateTimeToTimestamp($start);
            // allow for a 10 minute difference in time
            if ($startTime < 0 || $startTime - 600 > $currentTime) {
                return false;
            }
        }
        if (!empty($end)) {
            $endTime = \SAML2\Utils::xsDateTimeToTimestamp($end);
            if ($endTime < 0 || $endTime <= $currentTime) {
                return false;
            }
        }
        return true;
    }