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


PHP CF_Authentication::authenticate方法代码示例

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


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

示例1: switch

 /**
  * Init connection object
  *
  * @param string $error
  * @return boolean
  */
 function _init(&$error)
 {
     if (empty($this->_config['user'])) {
         $error = 'Empty username.';
         return false;
     }
     if (empty($this->_config['key'])) {
         $error = 'Empty API key.';
         return false;
     }
     if (empty($this->_config['location'])) {
         $error = 'Empty API key.';
         return false;
     }
     switch ($this->_config['location']) {
         default:
         case 'us':
             $host = US_AUTHURL;
             break;
         case 'uk':
             $host = UK_AUTHURL;
             break;
     }
     try {
         $this->_auth = new CF_Authentication($this->_config['user'], $this->_config['key'], null, $host);
         $this->_auth->ssl_use_cabundle();
         $this->_auth->authenticate();
         $this->_connection = new CF_Connection($this->_auth);
         $this->_connection->ssl_use_cabundle();
     } catch (Exception $exception) {
         $error = $exception->getMessage();
         return false;
     }
     return true;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:41,代码来源:Rscf.php

示例2: 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->conn->close();
         // close active cURL connections
         $this->conn = null;
     }
     // Authenticate with proxy and get a session key...
     if ($this->conn === null) {
         $this->connContainers = array();
         try {
             $this->auth->authenticate();
             $this->conn = new CF_Connection($this->auth);
             $this->connStarted = time();
         } catch (AuthenticationException $e) {
             $this->conn = false;
             // don't keep re-trying
         } catch (InvalidResponseException $e) {
             $this->conn = false;
             // don't keep re-trying
         }
     }
     if (!$this->conn) {
         throw new InvalidResponseException();
         // auth/connection problem
     }
     return $this->conn;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:39,代码来源:SwiftFileBackend.php

示例3: doRackspaceUploadNewDeleteOld

function doRackspaceUploadNewDeleteOld($RS_USERNAME, $RS_KEY)
{
    //get the most recent grouping of files.
    $arrRecentFiles = getMostRecentFiles();
    sort($arrRecentFiles);
    if (count($arrRecentFiles > 0)) {
        //============================================ get our rackspace auth, connection, and container set up =====================================
        //Create the authentication instance
        $auth = new CF_Authentication($RS_USERNAME, $RS_KEY);
        //Perform authentication request
        $auth->authenticate();
        //Create a connection to the storage/cdn system(s) and pass in the validated CF_Authentication instance.
        $conn = new CF_Connection($auth);
        //get the "salesforce_backups" container
        $cont = $conn->get_container('salesforce_backups');
        //============================================ end get our rackspace auth, connection, and container set up =====================================
        //get the date prefix off of the most recent grouping of local files
        $recentFileDate = getDatePrefix($arrRecentFiles[0]);
        //get the listing of files from rackspace cloud files
        $arrRackspaceFiles = $cont->list_objects();
        sort($arrRackspaceFiles);
        //get a distinct listing off all the rackspace prefixes (Dates)
        $arrRackspaceDistinctPrefixes = filterDistinctPrefixes($arrRackspaceFiles);
        //see if the most recent local date is in rackspace or not
        if (!in_array($recentFileDate, $arrRackspaceDistinctPrefixes)) {
            //we haven't uploaded our most recent local files yet to rackspace.  Let's do it.
            uploadToRackspace($cont, $arrRecentFiles);
        }
        //refresh our container and objects so we are sure the newly included files are in them
        $cont = $conn->get_container('salesforce_backups');
        //if we have more than 4 distinct date range prefixes (more than 4 weekly backups), delete the older ones so we are just left with the 4 most recent.
        deleteOlderBackups($conn, $cont);
    }
}
开发者ID:robertjustjones,项目名称:salesforceDataBackup,代码行数:34,代码来源:getData.php

示例4: wmfGetSwiftThumbContainer

/**
 * Get the Swift thumbnail container for this wiki.
 *
 * @param $site string
 * @param $lang string
 * @param $relPath string Path relative to container
 * @return CF_Container|null
 */
