private function getmetadata_shib13idpremote($metadataxml)
 {
     // Create a parser for the metadata document.
     $metadata_parser = new SimpleSAML_XML_Parser($metadataxml);
     // Get all entries in the metadata.
     $idpentities = $metadata_parser->simplexml->xpath('/saml2meta:EntitiesDescriptor/saml2meta:EntityDescriptor[./saml2meta:IDPSSODescriptor]');
     if (!$idpentities) {
         throw new Exception('Could not find any entity descriptors in the meta data file: ' . $metadatasetfile);
     }
     // Array to hold the resulting metadata, to return at the end of this function.
     $metadata = array();
     // Traverse all entries.
     foreach ($idpentities as $idpentity) {
         try {
             $entityid = (string) $idpentity['entityID'];
             if (!$entityid) {
                 throw new Exception('Could not find entityID in element');
             }
             $metadata[$entityid] = array('entityid' => $entityid);
             $metadata_entry = SimpleSAML_XML_Parser::fromSimpleXMLElement($idpentity);
             $metadata[$entityid]['SingleSignOnService'] = $metadata_entry->getValue("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:SingleSignOnService[@Binding='urn:mace:shibboleth:1.0:profiles:AuthnRequest']/@Location", true);
             $metadata[$entityid]['certFingerprint'] = SimpleSAML_Utilities::cert_fingerprint($metadata_entry->getValue("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:KeyDescriptor[@use='signing']/ds:KeyInfo/ds:X509Data/ds:X509Certificate", true));
             $seek_base64 = $metadata_entry->getValue("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:Extensions/saml2:Attribute[@Name='urn:mace:feide.no:simplesamlphp:base64attributes']/saml2:AttributeValue");
             $metadata[$entityid]['base64attributes'] = isset($seek_base64) ? $seek_base64 === 'true' : false;
             $metadata[$entityid]['name'] = $metadata_entry->getValueAlternatives(array("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:Extensions/saml2:Attribute[@Name='urn:mace:feide.no:simplesamlphp:name']/saml2:AttributeValue", "/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:Organization/saml2meta:OrganizationDisplayName"));
             $metadata[$entityid]['description'] = $metadata_entry->getValue("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:Extensions/saml2:Attribute[@Name='urn:mace:feide.no:simplesamlphp:description']/saml2:AttributeValue");
         } catch (Exception $e) {
             SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage());
         }
     }
     return $metadata;
 }