From db50c8df1711e8f0326a88f446bfe7e256331203 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 9 Jul 2010 06:56:46 +0000
Subject: [PATCH] saml2/sp: Remove metadata send functionality.

Fixes issue 317.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2394 44740490-163a-0410-bde0-09ae8108e29a
---
 dictionaries/admin.definition.json       | 18 -----
 metadata-templates/saml20-idp-remote.php |  5 --
 modules/saml/www/sp/metadata.php         |  8 ---
 templates/metadata.php                   | 77 --------------------
 www/saml2/sp/metadata.php                | 90 ------------------------
 www/shib13/sp/metadata.php               |  1 -
 6 files changed, 199 deletions(-)

diff --git a/dictionaries/admin.definition.json b/dictionaries/admin.definition.json
index 7627b6ee0..5c75f855b 100644
--- a/dictionaries/admin.definition.json
+++ b/dictionaries/admin.definition.json
@@ -133,23 +133,5 @@
 	},
 	"metaconv_xmlmetadata": {
 		"en": "XML metadata"
-	},
-	"metadata_send_title2": {
-		"en": "Send Metadata to your IdP"
-	},
-	"metadata_send_select": {
-		"en": "Select an Identity Provider to send metadata to :"
-	},
-	"metadata_send_email2": {
-		"en": "Enter your e-mail address, such that the Identity Provider administrator may get in contact with you:"
-	},
-	"metadata_send_sendbutton": {
-		"en": "Send metadata"
-	},
-	"metadata_send_adminlogin": {
-		"en": "Login as administrator to send metadata to an Identity Provider"
-	},
-	"metadata_send_success": {
-		"en": "Successfully sent metadata to Identity Provider."
 	}
 }
diff --git a/metadata-templates/saml20-idp-remote.php b/metadata-templates/saml20-idp-remote.php
index 9fdd451f2..5c2299cf2 100644
--- a/metadata-templates/saml20-idp-remote.php
+++ b/metadata-templates/saml20-idp-remote.php
@@ -32,7 +32,6 @@ $metadata['https://idp-test.feide.no'] = array(
 		'no' => 'Feide testmiljø',
 	),
 	'description'                  => 'Feide test environment (idp-test.feide.no). Authenticate with your identity from a school or university in Norway.',
-	'send_metadata_email'          => 'moria-support@uninett.no',
 
 	'SingleSignOnService'          => 'https://idp-test.feide.no/simplesaml/saml2/idp/SSOService.php',
 	'SingleLogoutService'          => 'https://idp-test.feide.no/simplesaml/saml2/idp/SingleLogoutServiceiFrame.php',
@@ -48,7 +47,6 @@ $metadata['https://idp.feide.no'] = array(
 		'en' => 'Authenticate with your identity from a school or university in Norway.',
 		'no' => 'Logg inn med din identitet fra skolen eller universitetet du er tilknyttet (i Norge).',
 	),
-	'send_metadata_email'          => 'moria-support@uninett.no',
 	'SingleSignOnService'          => 'https://idp.feide.no/simplesaml/saml2/idp/SSOService.php',
 	'SingleLogoutService'          => 'https://idp.feide.no/simplesaml/saml2/idp/SingleLogoutServiceiFrame.php',
 	'SingleLogoutServiceResponse'  => 'https://idp.feide.no/simplesaml/saml2/idp/SingleLogoutServiceiFrameResponse.php',
@@ -67,7 +65,6 @@ $metadata['https://wayf.wayf.dk'] = array(
 		'da' => 'DK-WAYF Produktionsmiljøet',
 	),
 	'description'          => 'Login with your identity from a danish school, university or library.',
-	'send_metadata_email'  => 'sekretariat@wayf.dk',
 	'SingleSignOnService'  => 'https://wayf.wayf.dk/saml2/idp/SSOService.php',
 	'SingleLogoutService'  => 'https://wayf.wayf.dk/saml2/idp/SingleLogoutService.php',
 	'certFingerprint'      => 'c215d7bf9d51c7805055239f66b957d9a72ff44b'
@@ -79,7 +76,6 @@ $metadata['https://betawayf.wayf.dk'] = array(
 		'da' => 'DK-WAYF Quality Assurance miljøet',
 	),
 	'description'          => 'Login with your identity from a danish school, university or library.',
-	'send_metadata_email'  => 'sekretariat@wayf.dk',
 	'SingleSignOnService'  => 'https://betawayf.wayf.dk/saml2/idp/SSOService.php',
 	'SingleLogoutService'  => 'https://betawayf.wayf.dk/saml2/idp/SingleLogoutService.php',
 	'certFingerprint'      => 'c215d7bf9d51c7805055239f66b957d9a72ff44b'