function wmfGetSwiftThumbContainer($site, $lang, $relPath)
{
    global $wmfSwiftConfig;
    // from PrivateSettings.php
    $auth = new CF_Authentication($wmfSwiftConfig['user'], $wmfSwiftConfig['key'], NULL, $wmfSwiftConfig['authUrl']);
    try {
        $auth->authenticate();
    } catch (Exception $e) {
        wfDebugLog('swiftThumb', "Could not establish a connection to Swift.");
        return null;
    }
    $conn = new CF_Connection($auth);
    $wikiId = "{$site}-{$lang}";
    // Get the full swift container name, including any shard suffix
    $name = "{$wikiId}-local-thumb";
    if (in_array($wikiId, array('wikipedia-commons', 'wikipedia-en'))) {
        // Code stolen from FileBackend::getContainerShard()
        if (preg_match("!^(?:[^/]{2,}/)*[0-9a-f]/(?P<shard>[0-9a-f]{2})(?:/|\$)!", $relPath, $m)) {
            $name .= '.' . $m['shard'];
        } else {
            throw new MWException("Can't determine shard of path '{$relPath}' for '{$wikiId}'.");
        }
    }
    try {
        $container = $conn->get_container($name);
    } catch (NoSuchContainerException $e) {
        // container not created yet
        $container = null;
        wfDebugLog('swiftThumb', "Could not access `{$name}`; container does not exist.");
    }
    return $container;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:40,代码来源:swift.php

示例5: connect

 public function connect()
 {
     App::import('Vendor', 'rackspace-php-cloudfiles-5b45176/cloudfiles');
     $auth = new CF_Authentication(Configure::read('Cloudfiles.username'), Configure::read('Cloudfiles.apikey'));
     $auth->authenticate();
     $conn = new CF_Connection($auth);
     return $conn;
 }
开发者ID:justinmc,项目名称:justinmccandless.com,代码行数:8,代码来源:Photo.php

示例6: initContainer

 protected function initContainer()
 {
     if (!$this->containerInitiated) {
         $auth = new \CF_Authentication($this->username, $this->apiKey);
         $auth->authenticate();
         $conn = new \CF_Connection($auth, $this->serviceNet);
         $container = $conn->get_container($this->name);
         parent::__construct($container->cfs_auth, $container->cfs_http, $container->name, $container->object_count, $container->bytes_used);
     }
     $this->containerInitiated = true;
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:11,代码来源:Container.php

示例7: authconn

 public function authconn($use_servicenet)
 {
     $auth = new CF_Authentication($this->authname, $this->authkey);
     try {
         $auth->authenticate();
     } catch (AuthenticationException $e) {
         //for some reason this returns two error msgs.  one is echo'd even without the below echo
         echo $e->getMessage();
         return false;
     }
     $this->conn = new CF_Connection($auth, $servicenet = $use_servicenet);
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:12,代码来源:loader.php

示例8: __construct

 public function __construct($config)
 {
     $return = parent::__construct($config);
     require_once 'cloudfiles.php';
     $auth = new CF_Authentication($this->config['rsc-username'], $this->config['rsc-apikey']);
     $auth->authenticate();
     $this->conn = new CF_Connection($auth);
     if ($this->config['rsc-ssl_use_cabundle']) {
         $this->conn->ssl_use_cabundle();
     }
     return $return;
 }
开发者ID:radumargina,项目名称:webstyle-antcr,代码行数:12,代码来源:filemanager.rsc.class.php

示例9: getConnection

function getConnection()
{
    require_once 'modulos/cdn/clases/cloudfiles.php';
    $username = "netor27";
    $api_key = "a4958be56757129de44332626cb0594b";
    $auth = new CF_Authentication($username, $api_key);
    $auth->authenticate();
    //Creamos una conexión
    //Si esta en el servidor con true
    //$conn = new CF_Connection($auth, TRUE);
    $conn = new CF_Connection($auth);
    return $conn;
}
开发者ID:netor27,项目名称:Unova,代码行数:13,代码来源:cdnModelo.php

示例10: 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

示例11: createSynchronizer

 public function createSynchronizer()
 {
     $username = sfConfig::get('app_rackspace_username');
     $key = sfConfig::get('app_rackspace_key');
     $containerName = sfConfig::get('app_rackspace_container');
     $webDir = sfConfig::get('sf_web_dir');
     $ttl = sfConfig::get('app_rackspace_ttl');
     $mimeTypeResolver = $this->get('mime_type_resolver');
     $dispatcher = $this->get('dispatcher');
     $this->logSection("rackspace", "Connecting '{$username}' to '{$containerName}'");
     $auth = new CF_Authentication($username, $key);
     $auth->authenticate();
     $conn = new CF_Connection($auth);
     $container = $conn->create_container($containerName);
     $synchronizer = new knpDmRackspaceSynchronizer($container, $webDir, $ttl, $mimeTypeResolver, $dispatcher);
     return $synchronizer;
 }
开发者ID:KnpLabs,项目名称:knpDmRackspacePlugin,代码行数:17,代码来源:knpDmRackspaceSyncFilesTask.class.php

示例12: 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

示例13: 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

示例14: createSynchronizer

 protected function createSynchronizer()
 {
     require_once dirname(__FILE__) . '/../vendor/rackspace/cloudfiles.php';
     $username = sfConfig::get('app_rackspace_username');
     $key = sfConfig::get('app_rackspace_key');
     $containerName = sfConfig::get('app_rackspace_container');
     $webDir = sfConfig::get('sf_web_dir');
     $ttl = sfConfig::get('app_rackspace_ttl');
     $mimeTypeResolver = $this->container->getService('mime_type_resolver');
     $dispatcher = $this->container->getService('dispatcher');
     $auth = new CF_Authentication($username, $key);
     $auth->authenticate();
     $conn = new CF_Connection($auth);
     $container = $conn->create_container($containerName);
     $synchronizer = new knpDmRackspaceSynchronizer($container, $webDir, $ttl, $mimeTypeResolver, $dispatcher);
     return $synchronizer;
 }
开发者ID:KnpLabs,项目名称:knpDmRackspacePlugin,代码行数:17,代码来源:knpDmRackspacePluginConfiguration.class.php

示例15: connect

 public function connect()
 {
     static $bConnected = false;
     if ($bConnected === true) {
         return;
     }
     require_once PHPFOX_DIR_LIB . 'rackspace/cloudfiles.php';
     $oAuth = new CF_Authentication(Phpfox::getParam('core.rackspace_username'), Phpfox::getParam('core.rackspace_key'));
     try {
         $oAuth->authenticate();
     } catch (Exception $e) {
         Phpfox_Error::trigger('Rackspace error: ' . $e->getMessage(), E_USER_ERROR);
     }
     $this->_oObject = new CF_Connection($oAuth);
     $this->_sBucket = Phpfox::getParam('core.rackspace_container');
     $this->_oContainer = $this->_oObject->get_container($this->_sBucket);
     $bConnected = true;
 }
开发者ID:laiello,项目名称:kr-indian,代码行数:18,代码来源:rackspace.class.php


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