ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
hook_cron.php File Reference

Go to the source code of this file.

Functions

 metarefresh_hook_cron (&$croninfo)
 Hook to run a cron job. More...
 

Function Documentation

◆ metarefresh_hook_cron()

metarefresh_hook_cron ( $croninfo)

Hook to run a cron job.

Parameters
array&$croninfoOutput

Definition at line 7 of file hook_cron.php.

7 {
8 assert('is_array($croninfo)');
9 assert('array_key_exists("summary", $croninfo)');
10 assert('array_key_exists("tag", $croninfo)');
11
12 SimpleSAML\Logger::info('cron [metarefresh]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
13
14 try {
16 $mconfig = SimpleSAML_Configuration::getOptionalConfig('config-metarefresh.php');
17
18 $sets = $mconfig->getConfigList('sets', array());
19 $stateFile = $config->getPathValue('datadir', 'data/') . 'metarefresh-state.php';
20
21 foreach ($sets AS $setkey => $set) {
22 // Only process sets where cron matches the current cron tag
23 $cronTags = $set->getArray('cron');
24 if (!in_array($croninfo['tag'], $cronTags, true)) continue;
25
26 SimpleSAML\Logger::info('cron [metarefresh]: Executing set [' . $setkey . ']');
27
28 $expireAfter = $set->getInteger('expireAfter', NULL);
29 if ($expireAfter !== NULL) {
30 $expire = time() + $expireAfter;
31 } else {
32 $expire = NULL;
33 }
34
35 $outputDir = $set->getString('outputDir');
36 $outputDir = $config->resolvePath($outputDir);
37 $outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
38
40 'type' => $outputFormat,
41 'directory' => $outputDir,
42 ));
43
44 $metaloader = new sspmod_metarefresh_MetaLoader($expire, $stateFile, $oldMetadataSrc);
45
46 # Get global blacklist, whitelist and caching info
47 $blacklist = $mconfig->getArray('blacklist', array());
48 $whitelist = $mconfig->getArray('whitelist', array());
49 $conditionalGET = $mconfig->getBoolean('conditionalGET', FALSE);
50
51 // get global type filters
52 $available_types = array(
53 'saml20-idp-remote',
54 'saml20-sp-remote',
55 'shib13-idp-remote',
56 'shib13-sp-remote',
57 'attributeauthority-remote'
58 );
59 $set_types = $set->getArrayize('types', $available_types);
60
61 foreach($set->getArray('sources') AS $source) {
62
63 // filter metadata by type of entity
64 if (isset($source['types'])) {
65 $metaloader->setTypes($source['types']);
66 } else {
67 $metaloader->setTypes($set_types);
68 }
69
70 # Merge global and src specific blacklists
71 if(isset($source['blacklist'])) {
72 $source['blacklist'] = array_unique(array_merge($source['blacklist'], $blacklist));
73 } else {
74 $source['blacklist'] = $blacklist;
75 }
76
77 # Merge global and src specific whitelists
78 if(isset($source['whitelist'])) {
79 $source['whitelist'] = array_unique(array_merge($source['whitelist'], $whitelist));
80 } else {
81 $source['whitelist'] = $whitelist;
82 }
83
84 # Let src specific conditionalGET override global one
85 if(!isset($source['conditionalGET'])) {
86 $source['conditionalGET'] = $conditionalGET;
87 }
88
89 SimpleSAML\Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
90 $metaloader->loadSource($source);
91 }
92
93 // Write state information back to disk
94 $metaloader->writeState();
95
96 switch ($outputFormat) {
97 case 'flatfile':
98 $metaloader->writeMetadataFiles($outputDir);
99 break;
100 case 'serialize':
101 $metaloader->writeMetadataSerialize($outputDir);
102 break;
103 }
104
105 if ($set->hasValue('arp')) {
106 $arpconfig = SimpleSAML_Configuration::loadFromArray($set->getValue('arp'));
107 $metaloader->writeARPfile($arpconfig);
108 }
109 }
110
111 } catch (Exception $e) {
112 $croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage();
113 }
114}
$source
Definition: linkback.php:22
static info($string)
Definition: Logger.php:201
static debug($string)
Definition: Logger.php:213
static getOptionalConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
static getSource($sourceConfig)
This function creates a metadata source based on the given configuration.
$mconfig
Definition: fetch.php:4
$sets
Definition: fetch.php:11
$croninfo
Definition: cron.php:23
$expire
Definition: saml2-acs.php:140
foreach( $argv as $a) if(count($files)===0) $metaloader
$outputDir
Definition: metarefresh.php:28

References $config, $croninfo, $expire, $mconfig, $metaloader, $outputDir, $sets, $source, SimpleSAML\Logger\debug(), SimpleSAML_Configuration\getInstance(), SimpleSAML_Configuration\getOptionalConfig(), SimpleSAML_Metadata_MetaDataStorageSource\getSource(), SimpleSAML\Logger\info(), and SimpleSAML_Configuration\loadFromArray().

+ Here is the call graph for this function: