diff --git a/lib/SimpleSAML/Metadata/Signer.php b/lib/SimpleSAML/Metadata/Signer.php index d6964690..a0422153 100644 --- a/lib/SimpleSAML/Metadata/Signer.php +++ b/lib/SimpleSAML/Metadata/Signer.php @@ -173,7 +173,12 @@ class SimpleSAML_Metadata_Signer { $rootNode = $xml->firstChild; /* Sign the metadata with our private key. */ - $objXMLSecDSig = new XMLSecurityDSig(); + if ($type == 'ADFS IdP') { + $objXMLSecDSig = new sspmod_adfs_XMLSecurityDSig($metadataString); + } else { + $objXMLSecDSig = new XMLSecurityDSig(); + } + $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); $objXMLSecDSig->addReferenceList(array($rootNode), XMLSecurityDSig::SHA1, diff --git a/modules/adfs/lib/XMLSecurityDSig.php b/modules/adfs/lib/XMLSecurityDSig.php new file mode 100644 index 00000000..d5ab2fd2 --- /dev/null +++ b/modules/adfs/lib/XMLSecurityDSig.php @@ -0,0 +1,32 @@ +loadXML($template); + $this->sigNode = $sigdoc->documentElement; + } +} diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index fd563ba4..f1a191a4 100644 --- a/modules/adfs/www/idp/metadata.php +++ b/modules/adfs/www/idp/metadata.php @@ -117,14 +117,16 @@ try { 'name' => $config->getString('technicalcontact_name', NULL), )); } - $metaxml = explode("\n", $metaBuilder->getEntityDescriptorText()); - unset($metaxml[0]); - $metaxml = implode("\n", $metaxml); + $output_xhtml = array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml'; + $metaxml = $metaBuilder->getEntityDescriptorText($output_xhtml); + if (!$output_xhtml) { + $metaxml = str_replace("\n", '', $metaxml); + } /* Sign the metadata if enabled. */ $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'ADFS IdP'); - if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { + if ($output_xhtml) { $defaultidp = $config->getString('default-adfs-idp', NULL); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); @@ -138,19 +140,17 @@ try { $t->show(); } else { - header('Content-Type: application/xml'); + // make sure to export only the md:EntityDescriptor + $metaxml = substr($metaxml, strpos($metaxml, '') + $metaxml = substr($metaxml, 0, strrpos($metaxml, '') + 22); echo $metaxml; - exit(0); + exit(0); } - - } catch(Exception $exception) { - throw new SimpleSAML_Error_Error('METADATA', $exception); - } -