Пример #1
0
 private function _addCertificateMetaData(&$parsedMetaData)
 {
     $encryptionEnabled = $this->_config->getBoolean('encryption.enable');
     $certKeys = array('keys:0:', 'keys:1:', 'keys:2:', 'keys:3:', 'keys:4:', 'keys:5:', 'keys:6:', 'keys:7:', 'keys:8:');
     $certDataKeys = array('certData', 'certData2', 'certData3');
     $certificates = array();
     foreach ($certKeys as $certKey) {
         if (!isset($parsedMetaData[$certKey . 'X509Certificate'])) {
             continue;
         }
         // Skip encryption keys (key with no signing use) if we don't support encryption usage.
         if (!$parsedMetaData[$certKey . 'signing'] && !$encryptionEnabled) {
             continue;
         }
         $certData = $parsedMetaData[$certKey . 'X509Certificate'];
         /*
          * We don't want an empty certData if keys:0 is an encryption key and encryption is not enabled. So we
          * ensure that we fill the $certDataKeys in the right order.
          */
         foreach ($certDataKeys as $certDataKey) {
             if (!isset($certificates[$certDataKey])) {
                 $certificates[$certDataKey] = str_replace(array(" ", "\r\n", "\n", "\r", "\t", "\t"), '', $certData);
                 if (!$this->_validatePublicCertificate($certificates[$certDataKey])) {
                     return 'error_not_valid_certData';
                 }
                 break;
             }
         }
     }
     foreach ($certDataKeys as $certDataKey) {
         if (!isset($certificates[$certDataKey]) && $this->_entityController->hasMetadata($certDataKey)) {
             $this->_entityController->removeMetadata($certDataKey);
             $this->_updated = true;
         }
     }
     $parsedMetaData = array_merge($parsedMetaData, array_unique($certificates));
     return false;
 }
     $object = (array) $object;
     foreach ($object as $key => $value) {
         if (is_array($value) || is_object($value) && get_class($value) === 'stdClass') {
             $object[$key] = convert_stdobject_to_array($value);
         }
     }
     return $object;
 }
 try {
     $metaStdClass = json_decode($_POST['meta_json']);
     if ($metaStdClass) {
         $metaArray = convert_stdobject_to_array($metaStdClass);
         $metaArray = $mcontroller->arrayFlattenSep(':', $metaArray);
         if ($metaArray['entityid'] === $mcontroller->getEntity()->getEntityid()) {
             foreach ($metaArray as $key => $value) {
                 if ($mcontroller->hasMetadata($key)) {
                     echo "Updating: {$key}<br />" . PHP_EOL;
                     $mcontroller->updateMetadata($key, $value);
                 } else {
                     echo "Adding: {$key}<br />" . PHP_EOL;
                     $mcontroller->addMetadata($key, $value);
                 }
             }
             $update = TRUE;
             $msg = 'status_metadata_parsed_ok';
         } else {
             $msg = 'error_metadata_wrong_entity';
         }
     } else {
         $msg = 'error_not_valid_json';
     }