当前位置: 首页>>代码示例>>PHP>>正文


PHP CF_Authentication::export_credentials方法代码示例

本文整理汇总了PHP中CF_Authentication::export_credentials方法的典型用法代码示例。如果您正苦于以下问题:PHP CF_Authentication::export_credentials方法的具体用法?PHP CF_Authentication::export_credentials怎么用?PHP CF_Authentication::export_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CF_Authentication的用法示例。


在下文中一共展示了CF_Authentication::export_credentials方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConnection

 /**
  * Get an authenticated connection handle to the Swift proxy
  *
  * @throws CloudFilesException
  * @throws CloudFilesException|Exception
  * @return CF_Connection|bool False on failure
  */
 protected function getConnection()
 {
     if ($this->connException instanceof CloudFilesException) {
         if (time() - $this->connErrorTime < 60) {
             throw $this->connException;
             // failed last attempt; don't bother
         } else {
             // actually retry this time
             $this->connException = null;
             $this->connErrorTime = 0;
         }
     }
     // Session keys expire after a while, so we renew them periodically
     $reAuth = time() - $this->sessionStarted > $this->authTTL;
     // Authenticate with proxy and get a session key...
     if (!$this->conn || $reAuth) {
         $this->sessionStarted = 0;
         $this->connContainerCache->clear();
         $cacheKey = $this->getCredsCacheKey($this->auth->username);
         $creds = $this->srvCache->get($cacheKey);
         // credentials
         if (is_array($creds)) {
             // cache hit
             $this->auth->load_cached_credentials($creds['auth_token'], $creds['storage_url'], $creds['cdnm_url']);
             $this->sessionStarted = time() - ceil($this->authTTL / 2);
             // skew for worst case
         } else {
             // cache miss
             try {
                 $this->auth->authenticate();
                 $creds = $this->auth->export_credentials();
                 $this->srvCache->add($cacheKey, $creds, ceil($this->authTTL / 2));
                 // cache
                 $this->sessionStarted = time();
             } catch (CloudFilesException $e) {
                 $this->connException = $e;
                 // don't keep re-trying
                 $this->connErrorTime = time();
                 throw $e;
                 // throw it back
             }
         }
         if ($this->conn) {
             // re-authorizing?
             $this->conn->close();
             // close active cURL handles in CF_Http object
         }
         $this->conn = new CF_Connection($this->auth);
     }
     return $this->conn;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:58,代码来源:SwiftFileBackend.php

示例2: testTokenErrors

 public function testTokenErrors()
 {
     $auth = new CF_Authentication(USER, API_KEY);
     $auth->authenticate();
     $arr = $auth->export_credentials();
     $this->assertNotNull($arr['storage_url']);
     $this->assertNotNull($arr['cdnm_url']);
     $this->assertNotNull($arr['auth_token']);
     $this->auth = new CF_Authentication();
     $this->setExpectedException('SyntaxException');
     $auth->load_cached_credentials(NULL, $arr['storage_url'], $arr['cdnm_url']);
     $this->setExpectedException('SyntaxException');
     $auth->load_cached_credentials($arr['auth_token'], NULL, $arr['cdnm_url']);
     $this->setExpectedException('SyntaxException');
     $auth->load_cached_credentials($arr['auth_token'], $arr['storage_url'], NULL);
 }
开发者ID:yusufchang,项目名称:app,代码行数:16,代码来源:Authentication.php

示例3: getConnection

 /**
  * Get a connection to the Swift proxy
  *
  * @return CF_Connection|false
  * @throws InvalidResponseException
  */
 protected function getConnection()
 {
     if ($this->conn === false) {
         throw new InvalidResponseException();
         // failed last attempt
     }
     // Session keys expire after a while, so we renew them periodically
     if ($this->conn && time() - $this->connStarted > $this->authTTL) {
         $this->closeConnection();
     }
     // Authenticate with proxy and get a session key...
     if ($this->conn === null) {
         $cacheKey = $this->getCredsCacheKey($this->auth->username);
         $creds = $this->srvCache->get($cacheKey);
         // credentials
         if (is_array($creds)) {
             // cache hit
             $this->auth->load_cached_credentials($creds['auth_token'], $creds['storage_url'], $creds['cdnm_url']);
             $this->connStarted = time() - ceil($this->authTTL / 2);
             // skew for worst case
         } else {
             // cache miss
             try {
                 $this->auth->authenticate();
                 $creds = $this->auth->export_credentials();
                 $this->srvCache->set($cacheKey, $creds, ceil($this->authTTL / 2));
                 // cache
                 $this->connStarted = time();
             } catch (AuthenticationException $e) {
                 $this->conn = false;
                 // don't keep re-trying
                 $this->logException($e, __METHOD__, $creds);
             } catch (InvalidResponseException $e) {
                 $this->conn = false;
                 // don't keep re-trying
                 $this->logException($e, __METHOD__, $creds);
             }
         }
         $this->conn = new CF_Connection($this->auth);
     }
     if (!$this->conn) {
         throw new InvalidResponseException();
         // auth/connection problem
     }
     return $this->conn;
 }
开发者ID:yusufchang,项目名称:app,代码行数:52,代码来源:SwiftFileBackend.php

示例4: getAuth

 private static function getAuth()
 {
     global $wgMemc;
     $cacheKey = wfMemcKey('rscloudauth');
     $auth = new CF_Authentication(WH_RSCLOUD_USERNAME, WH_RSCLOUD_API_KEY);
     $creds = $wgMemc->get($cacheKey);
     if (!$creds) {
         # $auth->ssl_use_cabundle();  # bypass cURL's old CA bundle
         $auth->authenticate();
         // makes a call to a remote web server
         $creds = $auth->export_credentials();
         $wgMemc->set($cacheKey, $creds);
     } else {
         $auth->load_cached_credentials($creds['auth_token'], $creds['storage_url'], $creds['cdnm_url']);
     }
     return $auth;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:17,代码来源:sync_images_to_rscf.php

示例5: authenticate

 public function authenticate()
 {
     /** @var Host $host */
     foreach ($this->hosts as $host) {
         $config = $host->getAuthConfig();
         $auth = new \CF_Authentication($config['swiftUser'], $config['swiftKey'], null, $config['swiftAuthUrl']);
         $auth->authenticate();
         $credentials = $auth->export_credentials();
         $host->setCredentials($credentials['auth_token'], $credentials['storage_url']);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:Net.php


注:本文中的CF_Authentication::export_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。