diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index f1a0512c7840d35e154a53b2fb271d38f2556bb8..9f18ffea458e7f771f42c0fa0191196584b86308 100644 --- a/modules/metarefresh/hooks/hook_cron.php +++ b/modules/metarefresh/hooks/hook_cron.php @@ -48,8 +48,25 @@ function metarefresh_hook_cron(&$croninfo) { $whitelist = $mconfig->getArray('whitelist', array()); $conditionalGET = $mconfig->getBoolean('conditionalGET', FALSE); + // get global type filters + $available_types = array( + 'saml20-idp-remote', + 'saml20-sp-remote', + 'shib13-idp-remote', + 'shib13-sp-remote', + 'attributeauthority-remote' + ); + $set_types = $set->getArrayize('types', $available_types); + foreach($set->getArray('sources') AS $source) { + // filter metadata by type of entity + if (isset($source['types'])) { + $metaloader->setTypes($source['types']); + } else { + $metaloader->setTypes($set_types); + } + # Merge global and src specific blacklists if(isset($source['blacklist'])) { $source['blacklist'] = array_unique(array_merge($source['blacklist'], $blacklist)); diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php index 3f09817ea988efdc2bfa78701292fd3c9df7bfc7..91f505e287213d3944b074a6211b14bf716ccc3a 100644 --- a/modules/metarefresh/lib/MetaLoader.php +++ b/modules/metarefresh/lib/MetaLoader.php @@ -11,8 +11,13 @@ class sspmod_metarefresh_MetaLoader { private $oldMetadataSrc; private $stateFile; private $changed; - private static $types = array('saml20-idp-remote', 'saml20-sp-remote', - 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote'); + private $types = array( + 'saml20-idp-remote', + 'saml20-sp-remote', + 'shib13-idp-remote', + 'shib13-sp-remote', + 'attributeauthority-remote' + ); /** @@ -37,6 +42,33 @@ class sspmod_metarefresh_MetaLoader { } + + /** + * Get the types of entities that will be loaded. + * + * @return array The entity types allowed. + */ + public function getTypes() + { + return $this->types; + } + + + /** + * Set the types of entities that will be loaded. + * + * @param string|array $types Either a string with the name of one single type allowed, or an array with a list of + * types. Pass an empty array to reset to all types of entities. + */ + public function setTypes($types) + { + if (!is_array($types)) { + $types = array($types); + } + $this->types = $types; + } + + /** * This function processes a SAML metadata file. * @@ -176,7 +208,7 @@ class sspmod_metarefresh_MetaLoader { private function addCachedMetadata($source) { if(isset($this->oldMetadataSrc)) { - foreach(self::$types as $type) { + foreach($this->types as $type) { foreach($this->oldMetadataSrc->getMetadataSet($type) as $entity) { if(array_key_exists('metarefresh:src', $entity)) { if($entity['metarefresh:src'] == $source['src']) { @@ -369,7 +401,7 @@ class sspmod_metarefresh_MetaLoader { } } - foreach(self::$types as $type) { + foreach($this->types as $type) { $filename = $outputDir . '/' . $type . '.php'; diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php index 322c34408aa2e0b2b2bd7132e113afd45ec67a87..5f8cb282ac0917129ff0fae4cba4554cc077371a 100644 --- a/modules/metarefresh/www/fetch.php +++ b/modules/metarefresh/www/fetch.php @@ -30,8 +30,25 @@ foreach ($sets AS $setkey => $set) { $blacklist = $mconfig->getArray('blacklist', array()); $whitelist = $mconfig->getArray('whitelist', array()); + // get global type filters + $available_types = array( + 'saml20-idp-remote', + 'saml20-sp-remote', + 'shib13-idp-remote', + 'shib13-sp-remote', + 'attributeauthority-remote' + ); + $set_types = $set->getArrayize('types', $available_types); + foreach($set->getArray('sources') AS $source) { + // filter metadata by type of entity + if (isset($source['types'])) { + $metaloader->setTypes($source['types']); + } else { + $metaloader->setTypes($set_types); + } + # Merge global and src specific blacklists if(isset($source['blacklist'])) { $source['blacklist'] = array_unique(array_merge($source['blacklist'], $blacklist));