$session->setData('string', 'refURL', SimpleSAML_Utilities::selfURL()); SimpleSAML_Utilities::redirectTrustedUrl(SimpleSAML_Module::getModuleURL('janus/index.php')); } if (isset($_GET['eid'])) { $eid = $_GET['eid']; } else { throw new SimpleSAML_Error_Exception('Eid must be set'); } if (isset($_GET['revisionid'])) { $revisionid = $_GET['revisionid']; } else { throw new SimpleSAML_Error_Exception('Revisionid must be set'); } $md_options = $janus_config->getValue('mdexport.default_options'); $metaxml = sspmod_janus_MetaExport::getReadableXMLMetadata($eid, $revisionid, array('maxCache' => $md_options['maxCache'], 'maxDuration' => $md_options['maxDuration'])); $metaflat = sspmod_janus_MetaExport::getFlatMetadata($eid, $revisionid); $metaarray = sspmod_janus_MetaExport::getPHPArrayMetadata($eid, $revisionid); // Error generating som of the metadata if (empty($metaflat) || empty($metaxml)) { $t = new SimpleSAML_XHTML_Template($config, 'janus:error.php', 'janus:error'); $t->data['header'] = 'JANUS'; $t->data['title'] = 'error_required_metadata_missing_header'; $t->data['error'] = 'error_required_metadata_missing'; $t->data['extra_data'] = '<ul><li>' . implode("</li>\n<li>", sspmod_janus_MetaExport::getError()) . '</li></ul>'; $t->show(); exit(0); } elseif (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { $t = new SimpleSAML_XHTML_Template($config, 'janus:metadata.php', 'janus:metadata'); $t->data['header'] = 'Metadata export'; $t->data['metaurl'] = SimpleSAML_Utilities::selfURLNoQuery(); $t->data['metadata'] = htmlentities($metaxml);
$maxDuration = $janus_config->getValue('maxDuration', NULL); $entities = $util->getEntitiesByStateType($export_state, $export_type); $xml = new DOMDocument(); $entitiesDescriptor = $xml->createElementNS('urn:oasis:names:tc:SAML:2.0:metadata', 'md:EntitiesDescriptor'); $entitiesDescriptorName = $janus_config->getString('export.entitiesDescriptorName', 'Federation'); $entitiesDescriptor->setAttribute('Name', $entitiesDescriptorName); if ($maxCache !== NULL) { $entitiesDescriptor->setAttribute('cacheDuration', 'PT' . $maxCache . 'S'); } if ($maxDuration !== NULL) { $entitiesDescriptor->setAttribute('validUntil', SimpleSAML_Utilities::generateTimestamp(time() + $maxDuration)); } $xml->appendChild($entitiesDescriptor); foreach ($entities as $entity) { $entityDescriptor = sspmod_janus_MetaExport::getXMLMetadata($entity['eid'], $entity['revisionid'], array('maxCache' => $maxCache, 'maxDuration' => $maxDuration)); $ssp_metadata = $ssp_metadata . "\n\n" . sspmod_janus_MetaExport::getFlatMetadata($entity['eid'], $entity['revisionid']); if (empty($entityDescriptor)) { $t = new SimpleSAML_XHTML_Template($config, 'janus:error.php', 'janus:error'); $t->data['header'] = 'JANUS'; $t->data['title'] = 'error_required_metadata_missing_header'; $t->data['error'] = 'error_required_metadata_missing_entity'; $t->data['error_data'] = array('%ENTITY%' => $entity['entityid']); $t->data['extra_data'] = implode("\n", sspmod_janus_MetaExport::getError()); $t->show(); exit(0); } $entitiesDescriptor->appendChild($xml->importNode($entityDescriptor, TRUE)); } /* Sign the metadata if enabled. */ if ($janus_config->getBoolean('sign.enable', FALSE)) { $signer = new SimpleSAML_XML_Signer(array('privatekey' => $janus_config->getString('sign.privatekey'), 'privatekey_pass' => $janus_config->getString('sign.privatekey_pass', NULL), 'certificate' => $janus_config->getString('sign.certificate'), 'id' => 'ID'));