From f93eb031795e0f44a0ffe2de8a931a39e95be287 Mon Sep 17 00:00:00 2001
From: m0ark <33390109+m0ark@users.noreply.github.com>
Date: Mon, 9 Apr 2018 18:02:47 +0200
Subject: [PATCH] Update MetaLoader.php

Fixing loading behaviour according to the documentation
---
 modules/metarefresh/lib/MetaLoader.php | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php
index db67e9554..ed6bdca66 100644
--- a/modules/metarefresh/lib/MetaLoader.php
+++ b/modules/metarefresh/lib/MetaLoader.php
@@ -161,14 +161,24 @@ class sspmod_metarefresh_MetaLoader
 			$template = null;
 			if (array_key_exists('template', $source)) $template = $source['template'];
 
-			$this->addMetadata($source['src'], $entity->getMetadata1xSP(), 'shib13-sp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata1xIdP(), 'shib13-idp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata20SP(), 'saml20-sp-remote', $template);
-			$this->addMetadata($source['src'], $entity->getMetadata20IdP(), 'saml20-idp-remote', $template);
-			$attributeAuthorities = $entity->getAttributeAuthorities();
-			if (!empty($attributeAuthorities)) {
-				$this->addMetadata($source['src'], $attributeAuthorities[0], 'attributeauthority-remote', $template);
-			}
+			if (in_array('shib13-sp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata1xSP(), 'shib13-sp-remote', $template);
+            }
+            if (in_array('shib13-idp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata1xIdP(), 'shib13-idp-remote', $template);
+            }
+            if (in_array('saml20-sp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata20SP(), 'saml20-sp-remote', $template);
+            }
+            if (in_array('saml20-idp-remote', $this->types)) {
+                    $this->addMetadata($source['src'], $entity->getMetadata20IdP(), 'saml20-idp-remote', $template);
+            }
+            if (in_array('attributeauthority-remote', $this->types)) {
+                    $attributeAuthorities = $entity->getAttributeAuthorities();
+                    if (!empty($attributeAuthorities)) {
+                            $this->addMetadata($source['src'], $attributeAuthorities[0], 'attributeauthority-remote', $template);
+                    }
+            }
 		}
 
 		$this->saveState($source, $responseHeaders);
-- 
GitLab