ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
metadata-converter.php
Go to the documentation of this file.
1 <?php
2 require_once('../_include.php');
3 
4 // make sure that the user has admin access rights
6 
8 
9 if (!empty($_FILES['xmlfile']['tmp_name'])) {
10  $xmldata = trim(file_get_contents($_FILES['xmlfile']['tmp_name']));
11 } elseif (array_key_exists('xmldata', $_POST)) {
12  $xmldata = trim($_POST['xmldata']);
13 }
14 
15 if (!empty($xmldata)) {
16  \SimpleSAML\Utils\XML::checkSAMLMessage($xmldata, 'saml-meta');
18 
19  // get all metadata for the entities
20  foreach ($entities as &$entity) {
21  $entity = array(
22  'shib13-sp-remote' => $entity->getMetadata1xSP(),
23  'shib13-idp-remote' => $entity->getMetadata1xIdP(),
24  'saml20-sp-remote' => $entity->getMetadata20SP(),
25  'saml20-idp-remote' => $entity->getMetadata20IdP(),
26  );
27  }
28 
29  // transpose from $entities[entityid][type] to $output[type][entityid]
31 
32  // merge all metadata of each type to a single string which should be added to the corresponding file
33  foreach ($output as $type => &$entities) {
34  $text = '';
35  foreach ($entities as $entityId => $entityMetadata) {
36 
37  if ($entityMetadata === null) {
38  continue;
39  }
40 
41  // remove the entityDescriptor element because it is unused, and only makes the output harder to read
42  unset($entityMetadata['entityDescriptor']);
43 
44  $text .= '$metadata['.var_export($entityId, true).'] = '.
45  var_export($entityMetadata, true).";\n";
46  }
47  $entities = $text;
48  }
49 } else {
50  $xmldata = '';
51  $output = array();
52 }
53 
54 $template = new SimpleSAML_XHTML_Template($config, 'metadata-converter.php', 'admin');
55 $template->data['clipboard.js'] = true;
56 $template->data['xmldata'] = $xmldata;
57 $template->data['output'] = $output;
58 $template->show();
static transpose($array)
This function transposes a two-dimensional array, so that $a[&#39;k1&#39;][&#39;k2&#39;] becomes $a[&#39;k2&#39;][&#39;k1&#39;].
Definition: Arrays.php:39
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
$type
static checkSAMLMessage($message, $type)
This function performs some sanity checks on XML documents, and optionally validates them against the...
Definition: XML.php:35
static parseDescriptorsString($string)
This function parses a string with XML data.
Definition: SAMLParser.php:318
$text
Definition: errorreport.php:18
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
$_POST["username"]
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.