protected function initializeObjectStorage() {

    $token = $this->cxt('token');

    $account = $this->cxt('account');
    // Legacy support for old 'key' param.
    $key = $this->cxt('key', $this->cxt('secret'));

    $tenantId = $this->cxt('tenantid');
    $tenantName = $this->cxt('tenantname');
    $authUrl = $this->cxt('endpoint');
    $endpoint = $this->cxt('swift_endpoint');
    $region = $this->cxt('region');

    $serviceCatalog = NULL;

    if (!empty($token) && isset(self::$serviceCatalogCache[$token])) {
      $serviceCatalog = self::$serviceCatalogCache[$token];
    }

    // FIXME: If a token is invalidated, we should try to re-authenticate.
    // If context has the info we need, start from there.
    if (!empty($token) && !empty($endpoint)) {
      $this->store = new \HPCloud\Storage\ObjectStorage($token, $endpoint);
    }
    // DEPRECATED: For old swift auth.
    elseif ($this->cxt('use_swift_auth', FALSE)) {
      if (empty($authUrl) || empty($account) || empty($key)) {
        throw new \HPCloud\Exception('account, endpoint, key are required stream parameters.');
      }
      $this->store = \HPCloud\Storage\ObjectStorage::newFromSwiftAuth($account, $key, $authUrl);

    }
    // If we get here and tenant ID is not set, we can't get a container.
    elseif (empty($tenantId) && empty($tenantName)) {
      throw new \HPCloud\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.');
    }
    elseif (empty($authUrl)) {
      throw new \HPCloud\Exception('An Identity Service Endpoint (endpoint) is required.');
    }
    // Try to authenticate and get a new token.
    else {
      $ident = $this->authenticate();

      // Update token and service catalog. The old pair may be out of date.
      $token = $ident->token();
      $serviceCatalog = $ident->serviceCatalog();
      self::$serviceCatalogCache[$token] = $serviceCatalog;

      $this->store = ObjectStorage::newFromServiceCatalog($serviceCatalog, $token, $region);

      /*
      $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE);
      if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) {
        //throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE));
        throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.');
      }
      $serviceURL = $catalog[0]['endpoints'][0]['publicURL'];

      $this->store = new ObjectStorage($token, $serviceURL);
       */
    }

    try {
      $this->initializeCDN($token, $serviceCatalog);
    }
    catch (\HPCloud\Exception $e) {
      //fwrite(STDOUT, $e);
      throw new \HPCloud\Exception('CDN could not be initialized', 1, $e);

    }

    return !empty($this->store);

  }
protected function initializeObjectStorage() {

    $token = $this->cxt('token');

    $account = $this->cxt('account');
    // Legacy support for old 'key' param.
    $key = $this->cxt('key', $this->cxt('secret'));

    $tenantId = $this->cxt('tenantid');
    $tenantName = $this->cxt('tenantname');
    $authUrl = $this->cxt('endpoint');
    $endpoint = $this->cxt('swift_endpoint');
    $region = $this->cxt('region');

    $serviceCatalog = NULL;

    if (!empty($token) && isset(self::$serviceCatalogCache[$token])) {
      $serviceCatalog = self::$serviceCatalogCache[$token];
    }

    // FIXME: If a token is invalidated, we should try to re-authenticate.
    // If context has the info we need, start from there.
    if (!empty($token) && !empty($endpoint)) {
      $this->store = new \HPCloud\Storage\ObjectStorage($token, $endpoint);
    }
    // DEPRECATED: For old swift auth.
    elseif ($this->cxt('use_swift_auth', FALSE)) {
      if (empty($authUrl) || empty($account) || empty($key)) {
        throw new \HPCloud\Exception('account, endpoint, key are required stream parameters.');
      }
      $this->store = \HPCloud\Storage\ObjectStorage::newFromSwiftAuth($account, $key, $authUrl);

    }
    // If we get here and tenant ID is not set, we can't get a container.
    elseif (empty($tenantId) && empty($tenantName)) {
      throw new \HPCloud\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.');
    }
    elseif (empty($authUrl)) {
      throw new \HPCloud\Exception('An Identity Service Endpoint (endpoint) is required.');
    }
    // Try to authenticate and get a new token.
    else {
      $ident = $this->authenticate();

      // Update token and service catalog. The old pair may be out of date.
      $token = $ident->token();
      $serviceCatalog = $ident->serviceCatalog();
      self::$serviceCatalogCache[$token] = $serviceCatalog;

      $this->store = ObjectStorage::newFromServiceCatalog($serviceCatalog, $token, $region);

      /*
      $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE);
      if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) {
        //throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE));
        throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.');
      }
      $serviceURL = $catalog[0]['endpoints'][0]['publicURL'];

      $this->store = new ObjectStorage($token, $serviceURL);
       */
    }

    try {
      $this->initializeCDN($token, $serviceCatalog);
    }
    catch (\HPCloud\Exception $e) {
      //fwrite(STDOUT, $e);
      throw new \HPCloud\Exception('CDN could not be initialized', 1, $e);

    }

    return !empty($this->store);

  }
