From bbfb2e9e30b1d5f21c82a8fd7342605ea87d455d Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 15 Sep 2008 09:45:49 +0000
Subject: [PATCH] Dynamic metadata - remove fallback for entity selection when
 no entity with correct entity id is found in downloaded metadata.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@870 44740490-163a-0410-bde0-09ae8108e29a
---
 .../MetaDataStorageHandlerDynamicXML.php      | 30 ++++++-------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerDynamicXML.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerDynamicXML.php
index 7404de95f..784f734a9 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerDynamicXML.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerDynamicXML.php
@@ -239,27 +239,15 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerDynamicXML extends SimpleSAML_Me
 			throw new Exception('No entities found in "' . $index . '".');
 		}
 
-		if (array_key_exists($index, $entities)) {
-			$entity = $entities[$index];
-			$data = self::getParsedSet($entity, $set);
-			if ($data === NULL) {
-				throw new Exception('No metadata for set "' . $set .
-					'" available from "' . $index . '".');
-			}
-		} else {
-			SimpleSAML_Logger::warning('MetaData - Handler.DynamicXML: No entity with correct' .
-				' entity id found. Using the first entity which defines the correct' .
-				' metadata.');
-			foreach ($entities as $entity) {
-				$data = self::getParsedSet($entity, $set);
-				if ($data !== NULL) {
-					break;
-				}
-			}
-			if ($data === NULL) {
-				throw new Exception('No entities defines metadata for set "' .
-					$set . '" in "' . $index . '".');
-			}
+		if (!array_key_exists($index, $entities)) {
+			throw new Exception ('No entity with correct entity id found in "' . $index . '".');
+		}
+
+		$entity = $entities[$index];
+		$data = self::getParsedSet($entity, $set);
+		if ($data === NULL) {
+			throw new Exception('No metadata for set "' . $set .
+				'" available from "' . $index . '".');
 		}
 
 		$this->writeToCache($set, $index, $data);
-- 
GitLab