resolvePath($config['file']); } elseif (array_key_exists('url', $config)) { $src = $config['url']; } elseif (array_key_exists('xml', $config)) { $srcXml = $config['xml']; } else { throw new Exception("Missing one of 'file', 'url' and 'xml' in XML metadata source configuration."); } $SP1x = array(); $IdP1x = array(); $SP20 = array(); $IdP20 = array(); $AAD = array(); if(isset($src)) { $entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsFile($src); } elseif(isset($srcXml)) { $entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsString($srcXml); } else { throw new Exception("Neither source file path/URI nor string data provided"); } foreach ($entities as $entityId => $entity) { $md = $entity->getMetadata1xSP(); if ($md !== null) { $SP1x[$entityId] = $md; } $md = $entity->getMetadata1xIdP(); if ($md !== null) { $IdP1x[$entityId] = $md; } $md = $entity->getMetadata20SP(); if ($md !== null) { $SP20[$entityId] = $md; } $md = $entity->getMetadata20IdP(); if ($md !== null) { $IdP20[$entityId] = $md; } $md = $entity->getAttributeAuthorities(); if (count($md) > 0) { $AAD[$entityId] = $md[0]; } } $this->metadata = array( 'shib13-sp-remote' => $SP1x, 'shib13-idp-remote' => $IdP1x, 'saml20-sp-remote' => $SP20, 'saml20-idp-remote' => $IdP20, 'attributeauthority-remote' => $AAD, ); } /** * This function returns an associative array with metadata for all entities in the given set. The * key of the array is the entity id. * * @param string $set The set we want to list metadata for. * * @return array An associative array with all entities in the given set. */ public function getMetadataSet($set) { if (array_key_exists($set, $this->metadata)) { return $this->metadata[$set]; } // we don't have this metadata set return array(); } }