Add backwards compatibility to previous commit 722fd39.

git-svn-id: http://simplesamlphp.googlecode.com/svn/trunk@3351 44740490-163a-0410-bde0-09ae8108e29a
This commit is contained in:
jaimepc@gmail.com 2014-02-03 08:43:49 +00:00
parent 7859b86974
commit f5a9f3c081
4 changed files with 35 additions and 28 deletions

View File

@ -84,8 +84,8 @@ The endpoint supports the following query parameter:
`exclude`
: Specify a `tag` that will be excluded from the metadata set. Useful for leaving out your own federation metadata.
`format`
: Select the Mime-Type that will be used. Can be `txt` or `xml`.
`mimetype`
: Select the Mime-Type that will be used. Default is `application/samlmetadata+xml`.

View File

@ -15,8 +15,8 @@ if (count($this->data['sources']) === 0) {
$encName = htmlspecialchars($source);
echo('<li>');
echo('<a href="?id=' . $encId . '">' . $encName . '</a>');
echo(' <a href="?id=' . $encId . '&amp;format=txt">[' . $this->t('{aggregator:aggregator:text}') . ']</a>');
echo(' <a href="?id=' . $encId . '&amp;format=xml">[xml]</a>');
echo(' <a href="?id=' . $encId . '&amp;mimetype=text/plain">[' . $this->t('{aggregator:aggregator:text}') . ']</a>');
echo(' <a href="?id=' . $encId . '&amp;mimetype=application/xml">[xml]</a>');
echo('</li>');
}
@ -24,4 +24,3 @@ if (count($this->data['sources']) === 0) {
}
$this->includeAtTemplateBase('includes/footer.php');
?>

View File

@ -15,7 +15,7 @@ if (!array_key_exists('id', $_GET)) {
exit;
}
$id = $_GET['id'];
if (!in_array($id, $aggregators->getOptions()))
if (!in_array($id, $aggregators->getOptions()))
throw new SimpleSAML_Error_NotFound('No aggregator with id ' . var_export($id, TRUE) . ' found.');
$aConfig = $aggregators->getConfigItem($id);
@ -23,10 +23,10 @@ $aConfig = $aggregators->getConfigItem($id);
$aggregator = new sspmod_aggregator_Aggregator($gConfig, $aConfig, $id);
if (isset($_REQUEST['set']))
if (isset($_REQUEST['set']))
$aggregator->limitSets($_REQUEST['set']);
if (isset($_REQUEST['exclude']))
if (isset($_REQUEST['exclude']))
$aggregator->exclude($_REQUEST['exclude']);
@ -66,18 +66,21 @@ if ($aggregator->shouldSign()) {
$signer->sign($firstelement, $firstelement, $firstelement->firstChild);
}
$format = 'application/samlmetadata+xml';
$mimetype = 'application/samlmetadata-xml';
$allowedmimetypes = array(
'text/plain',
'application/samlmetadata-xml',
'application/xml',
);
/* Show the metadata. */
if(array_key_exists('format', $_GET)) {
if ($_GET['format'] === "txt") {
$format = 'text/plain';
}
if (isset($_GET['mimetype']) && in_array($_GET['mimetype'], $allowedmimetypes)) {
$mimetype = $_GET['mimetype'];
}
header('Content-Type: ' . $format);
if ($mimetype === 'text/plain') {
SimpleSAML_Utilities::formatDOMElement($xml->documentElement);
}
header('Content-Type: ' . $mimetype);
echo($xml->saveXML());
?>

View File

@ -15,7 +15,7 @@ if (!array_key_exists('id', $_GET)) {
exit;
}
$id = $_GET['id'];
if (!in_array($id, $aggregators->getOptions()))
if (!in_array($id, $aggregators->getOptions()))
throw new SimpleSAML_Error_NotFound('No aggregator with id ' . var_export($id, TRUE) . ' found.');
$aConfig = $aggregators->getConfigItem($id);
@ -23,7 +23,7 @@ $aConfig = $aggregators->getConfigItem($id);
$aggregator = new sspmod_aggregator_Aggregator($gConfig, $aConfig, $id);
if (isset($_REQUEST['set']))
if (isset($_REQUEST['set']))
$aggregator->limitSets($_REQUEST['set']);
if (isset($_REQUEST['exclude']))
@ -32,19 +32,24 @@ if (isset($_REQUEST['exclude']))
$xml = $aggregator->getMetadataDocument();
$format = 'application/samlmetadata+xml';
$mimetype = 'application/samlmetadata+xml';
$allowedmimetypes = array(
'text/plain',
'application/samlmetadata-xml',
'application/xml',
);
/* Show the metadata. */
if(array_key_exists('format', $_GET)) {
if ($_GET['format'] === "txt") {
SimpleSAML_Utilities::formatDOMElement($xml);
$format = 'text/plain';
}
if (isset($_GET['mimetype']) && in_array($_GET['mimetype'], $allowedmimetypes)) {
$mimetype = $_GET['mimetype'];
}
if ($mimetype === 'text/plain') {
SimpleSAML_Utilities::formatDOMElement($xml);
}
$metadata = '<?xml version="1.0"?>'."\n".$xml->ownerDocument->saveXML($xml);
header('Content-Type: ' . $format);
header('Content-Type: ' . $mimetype);
header('Content-Length: ' . strlen($metadata));
echo $metadata;