From 608a9b2ccab3f11b9ba2e72f24b38bdbb7047bc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Tue, 8 Jan 2008 11:13:23 +0000
Subject: [PATCH] Changed classes that access metadata to use the new API. Also
 added some initial code to start parsing Shibboleth 1.3 IdP metadata.. will
 do more on this tomorrow.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@147 44740490-163a-0410-bde0-09ae8108e29a
---
 .../Metadata/MetaDataStorageHandler.php       |   5 +-
 .../MetaDataStorageHandlerSAML2Meta.php       |  56 +++++++-
 www/admin/metadata.php                        | 121 ++++++++----------
 www/example-simple/hostnames.php              |   5 +-
 www/example-simple/saml2-example.php          |   4 +-
 www/example-simple/shib13-example.php         |   9 +-
 www/openid/provider/server.php                |   6 +-
 www/saml2/idp/SSOService.php                  |   4 +-
 www/saml2/idp/SingleLogoutService.php         |   4 +-
 www/saml2/idp/metadata.php                    |   4 +-
 www/saml2/sp/AssertionConsumerService.php     |   4 +-
 www/saml2/sp/SingleLogoutService.php          |   4 +-
 www/saml2/sp/idpdisco.php                     |   4 +-
 www/saml2/sp/initSLO.php                      |   4 +-
 www/saml2/sp/initSSO.php                      |   4 +-
 www/saml2/sp/metadata.php                     |   4 +-
 www/shib13/idp/SSOService.php                 |   4 +-
 17 files changed, 140 insertions(+), 106 deletions(-)

diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
index 87f90ec14..ab51591b9 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
@@ -52,6 +52,7 @@ abstract class SimpleSAML_Metadata_MetaDataStorageHandler {
 	 * the subclasses of this class.
 	 */
 	protected function __construct() {
+		
 	}
 
 
@@ -89,10 +90,10 @@ abstract class SimpleSAML_Metadata_MetaDataStorageHandler {
 			require_once('SimpleSAML/Metadata/MetaDataStorageHandlerFlatfile.php');
 			$sh = new SimpleSAML_Metadata_MetaDataStorageHandlerFlatfile();
 			
-		} elseif ($handler === 'saml2XMLmeta')  {
+		} elseif ($handler === 'saml2xmlmeta')  {
 
 			require_once('SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php');
-			$sh = new SimpleSAML_Metadata_MetaDataStorageHandlerFlatfile();
+			$sh = new SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta();
 
 		
 		} else {
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
index 64954a315..c62c5e9a0 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
@@ -16,7 +16,7 @@ require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 /**
  * Configuration of SimpleSAMLphp
  */
-class MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorageHandler {
+class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorageHandler {
 
 
 
@@ -28,7 +28,6 @@ class MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorag
 	}
 
 
-
 	public function load($set) {
 		$metadata = null;
 		if (!in_array($set, array(
@@ -43,13 +42,56 @@ class MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorag
 		assert($config instanceof SimpleSAML_Configuration);
 		
 		$metadatasetfile = $config->getBaseDir() . '/' . 
-			$config->getValue('metadatadir') . '/' . $set . '/' . $file . '.php';
+			$config->getValue('metadatadir') . '/xml/' . $set . '.xml';
+		
+		
+		if (!file_exists($metadatasetfile)) throw new Exception('Could not find SAML 2.0 Metadata file :'. $metadatasetfile);
+		
+		#$metadata = file_get_contents($metadatasetfile);
+		
+		// for now testing with the shib aai metadata...
+		$metadata = file_get_contents("http://www.switch.ch/aai/federation/SWITCHaai/metadata.switchaai_signed.xml");
+		echo '<pre>';
+		
+		$simplexml_metadata = new SimpleXMLElement($metadata);
+		$simplexml_metadata->registerXPathNamespace('saml2meta', 'urn:oasis:names:tc:SAML:2.0:metadata');
 		
+		$idpentities = $simplexml_metadata->xpath('/saml2meta:EntitiesDescriptor/saml2meta:EntityDescriptor[./saml2meta:IDPSSODescriptor]');
 		
-		if (!file_exists($metadatasetfile)) {
-			throw new Exception('Could not open file: ' . $metadatasetfile);
+		if (!$idpentities) throw new Exception('Could not find any entity descriptors in the meta data file: ' . $metadatasetfile);
+		foreach ($idpentities as $idpentity) {
+			echo 'Entity: ' . $idpentity['entityID'][0] . "\n";
+			
+			$newmeta = array('entityid' => (string) $idpentity['entityID']);
+			
+			#$idpentity['xmlns'] = 'urn:oasis:names:tc:SAML:2.0:metadata';
+			
+			$namespaces = $idpentity->getNamespaces();
+			
+			foreach ($namespaces AS $prefix => $ns) {
+				$newmeta[($prefix === '') ? 'xmlns' : 'xmlns:' . $prefix)] = $ns;
+			}
+			
+			$simplexml_metadata_entry = new SimpleXMLElement($idpentity->asXML());
+			$simplexml_metadata_entry->registerXPathNamespace('saml2meta', 'urn:oasis:names:tc:SAML:2.0:metadata');
+			
+			
+			$entry = $simplexml_metadata_entry->xpath("/saml2meta:EntityDescriptor/saml2meta:IDPSSODescriptor/saml2meta:SingleSignOnService[@Binding='urn:mace:shibboleth:1.0:profiles:AuthnRequest']/@Location");
+			
+			$newmeta['SingleSignOnService'] = (string)$entry[0]['Location'];
+			
+			echo 'Entry: ';
+			print_r($newmeta);
+
 		}
-		include($metadatasetfile);
+		
+		
+		//echo htmlentities($metadata);
+		echo '</pre>';
+				exit();
+		
+
+
 		
 		if (!is_array($metadata)) {
 			throw new Exception('Could not load metadata set [' . $set . '] from file: ' . $metadatasetfile);
@@ -65,7 +107,7 @@ class MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Metadata_MetaDataStorag
 		}
 
 	}
-
+	
 	
 	public function getMetaData($entityid = null, $set = 'saml20-sp-hosted') {
 		if (!isset($entityid)) {
diff --git a/www/admin/metadata.php b/www/admin/metadata.php
index 2ddc42b52..2ce1d3e6c 100644
--- a/www/admin/metadata.php
+++ b/www/admin/metadata.php
@@ -1,93 +1,80 @@
 <?php
 
-require_once('../../_include.php');
+require_once('../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+//$metadata = new SimpleSAML_XML_MetaDataStore($config);
 $session = SimpleSAML_Session::getInstance();
 
+
+
 try {
 
-	$idpmeta = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $metadata->getMetaDataCurrent('saml20-idp-hosted');
-	$idpentityid = isset($_GET['idpentityid']) ? $_GET['idpentityid'] : $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
-	
-	$publiccert = $config->getBaseDir() . '/cert/' . $idpmeta['certificate'];
+	$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+
+
+	$et = new SimpleSAML_XHTML_Template($config, 'admin-metadatalist.php');
+
 
-	if (!file_exists($publiccert)) 
-		throw new Exception('Could not find certificate [' . $publiccert . '] to attach to the authentication resposne');
-	
-	$cert = file_get_contents($publiccert);
-	$data = XMLSecurityDSig::get509XCert($cert, true);
-	
-	
-	
-	
-	$metaxml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-	<EntityDescriptor xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
- entityID="' . $idpentityid . '">
-    <IDPSSODescriptor
-        WantAuthnRequestsSigned="false"
-        protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
-        
-                <KeyDescriptor use="signing">
-                        <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
-                          <ds:X509Data>
-                                <ds:X509Certificate>' . $data . '</ds:X509Certificate>
-                        </ds:X509Data>
-                  </ds:KeyInfo>
-                </KeyDescriptor>  
-        
-
-        
-        <!-- Logout endpoints -->
-        <SingleLogoutService
-            Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
-            Location="' . $metadata->getGenerated('SingleLogoutService', 'saml20-idp-hosted') . '"
-            ResponseLocation="' . $metadata->getGenerated('SingleLogoutService', 'saml20-idp-hosted') . '" 
-            index="0" 
-            isDefault="true"
-            />
-
-        
-        <!-- Supported Name Identifier Formats -->
-        <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</NameIDFormat>
-        
-        <!-- AuthenticationRequest Consumer endpoint -->
-        <SingleSignOnService
-            Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
-            Location="' . $metadata->getGenerated('SingleSignOnService', 'saml20-idp-hosted') . '" 
-            index="0" 
-            isDefault="true"
-            />
-        
-    </IDPSSODescriptor>
-</EntityDescriptor>';
 	
+	if ($config->getValue('enable.saml20-sp') === true) {
+		$results = array();	
+		$metalist = $metadata->getList('saml20-sp-hosted');
+		foreach ($metalist AS $entityid => $mentry) {
+			$results[$entityid] = SimpleSAML_Utilities::checkAssocArrayRules($mentry,
+				array('entityid', 'host', 'spNameQualifier', 'NameIDFormat', 'ForceAuthn'),
+				array('name', 'description')
+			);
+		}
+		$et->data['metadata.saml20-sp-hosted'] = $results;
+		
+		$metalist = $metadata->getList('saml20-idp-remote');
+		foreach ($metalist AS $entityid => $mentry) {
+			$results[$entityid] = SimpleSAML_Utilities::checkAssocArrayRules($mentry,
+				array('entityid', 'host', 'spNameQualifier', 'NameIDFormat', 'ForceAuthn'),
+				array('name', 'description')
+			);
+		}
+		$et->data['metadata.saml20-idp-remote'] = $results;
+		
+	}
 	
-	if ($_GET['output'] == 'xml') {
-		header('Content-Type: application/xml');
+	if ($config->getValue('enable.saml20-idp') === true) {
+		$results = array();	
+		$metalist = $metadata->getList('saml20-idp-hosted');
+		foreach ($metalist AS $entityid => $mentry) {
+			$results[$entityid] = SimpleSAML_Utilities::checkAssocArrayRules($mentry,
+				array('entityid', 'host', 'spNameQualifier', 'NameIDFormat', 'ForceAuthn'),
+				array('name', 'description')
+			);
+		}
+		$et->data['metadata.saml20-idp-hosted'] = $results;
+		
+		$metalist = $metadata->getList('saml20-sp-remote');
+		foreach ($metalist AS $entityid => $mentry) {
+			$results[$entityid] = SimpleSAML_Utilities::checkAssocArrayRules($mentry,
+				array('entityid', 'host', 'spNameQualifier', 'NameIDFormat', 'ForceAuthn'),
+				array('name', 'description')
+			);
+		}
+		$et->data['metadata.saml20-sp-remote'] = $results;
 		
-		echo $metaxml;
-		exit(0);
 	}
 
+	
+	
 
-	$defaultidp = $config->getValue('default-saml20-idp');
 	
-	$et = new SimpleSAML_XHTML_Template($config, 'metadata.php');
 	
+	
+	$et->data['header'] = 'Metadata overview';
 
-	$et->data['header'] = 'SAML 2.0 IdP Metadata';
-	$et->data['metaurl'] = SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURLNoQuery(), 'output=xml');
-	$et->data['metadata'] = htmlentities($metaxml);
-	$et->data['feide'] = in_array($defaultidp, array('sam.feide.no', 'max.feide.no'));
-	$et->data['defaultidp'] = $defaultidp;
 	
 	$et->show();
 	
diff --git a/www/example-simple/hostnames.php b/www/example-simple/hostnames.php
index e3fd751a0..7afcfd590 100644
--- a/www/example-simple/hostnames.php
+++ b/www/example-simple/hostnames.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 require_once('SimpleSAML/XML/SAML20/AuthnResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
@@ -13,7 +13,8 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 
 
diff --git a/www/example-simple/saml2-example.php b/www/example-simple/saml2-example.php
index 7a1caa6c5..30705a345 100644
--- a/www/example-simple/saml2-example.php
+++ b/www/example-simple/saml2-example.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 require_once('SimpleSAML/XML/SAML20/AuthnResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
@@ -14,7 +14,7 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $session = SimpleSAML_Session::getInstance();
 
 /* Check if valid local session exists.. */
diff --git a/www/example-simple/shib13-example.php b/www/example-simple/shib13-example.php
index bdf6fd844..339758acf 100644
--- a/www/example-simple/shib13-example.php
+++ b/www/example-simple/shib13-example.php
@@ -4,12 +4,15 @@ require_once('../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XHTML/Template.php');
 
-
+/* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+
+
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
+
 
 $session = SimpleSAML_Session::getInstance();
 
diff --git a/www/openid/provider/server.php b/www/openid/provider/server.php
index 93fa87de0..9d4f7a753 100644
--- a/www/openid/provider/server.php
+++ b/www/openid/provider/server.php
@@ -10,7 +10,7 @@ require_once('../../_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/Logger.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/AttributeFilter.php');
 require_once('SimpleSAML/XHTML/Template.php');
 
@@ -91,7 +91,7 @@ function action_default()
     if (!$request) {
 
 		$config = SimpleSAML_Configuration::getInstance();
-		$metadata = new SimpleSAML_XML_MetaDataStore($config);
+		$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 		
 		$t = new SimpleSAML_XHTML_Template($config, 'openid-about.php');
 		$t->data['openidserver'] = $metadata->getGenerated('server', 'openid-provider');
@@ -217,7 +217,7 @@ function check_authenticated_user() {
 	//session_start();
 	
 	$config = SimpleSAML_Configuration::getInstance();
-	$metadata = new SimpleSAML_XML_MetaDataStore($config);
+	$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 	$session = SimpleSAML_Session::getInstance(true);
 	
 	$logger = new SimpleSAML_Logger();
diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php
index a53d59b4f..09ebe1a8f 100644
--- a/www/saml2/idp/SSOService.php
+++ b/www/saml2/idp/SSOService.php
@@ -7,7 +7,7 @@ require_once('../../../www/_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/Logger.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/AttributeFilter.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 require_once('SimpleSAML/XML/SAML20/AuthnResponse.php');
@@ -17,7 +17,7 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $session = SimpleSAML_Session::getInstance(true);
 
 $logger = new SimpleSAML_Logger();
diff --git a/www/saml2/idp/SingleLogoutService.php b/www/saml2/idp/SingleLogoutService.php
index 0f4715fdf..3b12d9963 100644
--- a/www/saml2/idp/SingleLogoutService.php
+++ b/www/saml2/idp/SingleLogoutService.php
@@ -6,7 +6,7 @@ require_once('../../../www/_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/LogoutRequest.php');
 require_once('SimpleSAML/XML/SAML20/LogoutResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
@@ -15,7 +15,7 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 $idpentityid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
 
diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index 2ddc42b52..ce80d28e0 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -4,12 +4,12 @@ require_once('../../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $session = SimpleSAML_Session::getInstance();
 
 try {
diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php
index 2111f2941..3b327e4bc 100644
--- a/www/saml2/sp/AssertionConsumerService.php
+++ b/www/saml2/sp/AssertionConsumerService.php
@@ -6,7 +6,7 @@ require_once('../../_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/Logger.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php');
 require_once('SimpleSAML/XHTML/Template.php');
@@ -25,7 +25,7 @@ $logger->log(LOG_INFO, $session->getTrackID(), 'SAML2.0', 'SP.AssertionConsumerS
 try {
 	
 	$config = SimpleSAML_Configuration::getInstance();	
-	$metadata = new SimpleSAML_XML_MetaDataStore($config);
+	$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 	$binding = new SimpleSAML_Bindings_SAML20_HTTPPost($config, $metadata);
 	$authnResponse = $binding->decodeResponse($_POST);
diff --git a/www/saml2/sp/SingleLogoutService.php b/www/saml2/sp/SingleLogoutService.php
index 0403eaca6..671733d42 100644
--- a/www/saml2/sp/SingleLogoutService.php
+++ b/www/saml2/sp/SingleLogoutService.php
@@ -6,13 +6,13 @@ require_once('../../_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/Logger.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/LogoutRequest.php');
 require_once('SimpleSAML/XML/SAML20/LogoutResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 // Get the local session
 $session = SimpleSAML_Session::getInstance();
diff --git a/www/saml2/sp/idpdisco.php b/www/saml2/sp/idpdisco.php
index a87327066..81e108c9a 100644
--- a/www/saml2/sp/idpdisco.php
+++ b/www/saml2/sp/idpdisco.php
@@ -6,14 +6,14 @@ require_once('../../_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/XHTML/Template.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 //require_once('SimpleSAML/XML/SAML20/AuthnResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
 //require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 
 $session = SimpleSAML_Session::getInstance();
diff --git a/www/saml2/sp/initSLO.php b/www/saml2/sp/initSLO.php
index 4971e55ab..abb24721f 100644
--- a/www/saml2/sp/initSLO.php
+++ b/www/saml2/sp/initSLO.php
@@ -5,7 +5,7 @@ require_once('../../_include.php');
 require_once('SimpleSAML/Logger.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/LogoutRequest.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
 //require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php');
@@ -13,7 +13,7 @@ require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 $session = SimpleSAML_Session::getInstance();
 
diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php
index 20ec003ad..60d2060ac 100644
--- a/www/saml2/sp/initSSO.php
+++ b/www/saml2/sp/initSSO.php
@@ -7,14 +7,14 @@ require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/Logger.php');
 require_once('SimpleSAML/XHTML/Template.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/SAML20/AuthnRequest.php');
 //require_once('SimpleSAML/XML/SAML20/AuthnResponse.php');
 require_once('SimpleSAML/Bindings/SAML20/HTTPRedirect.php');
 //require_once('SimpleSAML/Bindings/SAML20/HTTPPost.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $session = SimpleSAML_Session::getInstance(true);
 
 $logger = new SimpleSAML_Logger();
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index 037dbf5f9..e432bbf78 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -4,12 +4,12 @@ require_once('../../_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $session = SimpleSAML_Session::getInstance();
 
 try {
diff --git a/www/shib13/idp/SSOService.php b/www/shib13/idp/SSOService.php
index b032a88e5..7b622eda3 100644
--- a/www/shib13/idp/SSOService.php
+++ b/www/shib13/idp/SSOService.php
@@ -6,7 +6,7 @@ require_once('../../../www/_include.php');
 
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
-require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/Metadata/MetaDataStorageHandler.php');
 require_once('SimpleSAML/XML/AttributeFilter.php');
 require_once('SimpleSAML/XML/Shib13/AuthnRequest.php');
 require_once('SimpleSAML/XML/Shib13/AuthnResponse.php');
@@ -16,7 +16,7 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$metadata = new SimpleSAML_XML_MetaDataStore($config);
+$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 $idpentityid = $metadata->getMetaDataCurrentEntityID('shib13-idp-hosted');
 $idpmeta = $metadata->getMetaDataCurrent('shib13-idp-hosted');
-- 
GitLab