Beispiel #1
0
 public function push($remoteId)
 {
     $remotes = $this->config->getArray('push.remote');
     if (!isset($remotes[$remoteId])) {
         throw new \InvalidArgumentException("Remote 'remote' does not exist");
     }
     $remoteUrl = $remotes[$remoteId]['url'];
     $connections = $this->connectionService->findAll();
     $serializer = SerializerBuilder::create()->build();
     $serializedConnections = $serializer->serialize($connections, 'json');
     $client = new Client();
     $request = $client->createRequest('POST', $remoteUrl, array('Content-Type' => 'application/json', 'User-Agent' => 'JANUS Guzzle HTTP Client (see: https://github.com/janus-ssp/janus)'), $serializedConnections, $this->config->getArray('push.requestOptions'));
     return $request->send()->__toString();
 }
Beispiel #2
0
 /**
  * Load entities that user has access to
  *
  * @param null|string Workflow state the entity has to be in
  * @param null|string Workflow state the entity must NOT be in
  * @param null|string Field to sort on
  * @param null|string Direction to sort in ('ASC'|'DESC')
  * @return bool True on success and false on error.
  * @since Method available since Release 1.0.0
  * @throws Exception if loading fails
  */
 private function _loadEntities($state = null, $state_exclude = null, $sort = null, $order = null)
 {
     if (!$this->securityContext->isGranted('allentities')) {
         $allowedUserId = $this->_user->getUid();
     } else {
         $allowedUserId = null;
     }
     $filter = array('state' => $state, 'stateExclude' => $state_exclude, 'allowedUserId' => $allowedUserId);
     $connectionCollection = $this->connectionService->findDescriptorsForFilters($filter, $sort, $order);
     $this->_entities = array();
     /** @var $connectionDto \Janus\ServiceRegistry\Connection\ConnectionDto */
     foreach ($connectionCollection->connections as $connectionDto) {
         $entity = new sspmod_janus_Entity($this->_config);
         $entity->setEid($connectionDto->id);
         $entity->setRevisionid($connectionDto->revisionNr);
         if (!is_null($state)) {
             $entity->setWorkflow($state);
         }
         if ($entity->load()) {
             $this->_entities[] = $entity;
         } else {
             SimpleSAML_Logger::error('JANUS:UserController:_loadEntities - Entity could not be
                 loaded: ' . var_export($entity, true));
         }
     }
     return true;
 }
 public function testReturnsConnectionEntity()
 {
     // Mock repository which returns connection
     $connectionRepositoryMock = Phake::mock('Janus\\ServiceRegistry\\Entity\\ConnectionRepository');
     $connection = new Connection('test', 'saml20-idp');
     Phake::when($connectionRepositoryMock)->find(1)->thenReturn($connection);
     // Mock entity manager which returns repository
     $entityManagerMock = Phake::mock('Doctrine\\ORM\\EntityManager');
     Phake::when($entityManagerMock)->getRepository('Janus\\ServiceRegistry\\Entity\\Connection')->thenReturn($connectionRepositoryMock);
     // Create service
     $config = new ConfigProxy(array());
     $metadataDefinitionHelper = new MetadataDefinitionHelper($config);
     $loggerMock = Phake::mock('Monolog\\Logger');
     $connectionService = new ConnectionService($entityManagerMock, $config, $loggerMock, new MetadataTreeFlattener($metadataDefinitionHelper), $metadataDefinitionHelper, $connectionRepositoryMock);
     $connection = $connectionService->findById(1);
     $this->assertInstanceOf('Janus\\ServiceRegistry\\Entity\\Connection', $connection);
 }