/**
  * @param string $identityId
  * @param string $stepupProvider
  * @param string $gssfId
  * @return string|null
  */
 public function provePossession($identityId, $stepupProvider, $gssfId)
 {
     $command = new ProveGssfPossessionCommand();
     $command->identityId = $identityId;
     $command->secondFactorId = Uuid::generate();
     $command->stepupProvider = $stepupProvider;
     $command->gssfId = $gssfId;
     $result = $this->commandService->execute($command);
     return $result->isSuccessful() ? $command->secondFactorId : null;
 }
 public function execute(Command $command)
 {
     $token = $this->tokenStorage->getToken();
     if (!$token) {
         return $this->commandService->execute($command, new Metadata(null, null));
     }
     /** @var \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity $identity */
     $identity = $token->getUser();
     return $this->commandService->execute($command, new Metadata($identity->id, $identity->institution));
 }
 /**
  * @param $command
  */
 public function processCommand($command)
 {
     $messageTemplate = 'Exception when saving Identity[%s]: with command "%s", error: "%s"';
     try {
         $result = $this->commandService->execute($command);
     } catch (Exception $e) {
         $message = sprintf($messageTemplate, $command->id, get_class($command), $e->getMessage());
         $this->logger->critical($message);
         throw new RuntimeException($message, 0, $e);
     }
     if (!$result->isSuccessful()) {
         $note = sprintf($messageTemplate, $command->id, get_class($command), implode('", "', $result->getErrors()));
         $this->logger->critical($note);
         throw new RuntimeException($note);
     }
 }