diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index bf91de66079e3983b3b19577ff79518e8a137a00..2517465bf7a5a40ac74fced094a095eca1e9fbf0 100644 --- a/modules/metarefresh/hooks/hook_cron.php +++ b/modules/metarefresh/hooks/hook_cron.php @@ -51,6 +51,11 @@ function metarefresh_hook_cron(&$croninfo) { break; } + + if (array_key_exists('arp', $set)) { + $arpconfig = SimpleSAML_Configuration::loadFromArray($set['arp']); + $metaloader->writeARPfile($arpconfig); + } } } catch (Exception $e) { diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php index b06ff2f673ddd08c9ae2017aa115cc836aca8985..a9949a0705441e6e55d6b349710010193f23271e 100644 --- a/modules/metarefresh/lib/MetaLoader.php +++ b/modules/metarefresh/lib/MetaLoader.php @@ -136,7 +136,36 @@ class sspmod_metarefresh_MetaLoader { } + /** + * This function writes the metadata to an ARP file + */ + function writeARPfile($config) { + + assert('is_a($config, \'SimpleSAML_Configuration\')'); + + $arpfile = $config->getValue('arpfile'); + $types = array('saml20-sp-remote'); + + $md = array(); + foreach($this->metadata as $category => $elements) { + if (!in_array($category, $types)) continue; + $md = array_merge($md, $elements); + } + + #$metadata, $attributemap, $prefix, $suffix + $arp = new sspmod_metarefresh_ARP($md, + $config->getValue('attributemap', ''), + $config->getValue('prefix', ''), + $config->getValue('suffix', '') + ); + + + $arpxml = $arp->getXML(); + + SimpleSAML_Logger::info('Writing ARP file: ' . $arpfile . "\n"); + file_put_contents($arpfile, $arpxml); + } /**