Ejemplo n.º 1
0
 /**
  * Authenticate with the node with a password, if set
  *
  * @throws AuthenticationException
  */
 private function authenticateWithPassword()
 {
     if ($this->credentials->havePassword()) {
         $authCommand = new Auth();
         $authCommand->setArguments([$this->credentials->getPassword()]);
         $authResponse = $this->connection->execute($authCommand);
         $response = $authCommand->parse($authResponse);
         if ($response !== self::AUTH_SUCCESS_MESSAGE) {
             throw new AuthenticationException();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Actually perform the connection
  *
  * @param ConnectionInterface $connection Connection
  * @param array $server Server (with `host`, `options', `port`, and `password`)
  */
 private function doConnect(ConnectionInterface $connection, array $server)
 {
     $server += ['options' => []];
     $connection->connect($server['options']);
     if (!empty($server['password'])) {
         $authCommand = new Auth();
         $authCommand->setArguments([$server['password']]);
         $response = $authCommand->parse($connection->execute($authCommand));
         if ($response !== 'OK') {
             throw new AuthenticationException();
         }
     }
 }