getMetadataSet() public method

Retrieve a list of all available metadata for a given set.
public getMetadataSet ( string $set ) : array
$set string The set we are looking for metadata in.
return array An associative array with all the metadata for the given set.
Ejemplo n.º 1
0
}
$userid = $attributes[$useridattr][0];
function requireOwnership($metadata, $userid)
{
    if (!isset($metadata['owner'])) {
        throw new Exception('Metadata has no owner. Which means no one is granted access, not even you.');
    }
    if ($metadata['owner'] !== $userid) {
        throw new Exception('Metadata has an owner that is not equal to your userid, hence you are not granted access.');
    }
}
if (isset($_REQUEST['delete'])) {
    $premetadata = $mdh->getMetadata($_REQUEST['delete'], 'saml20-sp-remote');
    requireOwnership($premetadata, $userid);
    $mdh->deleteMetadata($_REQUEST['delete'], 'saml20-sp-remote');
}
$list = $mdh->getMetadataSet('saml20-sp-remote');
$slist = array('mine' => array(), 'others' => array());
foreach ($list as $listitem) {
    if (array_key_exists('owner', $listitem)) {
        if ($listitem['owner'] === $userid) {
            $slist['mine'][] = $listitem;
            continue;
        }
    }
    $slist['others'][] = $listitem;
}
$template = new SimpleSAML_XHTML_Template($config, 'metaedit:metalist.php');
$template->data['metadata'] = $slist;
$template->data['userid'] = $userid;
$template->show();
Ejemplo n.º 2
0
 /**
  * Save metadata for loading with the 'serialize' metadata loader.
  *
  * @param string $outputDir  The directory we should save the metadata to.
  */
 public function writeMetadataSerialize($outputDir)
 {
     assert('is_string($outputDir)');
     $metaHandler = new SimpleSAML_Metadata_MetaDataStorageHandlerSerialize(array('directory' => $outputDir));
     /* First we add all the metadata entries to the metadata handler. */
     foreach ($this->metadata as $set => $elements) {
         foreach ($elements as $m) {
             $entityId = $m['metadata']['entityid'];
             SimpleSAML_Logger::debug('metarefresh: Add metadata entry ' . var_export($entityId, TRUE) . ' in set ' . var_export($set, TRUE) . '.');
             $metaHandler->saveMetadata($entityId, $set, $m['metadata']);
         }
     }
     /* Then we delete old entries which should no longer exist. */
     $ct = time();
     foreach ($metaHandler->getMetadataSets() as $set) {
         foreach ($metaHandler->getMetadataSet($set) as $entityId => $metadata) {
             if (!array_key_exists('expire', $metadata)) {
                 SimpleSAML_Logger::warning('metarefresh: Metadata entry without expire timestamp: ' . var_export($entityId, TRUE) . ' in set ' . var_export($set, TRUE) . '.');
                 continue;
             }
             if ($metadata['expire'] > $ct) {
                 continue;
             }
             SimpleSAML_Logger::debug('metarefresh: ' . $entityId . ' expired ' . date('l jS \\of F Y h:i:s A', $metadata['expire']));
             SimpleSAML_Logger::debug('metarefresh: Delete expired metadata entry ' . var_export($entityId, TRUE) . ' in set ' . var_export($set, TRUE) . '. (' . ($ct - $metadata['expire']) . ' sec)');
             $metaHandler->deleteMetadata($entityId, $set);
         }
     }
 }
Ejemplo n.º 3
0
<?php

$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
$kconfig = SimpleSAML_Configuration::getConfig('module_metalisting.php');
$tag = $kconfig->getString('defaultTags', 'prod');
$allowedTags = $kconfig->getArray('allowedTags');
if (isset($_REQUEST['set'])) {
    if (in_array($_REQUEST['set'], $allowedTags)) {
        $tag = $_REQUEST['set'];
    }
}
$kdconfig = $kconfig->getConfigItem('dirs');
$dir = $kdconfig->getString($tag);
// echo('<pre>');
// print_r($tag);
// print_r($allowedTags);
// print_r($dir);
// exit;
$mh = new SimpleSAML_Metadata_MetaDataStorageHandlerSerialize(array('directory' => $dir));
$metaentries = array();
$metaentries['remote']['saml20-idp-remote'] = $mh->getMetadataSet('saml20-idp-remote');
$metaentries['remote']['saml20-sp-remote'] = $mh->getMetadataSet('saml20-sp-remote');
// echo('<pre>');
// print_r($mentries);
$t = new SimpleSAML_XHTML_Template($config, 'metalisting:metalisting.tpl.php');
$t->data['header'] = 'Federation entities';
$t->data['metaentries'] = $metaentries;
$t->data['extended'] = isset($_REQUEST['extended']);
$t->show();
exit;