@@ -91,7 +87,6 @@ $metadata['https://testidp.wayf.dk'] = array(
 		'da' => 'DK-WAYF Test Miljøet',
 	),
 	'description'          => 'Login with your identity from a danish school, university or library.',
-	'send_metadata_email'  => 'sekretariat@wayf.dk',
 	'SingleSignOnService'  => 'https://testidp.wayf.dk/saml2/idp/SSOService.php',
 	'SingleLogoutService'  => 'https://testidp.wayf.dk/saml2/idp/SingleLogoutService.php',
 	'certFingerprint'      => '04b3b08bce004c27458b3e85b125273e67ef062b'
diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index 830ebf02b..361037c1f 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -158,14 +158,6 @@ if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') {
 	$t->data['metadata'] = htmlspecialchars($xml);
 	$t->data['metadataflat'] = '$metadata[' . var_export($entityId, TRUE) . '] = ' . var_export($metaArray20, TRUE) . ';';
 	$t->data['metaurl'] = $source->getMetadataURL();
-
-	$t->data['idpsend'] = array();
-	$t->data['sentok'] = FALSE;
-	$t->data['adminok'] = FALSE;
-	$t->data['adminlogin'] = NULL;
-
-	$t->data['techemail'] = $config->getString('technicalcontact_email', NULL);
-
 	$t->show();
 } else {
 	header('Content-Type: application/samlmetadata+xml');
diff --git a/templates/metadata.php b/templates/metadata.php
index 3e39b36de..855cb04df 100644
--- a/templates/metadata.php
+++ b/templates/metadata.php
@@ -6,83 +6,6 @@ $this->includeAtTemplateBase('includes/header.php');
 
 		<h2><?php echo $this->data['header']; ?></h2>
 		
-		<?php 
-		
-		if(array_key_exists('idpsend', $this->data) && is_array($this->data['idpsend']) && count($this->data['idpsend']) > 0 ) {
-
-			if ($this->data['adminok']) {
-
-		?>
-			<div style="border: 1px solid #444; margin: .5em 2em .5em 2em; padding: .5em 1em 1em 1em; background: #FFFFCC">
-
-				
-
-
-				<h2 style="margin-top: 0px" ><?php echo $this->t('metadata_send_title2'); ?></h2>
-				
-				<?php
-
-				if ($this->data['sentok'] === TRUE) {
-				
-					echo '<p><strong>' . $this->t('metadata_send_success') . '</strong></p>';
-				
-				}
-				
-				?>
-				
-
-				<form action="metadata.php" method="post">
-
-					<p><?php echo $this->t('metadata_send_select'); ?>					
-					<select name="sendtoidp">
-					<?php
-						foreach ($this->data['idpsend'] AS $entityid => $idpmeta) {
-							$name = array_key_exists('name', $idpmeta) ? $idpmeta['name'] :
-								array_key_exists('OrganizationDisplayName', $idpmeta) ? $idpmeta['OrganizationDisplayName'] :
-								$entityid;
-							echo '<option value="' . htmlspecialchars($entityid) . '">';
-							if (is_array($name)) {
-								echo htmlspecialchars($this->t($name));
-							} else {
-								echo htmlspecialchars($name);
-							}
-							echo '</option>';
-						}
-					?>
-					</select> </p>
-
-					<p><?php echo $this->t('metadata_send_email2'); ?><br />
-						
-						<input type="text" size="25" name="email" value="<?php echo ($this->data['techemail']) ? $this->data['techemail'] : ''  ?>" />
-					</p>
-					<input type="hidden" name="output" value="xhtml" />
-					<input type="submit" name="send" value="<?php echo $this->t('metadata_send_sendbutton'); ?>" />
-					
-				</form>
-
-
-			</div>
-		
-		<?php 
-		
-			} else {
-				
-				echo '<div style="border: 1px solid #444; margin: .5em 2em .5em 2em; padding: .5em 1em 1em 1em; background: #FFFFCC">';
-				echo '	<a href="' . htmlspecialchars($this->data['adminlogin']) . '">';
-				echo $this->t('metadata_send_adminlogin');
-				echo '	</a>';
-				echo '</div>';
-				
-				
-			}
-
-		
-		} 
-		?>
-		
-		
-		
-		
 		<p><?php echo $this->t('metadata_intro'); ?></p>
 		
 		<?php if (isset($this->data['metaurl'])) { ?>
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index 5e065f04a..63fb36614 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -73,103 +73,13 @@ try {
 
 	/* Sign the metadata if enabled. */
 	$metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $spmeta->toArray(), 'SAML 2 SP');
-	
-	
-	
-	
-	/*
-	 * Generate list of IdPs that you can send metadata to.
-	 */
-	$idplist = $metadata->getList('saml20-idp-remote');
-	$idpsend = array();
-	foreach ($idplist AS $entityid => $mentry) {
-		if (array_key_exists('send_metadata_email', $mentry)) {
-			$idpsend[$entityid] = $mentry;
-		}
-	}
-	
-	
-	$adminok = SimpleSAML_Utilities::isAdmin();
-	$adminlogin = SimpleSAML_Utilities::getAdminLoginURL(
-		SimpleSAML_Utilities::addURLParameter(
-			SimpleSAML_Utilities::selfURLNoQuery(),
-			array('output' => 'xhtml')
-		));
-	
-
-	$sentok = FALSE;
-	/*
-	 * Send metadata to Identity Provider, if the user filled submitted the form
-	 */
-	if (array_key_exists('sendtoidp', $_POST)) {
-		
-		
-		if (!array_key_exists($_POST['sendtoidp'], $idpsend))
-			throw new Exception('Entity ID ' . $_POST['sendtoidp'] . ' not found in metadata. Cannot send metadata to this IdP.');
-		
-		$emailadr = $idpsend[$_POST['sendtoidp']]['send_metadata_email'];
-		$from = $_POST['email'];
-		
-		$message = '<h1>simpleSAMLphp SAML 2.0 Service Provider Metadata</h1>
-
-<p>Metadata was sent to you from a simpleSAMLphp SAML 2.0 Service Provider. The service provider requests to connect to the following Identity Provider: 
-	<ul>
-		<li><tt>' . htmlspecialchars($_POST['sendtoidp']) . '</tt></li>
-	</ul>
-</p>
-
-<p>SAML 2.0 Service Provider EntityID :</p>
-<pre>' . htmlspecialchars($spentityid) . '</pre>
-
-<p>Links to metadata at service provider
-<ul>
-	<li><a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xhtml'))) . '">SimpleSAMLphp Metadata page</a></li>
-	<li><a href="' . htmlspecialchars(SimpleSAML_Utilities::selfURLNoQuery()) . '">SimpleSAMLphp Metadata (XML only)</a></li>
-</ul>
-</p>
-
-<p>SAML 2.0 XML Metadata :</p>
-<pre>' . htmlspecialchars($metaxml) . '</pre>
-
-<p>Metadata in SimpleSAMLphp format :</p>
-<pre>' . htmlspecialchars($metaflat) . '</pre>
-
-<p>SimpleSAMLphp version: ' . $config->getVersion() . '</p>
-
-';
-		
-		$email = new SimpleSAML_XHTML_EMail($emailadr, 'simpleSAMLphp SAML 2.0 Service Provider Metadata', $from);
-		$email->setBody($message);
-		$email->send();
-		$sentok = TRUE;
-		
-		SimpleSAML_Logger::info('SAML2.0 - Metadata: Metadata was successfully sent to ' . $emailadr . ' from ' . $from);
-	}
-	
-	
-	
-	
-	
-	
-	
-	
-	
 
 	if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') {
 		$t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin');
-	
 		$t->data['header'] = 'saml20-sp';
 		$t->data['metadata'] = htmlspecialchars($metaxml);
 		$t->data['metadataflat'] = htmlspecialchars($metaflat);
 		$t->data['metaurl'] = SimpleSAML_Utilities::selfURLNoQuery();
-		
-		$t->data['idpsend'] = $idpsend;
-		$t->data['sentok'] = $sentok;
-		$t->data['adminok'] = $adminok;
-		$t->data['adminlogin'] = $adminlogin;
-		
-		$t->data['techemail'] = $config->getString('technicalcontact_email', NULL);
-		
 		$t->show();
 		
 	} else {
diff --git a/www/shib13/sp/metadata.php b/www/shib13/sp/metadata.php
index 18fec83a9..ab0e93d4d 100644
--- a/www/shib13/sp/metadata.php
+++ b/www/shib13/sp/metadata.php
@@ -82,7 +82,6 @@ try {
 		$t->data['metadata'] = htmlspecialchars($metaxml);
 		$t->data['metadataflat'] = htmlspecialchars($metaflat);
 		$t->data['metaurl'] = SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xml'));
-		$t->data['techemail'] = $config->getString('technicalcontact_email', 'na');
 		$t->show();
 		
 	} else {	
-- 
GitLab