From b5757a059a16c148be8a8561e0099a3cabe917da Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 5 Aug 2015 11:12:05 +0200
Subject: [PATCH] Parse the "Hide From Discovery" REFEDS Entity Category in
 SAML metadata as the new 'hide.from.discovery' configuration option for
 remote IdP metadata.

---
 lib/SimpleSAML/Metadata/SAMLParser.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php
index ffeca749f..5cbd5632a 100644
--- a/lib/SimpleSAML/Metadata/SAMLParser.php
+++ b/lib/SimpleSAML/Metadata/SAMLParser.php
@@ -488,6 +488,15 @@ class SimpleSAML_Metadata_SAMLParser
 
         if (!empty($this->entityAttributes)) {
             $metadata['EntityAttributes'] = $this->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, $metadata['EntityAttributes'])) {
+                if (in_array($hide_from_discovery, $metadata['EntityAttributes'][$entity_category])) {
+                    $metadata['hide.from.discovery'] = true;
+                }
+            }
         }
 
         if (!empty($roleDescriptor['UIInfo'])) {
-- 
GitLab