Exemplo n.º 1
0
 /**
  * Get all metadata for the entity
  *
  * @return false|array Array with metadata or false on error
  */
 public function getMetaArray()
 {
     if (empty($this->_metadata)) {
         if (!$this->_loadMetadata()) {
             return false;
         }
     }
     $metaArray = array();
     foreach ($this->_metadata as $data) {
         if (strpos($data->getKey(), ':')) {
             $keys = explode(':', $data->getKey());
             $val = $data->getValue();
             $array = array();
             while (!empty($keys)) {
                 $array = array();
                 $newKey = array_pop($keys);
                 $array[$newKey] = $val;
                 $val = $array;
             }
             $metaArray = self::arrayMergeRecursiveFixed($array, $metaArray);
         } else {
             $metaArray[$data->getKey()] = $data->getValue();
         }
     }
     $metaArray['entityid'] = $this->_entity->getEntityid();
     /*
      * The expiration field in the entity table is not for metadata 
      * expiration, but for telling when the entity can no longer be accessed 
      * via JANUS. 
      * To set expiration on metadata a metadata field called expiration 
      * should be set
      */
     /* 
             $expiration = $this->getEntity()->getExpiration();
             if ($expiration) {
        $metaArray['expire'] = SimpleSAML_Utilities::parseSAML2Time($expiration);
             }
     */
     $entity_type = $this->_entity->getType();
     $metaArray['metadata-set'] = $this->_entity->getType() . '-remote';
     if (!array_key_exists('NameIDFormat', $metaArray)) {
         if ($entity_type == 'saml20-idp' || $entity_type == 'saml20-sp') {
             $metaArray['NameIDFormat'] = 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient';
         } else {
             if ($entity_type == 'shib13-idp' || $entity_type == 'shib13-idp') {
                 $metaArray['NameIDFormat'] = 'urn:mace:shibboleth:1.0:nameIdentifier';
             }
         }
     }
     if ($entity_type == 'saml20-sp') {
         if (!is_null($this->_entity->getArpAttributes())) {
             $metaArray['attributes'] = array_keys($this->_entity->getArpAttributes());
         }
     }
     if (!isset($metaArray['name'])) {
         $metaArray['name']['en'] = $this->_entity->getEntityid();
     }
     if (isset($metaArray['certData2']) && isset($metaArray['certData'])) {
         $keys = array();
         $keys[0] = array('encryption' => FALSE, 'signing' => TRUE, 'type' => 'X509Certificate', 'X509Certificate' => $metaArray['certData']);
         $keys[1] = array('encryption' => TRUE, 'signing' => FALSE, 'type' => 'X509Certificate', 'X509Certificate' => $metaArray['certData']);
         $keys[2] = array('encryption' => FALSE, 'signing' => TRUE, 'type' => 'X509Certificate', 'X509Certificate' => $metaArray['certData2']);
         unset($metaArray['certData2']);
         $metaArray['keys'] = $keys;
     }
     return $metaArray;
 }