ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
sspmod_expirycheck_Auth_Process_ExpiryDate Class Reference
+ Inheritance diagram for sspmod_expirycheck_Auth_Process_ExpiryDate:
+ Collaboration diagram for sspmod_expirycheck_Auth_Process_ExpiryDate:

Public Member Functions

 __construct ($config, $reserved)
 Initialize this filter. More...
 
 shWarning (&$state, $expireOnDate, $warndaysbefore)
 Show expirational warning if remaining days is equal or under defined $warndaysbefore. More...
 
 checkDate ($expireOnDate)
 Check if given date is older than today. More...
 
 process (&$state)
 Apply filter. More...
 
- Public Member Functions inherited from SimpleSAML_Auth_ProcessingFilter
 __construct (&$config, $reserved)
 Constructor for a processing filter. More...
 
 process (&$request)
 Process a request. More...
 

Private Attributes

 $warndaysbefore = 0
 
 $netid_attr = NULL
 
 $expirydate_attr = NULL
 
 $date_format = 'd.m.Y'
 

Additional Inherited Members

- Data Fields inherited from SimpleSAML_Auth_ProcessingFilter
 $priority = 50
 Priority of this filter. More...
 

Detailed Description

Definition at line 23 of file ExpiryDate.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_expirycheck_Auth_Process_ExpiryDate::__construct (   $config,
  $reserved 
)

Initialize this filter.

Parameters
array$configConfiguration information about this filter.
mixed$reservedFor future use.

Definition at line 37 of file ExpiryDate.php.

37 {
38 parent::__construct($config, $reserved);
39
40 assert('is_array($config)');
41
42 if (array_key_exists('warndaysbefore', $config)) {
43 $this->warndaysbefore = $config['warndaysbefore'];
44 if (!is_string($this->warndaysbefore)) {
45 throw new Exception('Invalid value for number of days given to expirycheck::ExpiryDate filter.');
46 }
47 }
48
49 if (array_key_exists('netid_attr', $config)) {
50 $this->netid_attr = $config['netid_attr'];
51 if (!is_string($this->netid_attr)) {
52 throw new Exception('Invalid attribute name given as eduPersonPrincipalName to expirycheck::ExpiryDate filter.');
53 }
54 }
55
56 if (array_key_exists('expirydate_attr', $config)) {
57 $this->expirydate_attr = $config['expirydate_attr'];
58 if (!is_string($this->expirydate_attr)) {
59 throw new Exception('Invalid attribute name given as schacExpiryDate to expirycheck::ExpiryDate filter.');
60 }
61 }
62
63 if (array_key_exists('date_format', $config)) {
64 $this->date_format = $config['date_format'];
65 if (!is_string($this->date_format)) {
66 throw new Exception('Invalid date format given to expirycheck::ExpiryDate filter.');
67 }
68 }
69 }

References $config.

Member Function Documentation

◆ checkDate()

sspmod_expirycheck_Auth_Process_ExpiryDate::checkDate (   $expireOnDate)

Check if given date is older than today.

Parameters
integer$expireOnDate
Returns
bool

Definition at line 98 of file ExpiryDate.php.

98 {
99 $now = time();
100 $end = $expireOnDate;
101
102 if ($now <= $end) {
103 return true;
104 } else {
105 return false;
106 }
107
108 }
$end
Definition: saml1-acs.php:18

References $end.

◆ process()

sspmod_expirycheck_Auth_Process_ExpiryDate::process ( $state)

Apply filter.

Parameters
array&$stateThe current state.

Reimplemented from SimpleSAML_Auth_ProcessingFilter.

Definition at line 115 of file ExpiryDate.php.

115 {
116 /*
117 * UTC format: 20090527080352Z
118 */
119 $netId = $state['Attributes'][$this->netid_attr][0];
120 $expireOnDate = strtotime($state['Attributes'][$this->expirydate_attr][0]);
121
122 if (self::shWarning($state, $expireOnDate, $this->warndaysbefore)) {
123 assert('is_array($state)');
124 if (isset($state['isPassive']) && $state['isPassive'] === TRUE) {
125 // We have a passive request. Skip the warning.
126 return;
127 }
128
129 SimpleSAML\Logger::warning('expirycheck: NetID ' . $netId .
130 ' is about to expire!');
131
132 // Save state and redirect
133 $state['expireOnDate'] = date($this->date_format, $expireOnDate);
134 $state['netId'] = $netId;
135 $id = SimpleSAML_Auth_State::saveState($state, 'expirywarning:about2expire');
136 $url = SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php');
138 }
139
140 if (!self::checkDate($expireOnDate)) {
141 SimpleSAML\Logger::error('expirycheck: NetID ' . $netId .
142 ' has expired [' . date($this->date_format, $expireOnDate) . ']. Access denied!');
144
145 /* Save state and redirect. */
146 $state['expireOnDate'] = date($this->date_format, $expireOnDate);
147 $state['netId'] = $netId;
148 $id = SimpleSAML_Auth_State::saveState($state, 'expirywarning:expired');
149 $url = SimpleSAML\Module::getModuleURL('expirycheck/expired.php');
151
152 }
153 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
static warning($string)
Definition: Logger.php:179
static error($string)
Definition: Logger.php:168
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:303
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
Definition: HTTP.php:962
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
if(!array_key_exists('StateId', $_REQUEST)) $id
$url
$globalConfig

References $globalConfig, $id, $netid_attr, $state, $url, date, SimpleSAML\Logger\error(), SimpleSAML_Configuration\getInstance(), SimpleSAML\Module\getModuleURL(), SimpleSAML\Utils\HTTP\redirectTrustedURL(), SimpleSAML_Auth_State\saveState(), and SimpleSAML\Logger\warning().

+ Here is the call graph for this function:

◆ shWarning()

sspmod_expirycheck_Auth_Process_ExpiryDate::shWarning ( $state,
  $expireOnDate,
  $warndaysbefore 
)

Show expirational warning if remaining days is equal or under defined $warndaysbefore.

Parameters
integer$expireOnDate
integer$warndaysbefore
Returns
bool

Definition at line 78 of file ExpiryDate.php.

78 {
79 $now = time();
80 $end = $expireOnDate;
81
82 if ($expireOnDate >= $now) {
83 $days = (int)(($end - $now) / (24*60*60));
84 if ($days <= $warndaysbefore) {
85 $state['daysleft'] = $days;
86 return true;
87 }
88 }
89 return false;
90 }

References $end, $state, and $warndaysbefore.

Field Documentation

◆ $date_format

sspmod_expirycheck_Auth_Process_ExpiryDate::$date_format = 'd.m.Y'
private

Definition at line 28 of file ExpiryDate.php.

◆ $expirydate_attr

sspmod_expirycheck_Auth_Process_ExpiryDate::$expirydate_attr = NULL
private

Definition at line 27 of file ExpiryDate.php.

◆ $netid_attr

sspmod_expirycheck_Auth_Process_ExpiryDate::$netid_attr = NULL
private

Definition at line 26 of file ExpiryDate.php.

Referenced by process().

◆ $warndaysbefore

sspmod_expirycheck_Auth_Process_ExpiryDate::$warndaysbefore = 0
private

Definition at line 25 of file ExpiryDate.php.

Referenced by shWarning().


The documentation for this class was generated from the following file: