From 2b4e4ef1fa914325480d6b4482de8a5f3e129e66 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 3 Sep 2009 10:38:02 +0000
Subject: [PATCH] saml: Add metadata to frontpage.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1745 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml/hooks/hook_metadata_hosted.php | 33 +++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 modules/saml/hooks/hook_metadata_hosted.php

diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php
new file mode 100644
index 000000000..f22f265cc
--- /dev/null
+++ b/modules/saml/hooks/hook_metadata_hosted.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Hook to add the metadata for hosted entities to the frontpage.
+ *
+ * @param array &$metadataHosted  The metadata links for hosted metadata on the frontpage.
+ */
+function saml_hook_metadata_hosted(&$metadataHosted) {
+	assert('is_array($metadataHosted)');
+
+	$sources = SimpleSAML_Auth_Source::getSourcesOfType('saml:SP');
+
+	foreach ($sources as $source) {
+
+		$metadata = $source->getMetadata();
+
+		$name = $metadata->getValue('name', NULL);
+		if ($name === NULL) {
+			$name = $source->getAuthID();
+		}
+
+		$md = array(
+			'entityid' => $source->getEntityId(),
+			'metadata-index' => $source->getEntityId(),
+			'metadata-set' => 'saml20-sp-hosted',
+			'metadata-url' => $source->getMetadataURL() . '?output=xhtml',
+			'name' => $name,
+		);
+
+		$metadataHosted[] = $md;
+	}
+
+}
-- 
GitLab