/** * @param $username * @param $password * * @return User * @throws \Ice\JanusClientBundle\Exception\AuthenticationException when credentials are bad * @throws \Exception|\Guzzle\Http\Exception\BadResponseException when an unknown error (eg 500) occurs */ public function authenticate($username, $password) { try { $command = $this->client->getCommand('Authenticate'); $command->prepare(); $command->getRequest()->setAuth($username, $password, CURLAUTH_BASIC); return $command->execute(); } catch (BadResponseException $e) { switch ($e->getResponse()->getStatusCode()) { case 401: case 403: throw new AuthenticationException(); break; } throw $e; } }