From 1f18c0593e82c109a8bd7bc1f34594c9a68238e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Tue, 13 Jan 2009 12:46:06 +0000 Subject: [PATCH] Improvements to metadata handling to get current hosted metadata automatically using __default__ host and dynamic entityid. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1144 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Metadata/MetaDataStorageSource.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index 2ec89c801..07ea1ba7a 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -172,8 +172,19 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource { $metadataSet = $this->getMetadataSet($set); - foreach($metadataSet AS $index => $entry) - if ($entry['entityid'] === $entityId) return $index; + /* Check for hostname. */ + $currenthost = SimpleSAML_Utilities::getSelfHost(); // sp.example.org + if(strpos($currenthost, ":") !== FALSE) { + $currenthostdecomposed = explode(":", $currenthost); + $currenthost = $currenthostdecomposed[0]; + } + + foreach($metadataSet AS $index => $entry) { + if ($index === $entityId) return $index; + if ($entry['entityid'] === $entityId) { + if ($entry['host'] === '__DEFAULT__' || $entry['host'] === $currenthost) return $index; + } + } return NULL; } -- GitLab