Skip to content
Snippets Groups Projects
Unverified Commit 939cd8c1 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

PSR2

parent 1ddf2b79
No related branches found
No related tags found
No related merge requests found
...@@ -25,8 +25,8 @@ namespace SimpleSAML\Module\expirycheck\Auth\Process; ...@@ -25,8 +25,8 @@ namespace SimpleSAML\Module\expirycheck\Auth\Process;
class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
{ {
private $warndaysbefore = 0; private $warndaysbefore = 0;
private $netid_attr = NULL; private $netid_attr = null;
private $expirydate_attr = NULL; private $expirydate_attr = null;
private $date_format = 'd.m.Y'; private $date_format = 'd.m.Y';
...@@ -36,7 +36,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -36,7 +36,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
* @param array $config Configuration information about this filter. * @param array $config Configuration information about this filter.
* @param mixed $reserved For future use. * @param mixed $reserved For future use.
*/ */
public function __construct($config, $reserved) { public function __construct($config, $reserved)
{
parent::__construct($config, $reserved); parent::__construct($config, $reserved);
assert(is_array($config)); assert(is_array($config));
...@@ -77,7 +78,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -77,7 +78,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
* @return bool * @return bool
* *
*/ */
public function shWarning(&$state, $expireOnDate, $warndaysbefore) { public function shWarning(&$state, $expireOnDate, $warndaysbefore)
{
$now = time(); $now = time();
$end = $expireOnDate; $end = $expireOnDate;
...@@ -97,7 +99,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -97,7 +99,8 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
* @return bool * @return bool
* *
*/ */
public function checkDate($expireOnDate) { public function checkDate($expireOnDate)
{
$now = time(); $now = time();
$end = $expireOnDate; $end = $expireOnDate;
...@@ -106,7 +109,6 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -106,7 +109,6 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
} else { } else {
return false; return false;
} }
} }
/** /**
...@@ -114,22 +116,22 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -114,22 +116,22 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
* *
* @param array &$state The current state. * @param array &$state The current state.
*/ */
public function process(&$state) { public function process(&$state)
{
/* /*
* UTC format: 20090527080352Z * UTC format: 20090527080352Z
*/ */
$netId = $state['Attributes'][$this->netid_attr][0]; $netId = $state['Attributes'][$this->netid_attr][0];
$expireOnDate = strtotime($state['Attributes'][$this->expirydate_attr][0]); $expireOnDate = strtotime($state['Attributes'][$this->expirydate_attr][0]);
if (self::shWarning($state, $expireOnDate, $this->warndaysbefore)) { if ($this->shWarning($state, $expireOnDate, $this->warndaysbefore)) {
assert(is_array($state)); assert(is_array($state));
if (isset($state['isPassive']) && $state['isPassive'] === TRUE) { if (isset($state['isPassive']) && $state['isPassive'] === true) {
// We have a passive request. Skip the warning. // We have a passive request. Skip the warning.
return; return;
} }
\SimpleSAML\Logger::warning('expirycheck: NetID ' . $netId . \SimpleSAML\Logger::warning('expirycheck: NetID '.$netId.' is about to expire!');
' is about to expire!');
// Save state and redirect // Save state and redirect
$state['expireOnDate'] = date($this->date_format, $expireOnDate); $state['expireOnDate'] = date($this->date_format, $expireOnDate);
...@@ -139,7 +141,7 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -139,7 +141,7 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
} }
if (!self::checkDate($expireOnDate)) { if (!$this->checkDate($expireOnDate)) {
\SimpleSAML\Logger::error('expirycheck: NetID '.$netId. \SimpleSAML\Logger::error('expirycheck: NetID '.$netId.
' has expired ['.date($this->date_format, $expireOnDate).']. Access denied!'); ' has expired ['.date($this->date_format, $expireOnDate).']. Access denied!');
...@@ -149,9 +151,6 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter ...@@ -149,9 +151,6 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter
$id = \SimpleSAML\Auth\State::saveState($state, 'expirywarning:expired'); $id = \SimpleSAML\Auth\State::saveState($state, 'expirywarning:expired');
$url = \SimpleSAML\Module::getModuleURL('expirycheck/expired.php'); $url = \SimpleSAML\Module::getModuleURL('expirycheck/expired.php');
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment