Esempio n. 1
0
 private function execute(Command $command) : CollectionInterface
 {
     if (null !== $this->identity) {
         $command = $command->withIdentity($this->identity);
     }
     return $this->resultSetClient->execute($command);
 }
 public function authenticate(string $username, string $password) : Result
 {
     $identity = $this->identityHandler->createIdentity($username, $password);
     try {
         $resultSet = $this->resultSetClient->execute((new Command($this->identityLayout, [$this->usernameField => '==' . $this->resultSetClient->quoteString($username), '-find' => null]))->withIdentity($identity));
     } catch (InvalidResponseException $e) {
         $errorCode = $e->getCode();
         if (401 === $errorCode) {
             return Result::fromInvalidCredentials();
         }
         throw $e;
     }
     if ($resultSet->isEmpty()) {
         throw InvalidResultException::fromEmptyResultSet();
     }
     return Result::fromIdentity($identity);
 }