Exemplo n.º 1
0
 protected function authenticate()
 {
     $username = $this->cxt('username');
     $password = $this->cxt('password');
     $account = $this->cxt('account');
     $key = $this->cxt('key');
     $tenantId = $this->cxt('tenantid');
     $authUrl = $this->cxt('endpoint');
     $ident = new \HPCloud\Services\IdentityServices($authUrl);
     // Frustrated? Go burninate. http://www.homestarrunner.com/trogdor.html
     if (!empty($username) && !empty($password)) {
         $token = $ident->authenticateAsUser($username, $password, $tenantId);
     } elseif (!empty($account) && !empty($key)) {
         $token = $ident->authenticateAsAccount($account, $key, $tenantId);
     } else {
         throw new \HPCloud\Exception('Either username/password or account/key must be provided.');
     }
     // Cache the service catalog.
     self::$serviceCatalogCache[$token] = $ident->serviceCatalog();
     return $ident;
 }