コード例 #1
0
 /**
  * @param Identity $identity
  * @return \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\RegistrationAuthorityCredentials|null
  */
 public function getRaCredentials(Identity $identity)
 {
     try {
         $credentials = $this->apiIdentityService->getRegistrationAuthorityCredentials($identity);
     } catch (Exception $e) {
         $message = sprintf('Exception when retrieving RA credentials: "%s"', $e->getMessage());
         $this->logger->critical($message);
         throw new RuntimeException($message, 0, $e);
     }
     return $credentials;
 }
コード例 #2
0
 /**
  * @param string $nameId
  * @param string $institution
  * @return null|\Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity
  * @throws \Surfnet\StepupSelfService\SelfServiceBundle\Exception\RuntimeException
  */
 public function findByNameIdAndInstitution($nameId, $institution)
 {
     $searchQuery = new IdentitySearchQuery($institution);
     $searchQuery->setNameId($nameId);
     try {
         $result = $this->apiIdentityService->search($searchQuery);
     } catch (Exception $e) {
         $message = sprintf('Exception when searching identity: "%s"', $e->getMessage());
         $this->logger->critical($message);
         throw new RuntimeException($message, 0, $e);
     }
     $elements = $result->getElements();
     if (count($elements) === 0) {
         return null;
     }
     if (count($elements) === 1) {
         return reset($elements);
     }
     throw new RuntimeException(sprintf('Got an unexpected amount of identities, expected 0 or 1, got "%d"', count($elements)));
 }