From adf4857298c22bec32dd352466f95524a82552f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Thu, 31 Jan 2008 15:29:10 +0000
Subject: [PATCH] Updating sending metadata part to be more flexible and allow
 sending metadata to dkaai and others

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@233 44740490-163a-0410-bde0-09ae8108e29a
---
 config/config-template.php        | 48 +++++++++++++++++++------------
 extra/receiveinfo.php             | 16 +++++++++--
 templates/default/en/metadata.php | 15 +++++-----
 www/saml2/sp/metadata.php         |  4 ++-
 4 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/config/config-template.php b/config/config-template.php
index 5de071cf1..bf0397da7 100644
--- a/config/config-template.php
+++ b/config/config-template.php
@@ -7,7 +7,7 @@
 
 $config = array (
 
-	/*
+	/**
 	 * This option configures the base directory for this simpleSAMLphp
 	 * installation. Under most circumstances this option is optional,
 	 * and can be left unset.
@@ -17,24 +17,42 @@ $config = array (
 	 */
 	'basedir' => NULL,
 
-
-	/*
+	/**
 	 * Setup the following parameters to match the directory of your installation.
 	 * See the user manual for more details.
 	 */
-	'baseurlpath'			=> 'simplesaml/',
-	'templatedir'			=> 'templates/default/',
-	'metadatadir'			=> 'metadata/',
-	'attributenamemapdir'	=> 'attributemap/',
+	'baseurlpath'           => 'simplesaml/',
+	'templatedir'           => 'templates/default/',
+	'metadatadir'           => 'metadata/',
+	'attributenamemapdir'   => 'attributemap/',
+	'certdir'               => 'certs/',
+	'dictionarydir'         => 'dictionaries/',
 	
-	/*
+	
+	'version'				=>	'0.9.1',
+	
+	/**
 	 * If you set the debug parameter to true, all SAML messages will be visible in the
 	 * browser, and require the user to click the submit button. If debug is set to false,
 	 * Browser/POST SAML messages will be automaticly submitted.
 	 */
-	'debug'					=>	false,
+	'debug'                 =>	false,
+	'showerrors'            =>	true,
+	'errorreportaddress'    =>  'http://rnd.feide.no/content/sending-information-simplesamlphp',
 	
-	'version'				=>	'0.9',
+	/**
+	 * This password must be kept secret, and modified from the default value 123.
+	 * This password will give access to the installation page of simpleSAMLphp with
+	 * metadata listing and diagnostics pages.
+	 */
+	'auth.adminpassword'		=> '123',
+	'admin.protectindexpage'	=> false,
+	
+	/*
+	 * Some information about the technical persons running this installation.
+	 */
+	'technicalcontact_name'     => 'Administrator',
+	'technicalcontact_email'    => 'na@example.org',
 	
 	/*
 	 * Logging.
@@ -50,15 +68,7 @@ $config = array (
 	'logging.facility'		=> LOG_LOCAL5,
 	'logging.level'			=> LOG_NOTICE,
 	
-	
-	/**
-	 * This password must be kept secret, and modified from the default value 123.
-	 * This password will give access to the installation page of simpleSAMLphp with
-	 * metadata listing and diagnostics pages.
-	 */
-	'auth.adminpassword'		=> '123',
-	'admin.protectindexpage'	=> false,
-	
+
 	/*
 	 * Enable
 	 * 
diff --git a/extra/receiveinfo.php b/extra/receiveinfo.php
index 9a881a167..4bddc2481 100644
--- a/extra/receiveinfo.php
+++ b/extra/receiveinfo.php
@@ -1,3 +1,4 @@
+<?php
 /**
  * Copy and paste this file into a page in your drupal installation, or similar CMS system.
  * Make sure the Input mode in your new page is PHP Mode.
@@ -6,7 +7,7 @@
  * config.php of your simpleSAMLphp installation.
  * 
  */
-
+?>
 <p>Thanks for sending information to us from simpleSAMLphp.</p>
 
 
@@ -27,8 +28,17 @@ if (isset($_POST['action'])) {
 
 		echo '<p>We have received your metadata.';	
 		$subject = 'SAML 2.0 Metadata from '. $_POST['email'];
-		$message = 'Someone just used simpleSAMLphp to send metadata to Feide. Here is the metadata: ' . "\r\n\r\n------- BEGIN SAML 2.0 METADATA ----------\r\n" . 
-			html_entity_decode(base64_decode(urldecode($_POST['metadata']))) . "\r\n------- END SAML 2.0 METADATA ----------\r\n\r\nDefault IdP: " . $_POST['defaultidp'] . "\r\nSent by simpleSAMLphp :)";
+		$message = 'Someone just used simpleSAMLphp to send metadata to Feide. Here is the metadata: 
+------- BEGIN SAML 2.0 METADATA ----------
+' . html_entity_decode(base64_decode(urldecode($_POST['metadata']))) . '
+------- END SAML 2.0 METADATA ----------
+
+
+Default IdP: ' . $_POST['defaultidp'] . '
+simpleSAMLphp version: ' . $_POST['version'] . '
+Technical contact at server: ' . $_POST['techemail'] . ' 
+
+Sent using simpleSAMLphp';
 	
 } elseif($_POST['action'] == 'error') {
 	
diff --git a/templates/default/en/metadata.php b/templates/default/en/metadata.php
index cfecf0803..d20aeeb1f 100644
--- a/templates/default/en/metadata.php
+++ b/templates/default/en/metadata.php
@@ -15,12 +15,12 @@
 		<pre style="overflow: scroll; border: 1px solid #eee; padding: 2px"><?php echo $data['metadata']; ?></pre>
 
 		
-		<?php if(array_key_exists('sendmetadatato', $this->data) { ?>
-		
+		<?php if(array_key_exists('sendmetadatato', $this->data)) { ?>
 		
+
 			<div style="border: 1px solid #444; margin: 2em; padding: 1em; background: #eee">
 			
-				<h2>Send your metadata to <?php $this->data['federationname']; ?></h2>
+				<h2>Send your metadata to <?php echo $this->data['federationname']; ?></h2>
 				
 				<p>simpleSAMLphp has detected that you have configured Feide as your default IdP.</p>
 				
@@ -28,17 +28,18 @@
 					contact Feide to add you as a new service, you will be asked to send your metadata. Here you can easily send
 					the metadata to Feide by clicking the button below.</p>
 					
-				<form action="<?php $this->data['sendmetadatato']; ?>" method="post">
+				<form action="<?php echo $this->data['sendmetadatato']; ?>" method="post">
 
 					<p>Feide needs to know how to get in contact with you, so you need to type in <strong>your email address</strong>:
 						<input type="text" size="25" name="email" value="" />
 					</p>
 					
+					<input type="hidden" name="action" value="metadata" />
 					<input type="hidden" name="metadata" value="<?php echo urlencode(base64_encode($data['metadata'])); ?>" />
-					<input type="hidden" name="techemail" value="<?php echo $_POST['techemail']; ?>" />
-					<input type="hidden" name="version" value="<?php echo $_POST['version']; ?>" />
+					<input type="hidden" name="techemail" value="<?php echo $this->data['techemail']; ?>" />
+					<input type="hidden" name="version" value="<?php echo $this->data['version']; ?>" />
 					<input type="hidden" name="defaultidp" value="<?php echo htmlspecialchars($data['defaultidp']); ?>" />
-					<input type="submit" name="send" value="Send my metadata to <?php $this->data['federationname']; ?>" />
+					<input type="submit" name="send" value="Send my metadata to <?php echo $this->data['federationname']; ?>" />
 					
 				</form>
 				
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index 09bcb30fb..8e0ed035b 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -75,7 +75,9 @@ try {
 		$et->data['sendmetadatato'] = $send_metadata_to_idp[$defaultidp]['address'];
 		$et->data['federationname'] = $send_metadata_to_idp[$defaultidp]['name'];
 	}
-	
+
+	$et->data['techemail'] = $config->getValue('technicalcontact_email', 'na');
+	$et->data['version'] = $config->getValue('version', 'na');
 	$et->data['feide'] = in_array($defaultidp, array('sam.feide.no', 'max.feide.no'));
 	$et->data['defaultidp'] = $defaultidp;
 	
-- 
GitLab