Skip to content
Snippets Groups Projects
Commit ac161241 authored by Jaime Perez's avatar Jaime Perez
Browse files

aggregator2: allow the user to specify the MIME type of the response.

parent e0fc54a7
No related branches found
No related tags found
No related merge requests found
<?php <?php
if (!isset($_REQUEST['id'])) { if (!isset($_REQUEST['id'])) {
throw new SimpleSAML_Error_BadRequest('Missing required id-parameter.'); throw new SimpleSAML_Error_BadRequest('Missing required parameter "id".');
} }
$id = (string)$_REQUEST['id']; $id = (string) $_REQUEST['id'];
$aggregator = sspmod_aggregator2_Aggregator::getAggregator($id); $aggregator = sspmod_aggregator2_Aggregator::getAggregator($id);
$xml = $aggregator->getMetadata(); $xml = $aggregator->getMetadata();
header('Content-Type: application/samlmetadata+xml'); $mimetype = 'application/samlmetadata+xml';
$allowedmimetypes = array(
'text/plain',
'application/samlmetadata-xml',
'application/xml',
);
if (isset($_GET['mimetype']) && in_array($_GET['mimetype'], $allowedmimetypes)) {
$mimetype = $_GET['mimetype'];
}
if ($mimetype === 'text/plain') {
$xml = SimpleSAML_Utilities::formatXMLString($xml);
}
header('Content-Type: '.$mimetype);
header('Content-Length: ' . strlen($xml)); header('Content-Length: ' . strlen($xml));
/* /*
...@@ -17,4 +32,4 @@ header('Content-Length: ' . strlen($xml)); ...@@ -17,4 +32,4 @@ header('Content-Length: ' . strlen($xml));
*/ */
header('Content-Disposition: filename='.$id.'.xml'); header('Content-Disposition: filename='.$id.'.xml');
echo($xml); echo $xml;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment