Пример #1
0
             $user = new sspmod_janus_User($janus_config);
             $user->setUid($tmp[1]);
             $user->load();
             $name = $tmp[0] . ' - ' . $user->getUserid();
         } else {
             if (isset($tmp[1]) && $tmp[1] == 'NEW') {
                 $name = $tmp[0] . ' - ' . 'NEW';
             } else {
                 $name = $tmp[0];
             }
         }
     } else {
         if ($tmp[0] == 'ENTITYUPDATE') {
             if (isset($tmp[1]) && ctype_digit((string) $tmp[1])) {
                 $entity = new sspmod_janus_Entity($janus_config);
                 $entity->setEid($tmp[1]);
                 try {
                     $entity->load();
                     $name = $tmp[0] . ' - ' . $entity->getEntityid();
                 } catch (\Exception $ex) {
                     $name = "Entity '{$tmp['1']}' does not exist";
                 }
             } else {
                 $name = implode('-', $tmp);
             }
         } else {
             $name = implode('-', $tmp);
         }
     }
     echo '<option value="' . htmlspecialchars($subscription) . '">' . htmlspecialchars($name) . '</option>';
 }
Пример #2
0
if ($securityContext->isGranted('allentities')) {
    $userEntities = $remoteEntities;
} else {
    $userEntities = $adminUtil->getEntitiesFromUser($user->getUid());
}
$reverseBlockedEntities = $adminUtil->getReverseBlockedEntities($entity, $userEntities);
// Get metadatafields
$mfc = $janus_config->getArray('metadatafields.' . $entity->getType());
$mb = new sspmod_janus_MetadataFieldBuilder($mfc);
$et->data['metadatafields'] = $mb->getMetadataFields();
$remote_entities = array();
$remote_entities_acl_sorted = array();
// Only parse name and description in current language
foreach ($remoteEntities as $remoteEntityRow) {
    $remoteEntity = new sspmod_janus_Entity($janus_config);
    $remoteEntity->setEid($remoteEntityRow["eid"]);
    $remoteEntity->setRevisionid($remoteEntityRow["revisionid"]);
    $remoteEntity->load();
    $remoteEntityFormatted = array('eid' => $remoteEntity->getEid(), 'revisionid' => $remoteEntity->getRevisionid(), 'type' => $remoteEntity->getType(), 'notes' => $remoteEntity->getNotes());
    // Format the name for the remote entity
    $remoteEntityName = $remoteEntity->getPrettyName();
    if (isset($remoteEntityName)) {
        if (is_array($remoteEntityName)) {
            if (array_key_exists($language, $remoteEntityName)) {
                $remoteEntityFormatted['name'][$language] = $remoteEntityName[$language];
            } else {
                reset($remoteEntityName);
                $remoteEntityFormatted['name'][$language] = 'No name in current language (' . current($remoteEntityName) . ')';
            }
        } else {
            $remoteEntityFormatted['name'][$language] = $remoteEntityName;
Пример #3
0
 /**
  * Get the entity history.
  *
  * Returns an array of entities. One for each revision.
  *
  * @param int $lower_limit The lower limit from which get revisions
  * @param int $upper_limit The upper limit up to which get revisions
  *
  * @return array|bool An array of sspmod_janus_Entity or FALSE on error
  */
 public function getHistory($lower_limit = null, $upper_limit = null)
 {
     assert('$this->_entity instanceof Sspmod_Janus_Entity');
     if ($lower_limit !== null || $upper_limit !== null) {
         $limit_clause = ' LIMIT';
         if ($lower_limit !== null) {
             $limit_clause = $limit_clause . ' ' . $lower_limit;
         }
         if ($upper_limit !== null) {
             $separator = $limit_clause === null ? ' ' : ', ';
             $limit_clause = $limit_clause . $separator . $upper_limit;
         }
     } else {
         $limit_clause = '';
     }
     $st = $this->execute('SELECT * 
         FROM ' . $this->getTablePrefix() . 'connectionRevision
         WHERE `eid` = ? 
         ORDER BY `revisionid` DESC' . $limit_clause, array($this->_entity->getEid()));
     if ($st === false) {
         return false;
     }
     $rs = $st->fetchAll(PDO::FETCH_ASSOC);
     $history = array();
     foreach ($rs as $data) {
         $entity = new sspmod_janus_Entity($this->_config);
         $entity->setEid($this->_entity->getEid());
         $entity->setRevisionid($data['revisionid']);
         if (!$entity->load()) {
             SimpleSAML_Logger::error(__CLASS__ . ':getHistory - Entity could not ' . 'load. Eid: ' . $this->_entity->getEntityid() . ' - Rid: ' . $data['revisionid']);
             return false;
         }
         $history[] = $entity;
     }
     return $history;
 }
 /**
  * Retrieve all Eids for entities that match a certain metadata value.
  * 
  * The query is revision aware (only searches the latest revision of every
  * entity)
  * 
  * Note that this function supports regular expressions in the metadata 
  * value. If a metadata entry in the database is a regular expression, 
  * it will be matched against the $value passed to this function. This
  * works only one way, it's not possible to pass a regular expression 
  * to this function; the regex must be in the db.
  * 
  * @param String $key   The metadata key on which to perform the search
  * @param String $value The value to search for. 
  */
 public function searchEntitiesByMetadata($key, $value)
 {
     assert('is_string($key)');
     assert('is_string($value)');
     $st = $this->execute('SELECT DISTINCT eid 
         FROM ' . self::$prefix . "metadata jm\n            WHERE `key` = ?\n            AND ((value=?) OR (? REGEXP CONCAT('^',value,'\$')))\n            AND revisionid = (SELECT MAX(revisionid) FROM " . self::$prefix . "metadata WHERE eid = jm.eid);", array($key, $value, $value));
     if ($st === false) {
         return 'error_db';
     }
     $this->_entities = array();
     $rows = $st->fetchAll(PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $entity = new sspmod_janus_Entity($this->_config);
         $entity->setEid($row['eid']);
         if ($entity->load()) {
             $this->_entities[] = $entity;
         } else {
             SimpleSAML_Logger::error('JANUS:UserController:searchEntitiesByMetadata - Entity could not be
                 loaded, eid: ' . $row['eid']);
         }
     }
     return $this->_entities;
 }
Пример #5
0
 /**
  * Retrieve all Eids for entities that match a certain metadata value.
  * 
  * The query is revision aware (only searches the latest revision of every
  * entity)
  * 
  * Note that this function supports regular expressions in the metadata 
  * value. If a metadata entry in the database is a regular expression, 
  * it will be matched against the $value passed to this function. This
  * works only one way, it's not possible to pass a regular expression 
  * to this function; the regex must be in the db.
  * 
  * @param String $key   The metadata key on which to perform the search
  * @param String $value The value to search for. 
  */
 public function searchEntitiesByMetadata($key, $value)
 {
     assert('is_string($key)');
     assert('is_string($value)');
     $st = $this->execute("\n            SELECT  DISTINCT CONNECTION_REVISION.eid\n            FROM        " . $this->getTablePrefix() . "metadata AS METADATA\n            INNER JOIN  " . $this->getTablePrefix() . "connectionRevision AS CONNECTION_REVISION\n                ON  CONNECTION_REVISION.id = METADATA.connectionRevisionId\n            INNER JOIN  " . $this->getTablePrefix() . "connection AS CONNECTION\n                ON  CONNECTION.id = CONNECTION_REVISION.eid\n                AND CONNECTION.revisionNr = CONNECTION_REVISION.revisionid\n            WHERE   METADATA.`key` = ?\n                AND (\n                    (METADATA.value=?)\n                    OR (? REGEXP CONCAT('^',METADATA.value,'\$'))\n                )\n                ", array($key, $value, $value));
     if ($st === false) {
         return 'error_db';
     }
     $this->_entities = array();
     $rows = $st->fetchAll(PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $entity = new sspmod_janus_Entity($this->_config);
         $entity->setEid($row['eid']);
         if ($entity->load()) {
             $this->_entities[] = $entity;
         } else {
             SimpleSAML_Logger::error('JANUS:UserController:searchEntitiesByMetadata - Entity could not be
                 loaded, eid: ' . $row['eid']);
         }
     }
     return $this->_entities;
 }
        } else {
            if ($entity->getType() == 'shib13-idp') {
                $loaded_entities = array_merge($autil->getEntitiesByStateType(null, 'saml20-sp'), $autil->getEntitiesByStateType(null, 'shib13-sp'));
            }
        }
    }
}
// Get metadatafields
$mfc = $janus_config->getArray('metadatafields.' . $entity->getType());
$mb = new sspmod_janus_MetadatafieldBuilder($mfc);
$et->data['metadatafields'] = $mb->getMetadatafields();
$remote_entities = array();
// Only parse name and description in current language
foreach ($loaded_entities as $entityRow) {
    $instance = new sspmod_janus_Entity($janus_config);
    $instance->setEid($entityRow["eid"]);
    $instance->setRevisionid($entityRow["revisionid"]);
    $instance->load();
    $value = array("name" => $instance->getPrettyName(), "description" => $instance->getEntityId());
    $key = $instance->getEntityId();
    unset($value2);
    if (isset($value['name'])) {
        if (is_array($value['name'])) {
            if (array_key_exists($language, $value['name'])) {
                $value2['name'][$language] = $value['name'][$language];
            } else {
                reset($value['name']);
                $value2['name'][$language] = 'No name in current language (' . current($value['name']) . ')';
            }
        } else {
            $value2['name'][$language] = $value['name'];