Example #1
0
 private function importParsedMetadata($parsedMetadata)
 {
     // If metadata was not parsed
     if ($parsedMetadata === null) {
         SimpleSAML_Logger::error('Importer - Metadata was not parsed');
         return 'error_metadata_not_parsed';
     }
     if (isset($parsedMetadata['expire']) && $parsedMetadata['expire'] < time()) {
         SimpleSAML_Logger::error('Importer - Metadata was not parsed due expiration');
         return 'error_metadata_not_parsed_due_expiration';
     }
     // Remove entity descriptor
     unset($parsedMetadata['entityDescriptor']);
     unset($parsedMetadata['metadata-set']);
     // Validate that entity id is the same for imported metadata and entity
     if ($parsedMetadata['entityid'] != $this->_entityId) {
         SimpleSAML_Logger::error('Importer - EntityId does not match');
         return 'error_entityid_no_match';
     } else {
         unset($parsedMetadata['entityid']);
     }
     $parsedMetadata = $this->_removeUnusedContacts($parsedMetadata);
     $parsedMetadata = $this->_removeNonSaml2Services($parsedMetadata);
     $parsedMetadata = $this->_applyRequestedAttributesAsArp($parsedMetadata);
     $converter = sspmod_janus_DiContainer::getInstance()->getMetaDataConverter();
     $parsedMetadata = $converter->execute($parsedMetadata);
     $msg = $this->_addCertificateMetaData($parsedMetadata);
     if ($msg) {
         return $msg;
     }
     foreach ($parsedMetadata as $key => $value) {
         if (!empty($this->_excludedMetadataKeys) && in_array($key, $this->_excludedMetadataKeys)) {
             continue;
         }
         if ($this->_entityController->hasMetadata($key)) {
             if (!$this->_entityController->updateMetadata($key, $value)) {
                 SimpleSAML_Logger::info('Importer - Metadata field ' . $key . ' with value ' . $value . ' was not added.');
             } else {
                 $this->_updated = true;
             }
         } else {
             if (!$this->_entityController->addMetadata($key, $value)) {
                 SimpleSAML_Logger::info('Importer - Metadata field ' . $key . ' with value ' . $value . ' was not added.');
             } else {
                 $this->_updated = true;
             }
         }
     }
     return 'status_metadata_parsed_ok';
 }
     $arp->setName($key);
     $arp->setAttributes($v);
     $arp->save();
     $econtroller->setArp($arp->getAid());
 }
 if ($k == 'name') {
     $k = 'entity:name';
 }
 if ($k == 'description') {
     $k = 'entity:description';
 }
 echo '<br>Key: ' . $k . '<br>';
 if (is_string($v)) {
     echo '<br/>Insert ' . $v . '<br/>';
     if (!$econtroller->addMetadata($k, $v)) {
         $econtroller->updateMetadata($k, $v);
         echo 'Updated<br>';
     } else {
         echo 'Added<br>';
     }
 } else {
     if (is_array($v)) {
         foreach ($v as $sk => $sv) {
             if (is_string($sk)) {
                 $newkey = $k . ':' . $sk;
             } else {
                 $newkey = $k;
             }
             echo '<br/>Insert ' . $sv . '<br/>';
             if (!$econtroller->addMetadata($newkey, $sv)) {
                 $econtroller->updateMetadata($newkey, $sv);
     foreach ($_POST as $key => $value) {
         //Metadata
         if (substr($key, 0, 14) == 'edit-metadata-') {
             if (!is_array($value)) {
                 $newkey = substr($key, 14, strlen($key));
                 // If field is boolean
                 if (substr($newkey, -4) == 'TRUE') {
                     $newkey = substr($newkey, 0, -5);
                     $value = true;
                 } else {
                     if (substr($newkey, -5) == 'FALSE') {
                         $newkey = substr($newkey, 0, -6);
                         $value = false;
                     }
                 }
                 if ($mcontroller->updateMetadata($newkey, $value)) {
                     $update = TRUE;
                     $note .= 'Metadata edited: ' . $newkey . ' => ' . $value . '<br />';
                 }
             }
         }
     }
 }
 // Delete metadata
 if (isset($_POST['delete-metadata']) && $guard->hasPermission('deletemetadata', $entity->getWorkflow(), $user->getType())) {
     foreach ($_POST['delete-metadata'] as $data) {
         if ($mcontroller->removeMetadata($data)) {
             $update = TRUE;
             $note .= 'Metadata deleted: ' . $data . '<br />';
         }
     }