From a5c00042af6c9d896218b590f194d2760fea42e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Fri, 15 May 2009 09:40:25 +0000 Subject: [PATCH] Adding support for generating Shibboleth ARP files. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1504 44740490-163a-0410-bde0-09ae8108e29a --- modules/metarefresh/hooks/hook_cron.php | 5 +++++ modules/metarefresh/lib/MetaLoader.php | 29 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index bf91de660..2517465bf 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 b06ff2f67..a9949a070 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); + } /** -- GitLab