protected function initializeObjectStorage ( ) { $ token = $ this -> cxt ( 'token' ) ; $ account = $ this -> cxt ( 'account' ) ; // Legacy support for old 'key' param. $ key = $ this -> cxt ( 'key' , $ this -> cxt ( 'secret' ) ) ; $ tenantId = $ this -> cxt ( 'tenantid' ) ; $ tenantName = $ this -> cxt ( 'tenantname' ) ; $ authUrl = $ this -> cxt ( 'endpoint' ) ; $ endpoint = $ this -> cxt ( 'swift_endpoint' ) ; $ region = $ this -> cxt ( 'region' ) ; $ serviceCatalog = NULL ; if ( ! empty ( $ token ) && isset ( self :: $ serviceCatalogCache [ $ token ] ) ) { $ serviceCatalog = self :: $ serviceCatalogCache [ $ token ] ; } // FIXME: If a token is invalidated, we should try to re-authenticate. // If context has the info we need, start from there. if ( ! empty ( $ token ) && ! empty ( $ endpoint ) ) { $ this -> store = new \ HPCloud \ Storage \ ObjectStorage ( $ token , $ endpoint ) ; } // DEPRECATED: For old swift auth. elseif ( $ this -> cxt ( 'use_swift_auth' , FALSE ) ) { if ( empty ( $ authUrl ) || empty ( $ account ) || empty ( $ key ) ) { throw new \ HPCloud \ Exception ( 'account, endpoint, key are required stream parameters.' ) ; } $ this -> store = \ HPCloud \ Storage \ ObjectStorage :: newFromSwiftAuth ( $ account , $ key , $ authUrl ) ; } // If we get here and tenant ID is not set, we can't get a container. elseif ( empty ( $ tenantId ) && empty ( $ tenantName ) ) { throw new \ HPCloud \ Exception ( 'Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.' ) ; } elseif ( empty ( $ authUrl ) ) { throw new \ HPCloud \ Exception ( 'An Identity Service Endpoint (endpoint) is required.' ) ; } // Try to authenticate and get a new token. else { $ ident = $ this -> authenticate ( ) ; // Update token and service catalog. The old pair may be out of date. $ token = $ ident -> token ( ) ; $ serviceCatalog = $ ident -> serviceCatalog ( ) ; self :: $ serviceCatalogCache [ $ token ] = $ serviceCatalog ; $ this -> store = ObjectStorage :: newFromServiceCatalog ( $ serviceCatalog , $ token , $ region ) ; /*
      $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE);
      if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) {
        //throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE));
        throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.');
      }
      $serviceURL = $catalog[0]['endpoints'][0]['publicURL'];

      $this->store = new ObjectStorage($token, $serviceURL);
       */ } try { $ this -> initializeCDN ( $ token , $ serviceCatalog ) ; } catch ( \ HPCloud \ Exception $ e ) { //fwrite(STDOUT, $e); throw new \ HPCloud \ Exception ( 'CDN could not be initialized' , 1 , $ e ) ; } return ! empty ( $ this -> store ) ; }
Based on the context, initialize the ObjectStorage.

The following parameters may be set either in the stream context
or through HPCloud::Bootstrap::setConfiguration():

- token: An auth token. If this is supplied, authentication is skipped and
this token is used. NOTE: You MUST set swift_endpoint if using this
option.
- swift_endpoint: The URL to the swift instance. This is only necessary if
'token' is set. Otherwise it is ignored.
- username: A username. MUST be accompanied by 'password' and 'tenantname'.
- password: A password. MUST be accompanied by 'username' and 'tenantname'.
- account: An account ID. MUST be accompanied by a 'secret' and 'tenantname'.
- secret: A secret key. MUST be accompanied by an 'account' and 'tenantname'.
- endpoint: The URL to the authentication endpoint. Necessary if you are not
using a 'token' and 'swift_endpoint'.
- use_swift_auth: If this is set to TRUE, it will force the app to use
the deprecated swiftAuth instead of IdentityServices authentication.
In general, you should avoid using this.

To find these params, the method first checks the supplied context. If the
key is not found there, it checks the Bootstrap::conf().

@param string $region
The region being used for this service.

@fixme This should be rewritten to use ObjectStorage::newFromServiceCatalog().
Based on the context initialize the ObjectStorage .