From 5e1a722a6ff99a5c8829f2af5fe4e9432d2e4be1 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 5 Aug 2015 11:00:25 +0200
Subject: [PATCH] Export the new 'hide.from.discovery' option in the PHP
 metadata array when the "Hide From Discovery" REFEDS Entity Category is
 defined in the hosted IdP metadata.

---
 www/saml2/idp/metadata.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index 631865a9f..f5b897657 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -136,6 +136,15 @@ try {
 
 	if ($idpmeta->hasValue('EntityAttributes')) {
 		$metaArray['EntityAttributes'] = $idpmeta->getArray('EntityAttributes');
+
+		// check for entity categories
+		$entity_category = 'http://macedir.org/entity-category';
+		$hide_from_discovery = 'http://refeds.org/category/hide-from-discovery';
+		if (array_key_exists($entity_category, $metaArray['EntityAttributes'])) {
+			if (in_array($hide_from_discovery, $metaArray['EntityAttributes'][$entity_category])) {
+				$metaArray['hide.from.discovery'] = true;
+			}
+		}
 	}
 
 	if ($idpmeta->hasValue('UIInfo')) {
-- 
GitLab