/** * Factory method which allows for easy service creation * * @param ClientInterface $client * @return self */ public static function factory(ClientInterface $client) { $identity = new self(); if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) { $identity->setLogger($client->getLogger()); } $identity->setClient($client); $identity->setEndpoint(clone $client->getAuthUrl()); return $identity; }
/** * Factory method which allows for easy service creation * * @param ClientInterface $client * @return self */ public static function factory(\Guzzle\Http\ClientInterface $client) { $tempAuth = new self(); if (($client instanceof \OpenCloud\Common\Base || $client instanceof \OpenCloud\OpenStack) && $client->hasLogger()) { $tempAuth->setLogger($client->getLogger()); } $tempAuth->setClient($client); $tempAuth->setEndpoint(clone $client->getAuthUrl()); return $tempAuth; }
/** * Creates a service object, based off the specified client. * * The service's URL is defined in the client's serviceCatalog; it * uses the $type, $name, $region, and $urlType to find the proper endpoint * and set it. If it cannot find a URL in the service catalog that matches * the criteria, then an exception is thrown. * * @param Client $client Client object * @param string $type Service type (e.g. 'compute') * @param string $name Service name (e.g. 'cloudServersOpenStack') * @param string $region Service region (e.g. 'DFW', 'ORD', 'IAD', 'LON', 'SYD' or 'HKG') * @param string $urlType Either 'publicURL' or 'internalURL' */ public function __construct(ClientInterface $client, $type = null, $name = null, $region = null, $urlType = null) { if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) { $this->setLogger($client->getLogger()); } $this->setClient($client); $this->name = $name ?: static::DEFAULT_NAME; $this->region = $region; $this->region = $region; if ($this->regionless !== true && !$this->region) { throw new Exceptions\ServiceException(sprintf('The %s service must have a region set. You can either pass in a region string as an argument param, or' . ' set a default region for your user account by executing User::setDefaultRegion and ::update().', $this->name)); } $this->type = $type ?: static::DEFAULT_TYPE; $this->urlType = $urlType ?: static::DEFAULT_URL_TYPE; $this->setEndpoint($this->findEndpoint()); $this->client->setBaseUrl($this->getBaseUrl()); if ($this instanceof EventSubscriberInterface) { $this->client->getEventDispatcher()->addSubscriber($this); } }
/** * {@inheritDoc} */ public function setClient(ClientInterface $client) { // The Rackspace Cloud Databases service only supports the // RC4 SSL cipher which is not supported by modern OpenSSL clients. // Until the service can support additional, more modern and secure // ciphers, this SDK has to ask curl to allow using the weaker // cipher. For more information, see https://github.com/rackspace/php-opencloud/issues/560 $curlOptions = $client->getConfig()->get('curl.options'); $curlOptions['CURLOPT_SSL_CIPHER_LIST'] = static::getSslCipherList(); $client->getConfig()->set('curl.options', $curlOptions); $logMessage = 'The SDK is using a custom cipher suite when connecting ' . 'to the Rackspace Cloud Databases service. This suite contains ' . 'a weak cipher (RC4) so please use at your own risk. See ' . 'https://github.com/rackspace/php-opencloud/issues/560 for details.'; $client->getLogger()->critical($logMessage); $this->client = $client; }