From c61e6080137bc1de8f3f1a4749b6f0b9be29ea3e Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 20 Jun 2008 12:17:35 +0000
Subject: [PATCH] Extended MetaShare publish to support SAML 2.0 SP & Shib 1.3
 IdP/SP metadata.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@683 44740490-163a-0410-bde0-09ae8108e29a
---
 dictionaries/frontpage.php | 11 ++++++++++-
 www/index.php              | 25 ++++++++++++++++++-------
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/dictionaries/frontpage.php b/dictionaries/frontpage.php
index 801754386..ee71acc05 100644
--- a/dictionaries/frontpage.php
+++ b/dictionaries/frontpage.php
@@ -536,9 +536,18 @@ $lang = array(
 		'hr' => 'OdrĹľavanje i konfiguriranje simpleSAMLphp-a',
 		'hu' => 'SimpleSAMLphp karbantartása és beállítása',
 	),
-	'link_publish' => array (
+	'link_publish_saml20-idp' => array (
 		'en' => 'Publish my SAML 2.0 IdP metadata to the configured MetaShare',
 	),
+	'link_publish_saml20-sp' => array (
+		'en' => 'Publish my SAML 2.0 SP metadata to the configured MetaShare',
+	),
+	'link_publish_shib13-idp' => array (
+		'en' => 'Publish my Shib 1.3 IdP metadata to the configured MetaShare',
+	),
+	'link_publish_shib13-sp' => array (
+		'en' => 'Publish my Shib 1.3 SP metadata to the configured MetaShare',
+	),
 
 );
 
diff --git a/www/index.php b/www/index.php
index eb68e4269..e32ff3c2e 100644
--- a/www/index.php
+++ b/www/index.php
@@ -60,14 +60,25 @@ if($config->getBoolean('idpdisco.enableremember', FALSE)) {
 		);
 }
 
-if ($config->getValue('enable.saml20-idp') === TRUE) {
-	$publishURL = $config->getString('metashare.publishurl', NULL);
-	if ($publishURL !== NULL) {
-		$metadataURL = SimpleSAML_Utilities::resolveURL('saml2/idp/metadata.php');
-		$publishURL = SimpleSAML_Utilities::addURLparameter($publishURL, 'url=' . urlencode($metadataURL));
+
+$publishURL = $config->getString('metashare.publishurl', NULL);
+if ($publishURL !== NULL) {
+	$metadataSources = array(
+		'saml20-idp' => 'saml2/idp/metadata.php',
+		'saml20-sp' => 'saml2/sp/metadata.php',
+		'shib13-idp' => 'shib13/idp/metadata.php',
+		'shib13-sp' => 'shib13/sp/metadata.php',
+		);
+	foreach($metadataSources as $name => $url) {
+		if(!$config->getBoolean('enable.' . $name, FALSE)) {
+			continue;
+		}
+
+		$url = SimpleSAML_Utilities::resolveURL($url);
+		$linkTarget = SimpleSAML_Utilities::addURLparameter($publishURL, 'url=' . urlencode($url));
 		$links[] = array(
-			'href' => $publishURL,
-			'text' => 'link_publish',
+			'href' => $linkTarget,
+			'text' => 'link_publish_' . $name,
 			);
 	}
 }
-- 
GitLab