aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/aws-sdk-php/Aws/Common
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Aws/Common')
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Aws.php8
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/AbstractClient.php59
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/ClientBuilder.php83
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/DefaultClient.php55
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/UploadBodyListener.php12
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Command/AwsQueryVisitor.php27
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/Credentials.php219
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/NullCredentials.php68
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/ClientOptions.php5
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/Region.php5
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Exception/TransferException.php24
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/Facade.php2
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/facade-classes.php16
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/HostNameUtils.php4
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/InstanceMetadata/InstanceMetadataClient.php13
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIterator.php72
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIteratorFactory.php85
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Resources/aws-config.php53
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/AbstractSignature.php68
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureInterface.php15
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV2.php9
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3.php102
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3Https.php9
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV4.php356
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Waiter/AbstractWaiter.php10
25 files changed, 864 insertions, 515 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Aws.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Aws.php
index bd3175be591..1824e09c664 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Aws.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Aws.php
@@ -16,6 +16,7 @@
namespace Aws\Common;
+use Aws\Common\Facade\Facade;
use Guzzle\Service\Builder\ServiceBuilder;
use Guzzle\Service\Builder\ServiceBuilderLoader;
@@ -27,7 +28,7 @@ class Aws extends ServiceBuilder
/**
* @var string Current version of the SDK
*/
- const VERSION = '2.4.0';
+ const VERSION = '2.6.15';
/**
* Create a new service locator for the AWS SDK
@@ -97,10 +98,7 @@ class Aws extends ServiceBuilder
*/
public function enableFacades($namespace = null)
{
- $facadeClass = 'Aws\\Common\\Facade\\Facade';
- if (class_exists($facadeClass)) {
- $facadeClass::mountFacades($this, $namespace);
- }
+ Facade::mountFacades($this, $namespace);
return $this;
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/AbstractClient.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/AbstractClient.php
index 0187cdb15c3..0e2aa1a88ed 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/AbstractClient.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/AbstractClient.php
@@ -19,8 +19,10 @@ namespace Aws\Common\Client;
use Aws\Common\Aws;
use Aws\Common\Credentials\Credentials;
use Aws\Common\Credentials\CredentialsInterface;
+use Aws\Common\Credentials\NullCredentials;
use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Exception\InvalidArgumentException;
+use Aws\Common\Exception\TransferException;
use Aws\Common\Signature\EndpointSignatureInterface;
use Aws\Common\Signature\SignatureInterface;
use Aws\Common\Signature\SignatureListener;
@@ -29,6 +31,7 @@ use Aws\Common\Waiter\CompositeWaiterFactory;
use Aws\Common\Waiter\WaiterFactoryInterface;
use Aws\Common\Waiter\WaiterConfigFactory;
use Guzzle\Common\Collection;
+use Guzzle\Http\Exception\CurlException;
use Guzzle\Service\Client;
use Guzzle\Service\Description\ServiceDescriptionInterface;
@@ -82,7 +85,9 @@ abstract class AbstractClient extends Client implements AwsClientInterface
// Add the event listener so that requests are signed before they are sent
$dispatcher = $this->getEventDispatcher();
- $dispatcher->addSubscriber(new SignatureListener($credentials, $signature));
+ if (!$credentials instanceof NullCredentials) {
+ $dispatcher->addSubscriber(new SignatureListener($credentials, $signature));
+ }
if ($backoff = $config->get(Options::BACKOFF)) {
$dispatcher->addSubscriber($backoff, -255);
@@ -133,17 +138,11 @@ abstract class AbstractClient extends Client implements AwsClientInterface
return $scheme . '://' . $regions[$region]['hostname'];
}
- /**
- * {@inheritdoc}
- */
public function getCredentials()
{
return $this->credentials;
}
- /**
- * {@inheritdoc}
- */
public function setCredentials(CredentialsInterface $credentials)
{
$formerCredentials = $this->credentials;
@@ -158,33 +157,21 @@ abstract class AbstractClient extends Client implements AwsClientInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function getSignature()
{
return $this->signature;
}
- /**
- * {@inheritdoc}
- */
public function getRegions()
{
return $this->serviceDescription->getData('regions');
}
- /**
- * {@inheritdoc}
- */
public function getRegion()
{
return $this->getConfig(Options::REGION);
}
- /**
- * {@inheritdoc}
- */
public function setRegion($region)
{
$config = $this->getConfig();
@@ -214,9 +201,6 @@ abstract class AbstractClient extends Client implements AwsClientInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function waitUntil($waiter, array $input = array())
{
$this->getWaiter($waiter, $input)->wait();
@@ -224,9 +208,6 @@ abstract class AbstractClient extends Client implements AwsClientInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function getWaiter($waiter, array $input = array())
{
return $this->getWaiterFactory()->build($waiter)
@@ -234,9 +215,6 @@ abstract class AbstractClient extends Client implements AwsClientInterface
->setConfig($input);
}
- /**
- * {@inheritdoc}
- */
public function setWaiterFactory(WaiterFactoryInterface $waiterFactory)
{
$this->waiterFactory = $waiterFactory;
@@ -244,9 +222,6 @@ abstract class AbstractClient extends Client implements AwsClientInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function getWaiterFactory()
{
if (!$this->waiterFactory) {
@@ -256,18 +231,34 @@ abstract class AbstractClient extends Client implements AwsClientInterface
new WaiterClassFactory(substr($clientClass, 0, strrpos($clientClass, '\\')) . '\\Waiter')
));
if ($this->getDescription()) {
- $this->waiterFactory->addFactory(new WaiterConfigFactory($this->getDescription()->getData('waiters')));
+ $waiterConfig = $this->getDescription()->getData('waiters') ?: array();
+ $this->waiterFactory->addFactory(new WaiterConfigFactory($waiterConfig));
}
}
return $this->waiterFactory;
}
+ public function getApiVersion()
+ {
+ return $this->serviceDescription->getApiVersion();
+ }
+
/**
* {@inheritdoc}
+ * @throws \Aws\Common\Exception\TransferException
*/
- public function getApiVersion()
+ public function send($requests)
{
- return $this->serviceDescription->getApiVersion();
+ try {
+ return parent::send($requests);
+ } catch (CurlException $e) {
+ $wrapped = new TransferException($e->getMessage(), null, $e);
+ $wrapped->setCurlHandle($e->getCurlHandle())
+ ->setCurlInfo($e->getCurlInfo())
+ ->setError($e->getError(), $e->getErrorNo())
+ ->setRequest($e->getRequest());
+ throw $wrapped;
+ }
}
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/ClientBuilder.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/ClientBuilder.php
index 478aa0e0950..dd81cba2351 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/ClientBuilder.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/ClientBuilder.php
@@ -17,6 +17,8 @@
namespace Aws\Common\Client;
use Aws\Common\Credentials\Credentials;
+use Aws\Common\Credentials\CredentialsInterface;
+use Aws\Common\Credentials\NullCredentials;
use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Enum\Region;
use Aws\Common\Exception\ExceptionListener;
@@ -28,7 +30,6 @@ use Aws\Common\Iterator\AwsResourceIteratorFactory;
use Aws\Common\Signature\EndpointSignatureInterface;
use Aws\Common\Signature\SignatureInterface;
use Aws\Common\Signature\SignatureV2;
-use Aws\Common\Signature\SignatureV3;
use Aws\Common\Signature\SignatureV3Https;
use Aws\Common\Signature\SignatureV4;
use Guzzle\Common\Collection;
@@ -199,14 +200,10 @@ class ClientBuilder
(self::$commonConfigRequirements + $this->configRequirements)
);
- // Resolve endpoint and signature from the config and service description
+ // Resolve the endpoint, signature, and credentials
$description = $this->updateConfigFromDescription($config);
$signature = $this->getSignature($description, $config);
-
- // Resolve credentials
- if (!$credentials = $config->get('credentials')) {
- $credentials = Credentials::factory($config);
- }
+ $credentials = $this->getCredentials($config);
// Resolve exception parser
if (!$this->exceptionParser) {
@@ -221,10 +218,10 @@ class ClientBuilder
new TruncatedBackoffStrategy(3,
// Retry failed requests with 400-level responses due to throttling
new ThrottlingErrorChecker($this->exceptionParser,
- // Retry failed requests with 500-level responses
- new HttpBackoffStrategy(array(500, 503, 509),
- // Retry failed requests due to transient network or cURL problems
- new CurlBackoffStrategy(null,
+ // Retry failed requests due to transient network or cURL problems
+ new CurlBackoffStrategy(null,
+ // Retry failed requests with 500-level responses
+ new HttpBackoffStrategy(array(500, 503, 509),
// Retry requests that failed due to expired credentials
new ExpiredCredentialsChecker($this->exceptionParser,
new ExponentialBackoffStrategy()
@@ -402,7 +399,10 @@ class ClientBuilder
}
/**
- * Return an appropriate signature object for a a client based on a description
+ * Return an appropriate signature object for a a client based on the
+ * "signature" configuration setting, or the default signature specified in
+ * a service description. The signature can be set to a valid signature
+ * version identifier string or an instance of Aws\Common\Signature\SignatureInterface.
*
* @param ServiceDescription $description Description that holds a signature option
* @param Collection $config Configuration options
@@ -412,43 +412,50 @@ class ClientBuilder
*/
protected function getSignature(ServiceDescription $description, Collection $config)
{
- if (!$signature = $config->get(Options::SIGNATURE)) {
- switch ($description->getData('signatureVersion')) {
- case 'v2':
- $signature = new SignatureV2();
- break;
- case 'v3':
- $signature = new SignatureV3();
- break;
- case 'v3https':
- $signature = new SignatureV3Https();
- break;
- case 'v4':
- $signature = new SignatureV4();
- break;
- default:
- throw new InvalidArgumentException('Service description does not specify a valid signatureVersion');
+ // If a custom signature has not been provided, then use the default
+ // signature setting specified in the service description.
+ $signature = $config->get(Options::SIGNATURE) ?: $description->getData('signatureVersion');
+
+ if (is_string($signature)) {
+ if ($signature == 'v4') {
+ $signature = new SignatureV4();
+ } elseif ($signature == 'v2') {
+ $signature = new SignatureV2();
+ } elseif ($signature == 'v3https') {
+ $signature = new SignatureV3Https();
+ } else {
+ throw new InvalidArgumentException("Invalid signature type: {$signature}");
}
+ } elseif (!($signature instanceof SignatureInterface)) {
+ throw new InvalidArgumentException('The provided signature is not '
+ . 'a signature version string or an instance of '
+ . 'Aws\\Common\\Signature\\SignatureInterface');
}
// Allow a custom service name or region value to be provided
if ($signature instanceof EndpointSignatureInterface) {
// Determine the service name to use when signing
- if (!$service = $config->get(Options::SIGNATURE_SERVICE)) {
- if (!$service = $description->getData('signingName')) {
- $service = $description->getData('endpointPrefix');
- }
- }
- $signature->setServiceName($service);
+ $signature->setServiceName($config->get(Options::SIGNATURE_SERVICE)
+ ?: $description->getData('signingName')
+ ?: $description->getData('endpointPrefix'));
// Determine the region to use when signing requests
- if (!$region = $config->get(Options::SIGNATURE_REGION)) {
- $region = $config->get(Options::REGION);
- }
- $signature->setRegionName($region);
+ $signature->setRegionName($config->get(Options::SIGNATURE_REGION) ?: $config->get(Options::REGION));
}
return $signature;
}
+
+ protected function getCredentials(Collection $config)
+ {
+ $credentials = $config->get(Options::CREDENTIALS);
+ if ($credentials === false) {
+ $credentials = new NullCredentials();
+ } elseif (!$credentials instanceof CredentialsInterface) {
+ $credentials = Credentials::factory($config);
+ }
+
+ return $credentials;
+ }
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/DefaultClient.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/DefaultClient.php
index 4bc257a4e94..1dc276d3ccb 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/DefaultClient.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/DefaultClient.php
@@ -29,38 +29,29 @@ class DefaultClient extends AbstractClient
*
* The following array keys and values are available options:
*
- * - Credential options (`key`, `secret`, and optional `token` OR `credentials` is required)
- * - key: AWS Access Key ID
- * - secret: AWS secret access key
- * - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
- * - token: Custom AWS security token to use with request authentication
- * - token.ttd: UNIX timestamp for when the custom credentials expire
- * - credentials.cache: Used to cache credentials when using providers that require HTTP requests. Set the true
- * to use the default APC cache or provide a `Guzzle\Cache\CacheAdapterInterface` object.
- * - credentials.cache.key: Optional custom cache key to use with the credentials
- * - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your
- * credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
- * - Region and Endpoint options (a `region` and optional `scheme` OR a `base_url` is required)
- * - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
- * - scheme: URI Scheme of the base URL (e.g. 'https', 'http').
- * - service: Specify the name of the service
- * - base_url: Instead of using a `region` and `scheme`, you can specify a custom base URL for the client
- * - Signature options
- * - signature: You can optionally provide a custom signature implementation used to sign requests
- * - signature.service: Set to explicitly override the service name used in signatures
- * - signature.region: Set to explicitly override the region name used in signatures
- * - Exponential backoff options
- * - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use
- * 'debug' to emit PHP warnings when a retry is issued.
- * - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See
- * `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
- * - Generic client options
- * - ssl.certificate_authority: Set to true to use the bundled CA cert (default), system to use the certificate
- * bundled with your system, or pass the full path to an SSL certificate bundle. This option should be used
- * when you encounter curl error code 60.
- * - curl.CURLOPT_VERBOSE: Set to true to output curl debug information during transfers
- * - curl.*: Prefix any available cURL option with `curl.` to add cURL options to each request.
- * See: http://www.php.net/manual/en/function.curl-setopt.php
+ * Credential options ((`key`, `secret`, and optional `token`) OR `credentials` is required):
+ *
+ * - key: AWS Access Key ID
+ * - secret: AWS secret access key
+ * - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
+ * - token: Custom AWS security token to use with request authentication. Please note that not all services accept temporary credentials. See http://docs.aws.amazon.com/STS/latest/UsingSTS/UsingTokens.html
+ * - token.ttd: UNIX timestamp for when the custom credentials expire
+ * - credentials.cache.key: Optional custom cache key to use with the credentials
+ * - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
+ *
+ * Region and endpoint options (Some services do not require a region while others do. Check the service specific user guide documentation for details):
+ *
+ * - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
+ * - scheme: URI Scheme of the base URL (e.g. 'https', 'http') used when base_url is not supplied
+ * - base_url: Allows you to specify a custom endpoint instead of building one from the region and scheme
+ *
+ * Generic client options:
+ *
+ * - signature: Overrides the signature used by the client. Clients will always choose an appropriate default signature. However, it can be useful to override this with a custom setting. This can be set to "v4", "v3https", "v2" or an instance of Aws\Common\Signature\SignatureInterface.
+ * - ssl.certificate_authority: Set to true to use the bundled CA cert or pass the full path to an SSL certificate bundle
+ * - curl.options: Associative of CURLOPT_* cURL options to add to each request
+ * - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use 'debug' to emit PHP warnings when a retry is issued.
+ * - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
*
* @param array|Collection $config Client configuration data
*
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/UploadBodyListener.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/UploadBodyListener.php
index e559d4826a6..a99d2fa910c 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/UploadBodyListener.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Client/UploadBodyListener.php
@@ -16,6 +16,7 @@
namespace Aws\Common\Client;
+use Aws\Common\Exception\InvalidArgumentException;
use Guzzle\Common\Event;
use Guzzle\Http\EntityBody;
use Guzzle\Service\Command\AbstractCommand as Command;
@@ -66,6 +67,7 @@ class UploadBodyListener implements EventSubscriberInterface
* Converts filenames and file handles into EntityBody objects before the command is validated
*
* @param Event $event Event emitted
+ * @throws InvalidArgumentException
*/
public function onCommandBeforePrepare(Event $event)
{
@@ -81,13 +83,13 @@ class UploadBodyListener implements EventSubscriberInterface
$body = fopen($source, 'r');
}
+ // Prepare the body parameter and remove the source file parameter
if (null !== $body) {
- $body = EntityBody::factory($body);
+ $command->remove($this->sourceParameter);
+ $command->set($this->bodyParameter, EntityBody::factory($body));
+ } else {
+ throw new InvalidArgumentException("You must specify a non-null value for the {$this->bodyParameter} or {$this->sourceParameter} parameters.");
}
-
- // Prepare the body parameter and remove the source file parameter
- $command->remove($this->sourceParameter);
- $command->set($this->bodyParameter, $body);
}
}
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Command/AwsQueryVisitor.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Command/AwsQueryVisitor.php
index b6d14099eec..dceaafaafc1 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Command/AwsQueryVisitor.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Command/AwsQueryVisitor.php
@@ -12,11 +12,11 @@ use Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor;
*/
class AwsQueryVisitor extends AbstractRequestVisitor
{
- /**
- * {@inheritdoc}
- */
+ private $fqname;
+
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
+ $this->fqname = $command->getName();
$query = array();
$this->customResolver($value, $param, $query, $param->getWireName());
$request->addPostFields($query);
@@ -66,8 +66,11 @@ class AwsQueryVisitor extends AbstractRequestVisitor
} elseif ($hasAdditionalProperties) {
// Handle map cases like &Attribute.1.Name=<name>&Attribute.1.Value=<value>
$additionalPropertyCount++;
- $query["{$prefix}.{$additionalPropertyCount}.Name"] = $name;
- $newPrefix = "{$prefix}.{$additionalPropertyCount}.Value";
+ $data = $param->getData();
+ $keyName = isset($data['keyName']) ? $data['keyName'] : 'key';
+ $valueName = isset($data['valueName']) ? $data['valueName'] : 'value';
+ $query["{$prefix}.{$additionalPropertyCount}.{$keyName}"] = $name;
+ $newPrefix = "{$prefix}.{$additionalPropertyCount}.{$valueName}";
if (is_array($v)) {
$this->customResolver($v, $param->getAdditionalProperties(), $query, $newPrefix);
} else {
@@ -87,6 +90,20 @@ class AwsQueryVisitor extends AbstractRequestVisitor
*/
protected function resolveArray(Parameter $param, array $value, $prefix, array &$query)
{
+ static $serializeEmpty = array(
+ 'SetLoadBalancerPoliciesForBackendServer' => 1,
+ 'SetLoadBalancerPoliciesOfListener' => 1,
+ 'UpdateStack' => 1
+ );
+
+ // For BC, serialize empty lists for specific operations
+ if (!$value) {
+ if (isset($serializeEmpty[$this->fqname])) {
+ $query[$prefix] = '';
+ }
+ return;
+ }
+
$offset = $param->getData('offset') ?: 1;
foreach ($value as $index => $v) {
$index += $offset;
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/Credentials.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/Credentials.php
index dfb19c94224..73b8ffa0005 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/Credentials.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/Credentials.php
@@ -20,10 +20,10 @@ use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Exception\InvalidArgumentException;
use Aws\Common\Exception\RequiredExtensionNotLoadedException;
use Aws\Common\Exception\RuntimeException;
-use Guzzle\Http\ClientInterface;
use Guzzle\Common\FromConfigInterface;
use Guzzle\Cache\CacheAdapterInterface;
use Guzzle\Cache\DoctrineCacheAdapter;
+use Guzzle\Common\Collection;
/**
* Basic implementation of the AWSCredentials interface that allows callers to
@@ -33,25 +33,19 @@ class Credentials implements CredentialsInterface, FromConfigInterface
{
const ENV_KEY = 'AWS_ACCESS_KEY_ID';
const ENV_SECRET = 'AWS_SECRET_KEY';
+ const ENV_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY';
+ const ENV_PROFILE = 'AWS_PROFILE';
- /**
- * @var string AWS Access key ID
- */
+ /** @var string AWS Access Key ID */
protected $key;
- /**
- * @var string AWS Secret access key
- */
+ /** @var string AWS Secret Access Key */
protected $secret;
- /**
- * @var string Security token
- */
+ /** @var string AWS Security Token */
protected $token;
- /**
- * @var int Time to die of token
- */
+ /** @var int Time to die of token */
protected $ttd;
/**
@@ -66,6 +60,7 @@ class Credentials implements CredentialsInterface, FromConfigInterface
Options::SECRET => null,
Options::TOKEN => null,
Options::TOKEN_TTD => null,
+ Options::PROFILE => null,
Options::CREDENTIALS_CACHE => null,
Options::CREDENTIALS_CACHE_KEY => null,
Options::CREDENTIALS_CLIENT => null
@@ -97,19 +92,7 @@ class Credentials implements CredentialsInterface, FromConfigInterface
// Create the credentials object
if (!$config[Options::KEY] || !$config[Options::SECRET]) {
- // No keys were provided, so attempt to retrieve some from the environment
- $envKey = isset($_SERVER[self::ENV_KEY]) ? $_SERVER[self::ENV_KEY] : getenv(self::ENV_KEY);
- $envSecret = isset($_SERVER[self::ENV_SECRET]) ? $_SERVER[self::ENV_SECRET] : getenv(self::ENV_SECRET);
- if ($envKey && $envSecret) {
- // Use credentials set in the environment variables
- $credentials = new static($envKey, $envSecret);
- } else {
- // Use instance profile credentials (available on EC2 instances)
- $credentials = new RefreshableInstanceProfileCredentials(
- new static('', '', '', 1),
- $config[Options::CREDENTIALS_CLIENT]
- );
- }
+ $credentials = self::createFromEnvironment($config);
// If no cache key was set, use the crc32 hostname of the server
$cacheKey = $cacheKey ?: 'credentials_' . crc32(gethostname());
} else {
@@ -127,32 +110,57 @@ class Credentials implements CredentialsInterface, FromConfigInterface
// Check if the credentials are refreshable, and if so, configure caching
$cache = $config[Options::CREDENTIALS_CACHE];
if ($cacheKey && $cache) {
- if ($cache === 'true' || $cache === true) {
- // If no cache adapter was provided, then create one for the user
- // @codeCoverageIgnoreStart
- if (!extension_loaded('apc')) {
- throw new RequiredExtensionNotLoadedException('PHP has not been compiled with APC. Unable to cache '
- . 'the credentials.');
- } elseif (!class_exists('Doctrine\Common\Cache\ApcCache')) {
- throw new RuntimeException(
- 'Cannot set ' . Options::CREDENTIALS_CACHE . ' to true because the Doctrine cache component is '
- . 'not installed. Either install doctrine/cache or pass in an instantiated '
- . 'Guzzle\Cache\CacheAdapterInterface object'
- );
- }
- // @codeCoverageIgnoreEnd
- $cache = new DoctrineCacheAdapter(new \Doctrine\Common\Cache\ApcCache());
- } elseif (!($cache instanceof CacheAdapterInterface)) {
- throw new InvalidArgumentException('Unable to utilize caching with the specified options');
- }
- // Decorate the credentials with a cache
- $credentials = new CacheableCredentials($credentials, $cache, $cacheKey);
+ $credentials = self::createCache($credentials, $cache, $cacheKey);
}
return $credentials;
}
/**
+ * Create credentials from the credentials ini file in the HOME directory.
+ *
+ * @param string|null $profile Pass a specific profile to use. If no
+ * profile is specified we will attempt to use
+ * the value specified in the AWS_PROFILE
+ * environment variable. If AWS_PROFILE is not
+ * set, the "default" profile is used.
+ * @param string|null $filename Pass a string to specify the location of the
+ * credentials files. If null is passed, the
+ * SDK will attempt to find the configuration
+ * file at in your HOME directory at
+ * ~/.aws/credentials.
+ * @return CredentialsInterface
+ * @throws \RuntimeException if the file cannot be found, if the file is
+ * invalid, or if the profile is invalid.
+ */
+ public static function fromIni($profile = null, $filename = null)
+ {
+ if (!$filename) {
+ $filename = self::getHomeDir() . '/.aws/credentials';
+ }
+
+ if (!$profile) {
+ $profile = self::getEnvVar(self::ENV_PROFILE) ?: 'default';
+ }
+
+ if (!file_exists($filename) || !($data = parse_ini_file($filename, true))) {
+ throw new \RuntimeException("Invalid AWS credentials file: {$filename}.");
+ }
+
+ if (empty($data[$profile])) {
+ throw new \RuntimeException("Invalid AWS credentials profile {$profile} in {$filename}.");
+ }
+
+ return new self(
+ $data[$profile]['aws_access_key_id'],
+ $data[$profile]['aws_secret_access_key'],
+ isset($data[$profile]['aws_security_token'])
+ ? $data[$profile]['aws_security_token']
+ : null
+ );
+ }
+
+ /**
* Constructs a new BasicAWSCredentials object, with the specified AWS
* access key and AWS secret key
*
@@ -169,9 +177,6 @@ class Credentials implements CredentialsInterface, FromConfigInterface
$this->ttd = $expiration;
}
- /**
- * {@inheritdoc}
- */
public function serialize()
{
return json_encode(array(
@@ -182,9 +187,6 @@ class Credentials implements CredentialsInterface, FromConfigInterface
));
}
- /**
- * {@inheritdoc}
- */
public function unserialize($serialized)
{
$data = json_decode($serialized, true);
@@ -194,49 +196,31 @@ class Credentials implements CredentialsInterface, FromConfigInterface
$this->ttd = $data[Options::TOKEN_TTD];
}
- /**
- * {@inheritdoc}
- */
public function getAccessKeyId()
{
return $this->key;
}
- /**
- * {@inheritdoc}
- */
public function getSecretKey()
{
return $this->secret;
}
- /**
- * {@inheritdoc}
- */
public function getSecurityToken()
{
return $this->token;
}
- /**
- * {@inheritdoc}
- */
public function getExpiration()
{
return $this->ttd;
}
- /**
- * {@inheritdoc}
- */
public function isExpired()
{
return $this->ttd !== null && time() >= $this->ttd;
}
- /**
- * {@inheritdoc}
- */
public function setAccessKeyId($key)
{
$this->key = $key;
@@ -244,9 +228,6 @@ class Credentials implements CredentialsInterface, FromConfigInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function setSecretKey($secret)
{
$this->secret = $secret;
@@ -254,9 +235,6 @@ class Credentials implements CredentialsInterface, FromConfigInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function setSecurityToken($token)
{
$this->token = $token;
@@ -264,13 +242,96 @@ class Credentials implements CredentialsInterface, FromConfigInterface
return $this;
}
- /**
- * {@inheritdoc}
- */
public function setExpiration($timestamp)
{
$this->ttd = $timestamp;
return $this;
}
+
+ /**
+ * When no keys are provided, attempt to create them based on the
+ * environment or instance profile credentials.
+ *
+ * @param array|Collection $config
+ *
+ * @return CredentialsInterface
+ */
+ private static function createFromEnvironment($config)
+ {
+ // Get key and secret from ENV variables
+ $envKey = self::getEnvVar(self::ENV_KEY);
+ if (!($envSecret = self::getEnvVar(self::ENV_SECRET))) {
+ // Use AWS_SECRET_ACCESS_KEY if AWS_SECRET_KEY was not set.
+ $envSecret = self::getEnvVar(self::ENV_SECRET_ACCESS_KEY);
+ }
+
+ // Use credentials from the environment variables if available
+ if ($envKey && $envSecret) {
+ return new static($envKey, $envSecret);
+ }
+
+ // Use credentials from the ini file in HOME directory if available
+ $home = self::getHomeDir();
+ if ($home && file_exists("{$home}/.aws/credentials")) {
+ return self::fromIni($config[Options::PROFILE], "{$home}/.aws/credentials");
+ }
+
+ // Use instance profile credentials (available on EC2 instances)
+ return new RefreshableInstanceProfileCredentials(
+ new static('', '', '', 1),
+ $config[Options::CREDENTIALS_CLIENT]
+ );
+ }
+
+ private static function createCache(CredentialsInterface $credentials, $cache, $cacheKey)
+ {
+ if ($cache === 'true' || $cache === true) {
+ // If no cache adapter was provided, then create one for the user
+ // @codeCoverageIgnoreStart
+ if (!extension_loaded('apc')) {
+ throw new RequiredExtensionNotLoadedException('PHP has not been compiled with APC. Unable to cache '
+ . 'the credentials.');
+ } elseif (!class_exists('Doctrine\Common\Cache\ApcCache')) {
+ throw new RuntimeException(
+ 'Cannot set ' . Options::CREDENTIALS_CACHE . ' to true because the Doctrine cache component is '
+ . 'not installed. Either install doctrine/cache or pass in an instantiated '
+ . 'Guzzle\Cache\CacheAdapterInterface object'
+ );
+ }
+ // @codeCoverageIgnoreEnd
+ $cache = new DoctrineCacheAdapter(new \Doctrine\Common\Cache\ApcCache());
+ } elseif (!($cache instanceof CacheAdapterInterface)) {
+ throw new InvalidArgumentException('Unable to utilize caching with the specified options');
+ }
+
+ // Decorate the credentials with a cache
+ return new CacheableCredentials($credentials, $cache, $cacheKey);
+ }
+
+ private static function getHomeDir()
+ {
+ // On Linux/Unix-like systems, use the HOME environment variable
+ if ($homeDir = self::getEnvVar('HOME')) {
+ return $homeDir;
+ }
+
+ // Get the HOMEDRIVE and HOMEPATH values for Windows hosts
+ $homeDrive = self::getEnvVar('HOMEDRIVE');
+ $homePath = self::getEnvVar('HOMEPATH');
+
+ return ($homeDrive && $homePath) ? $homeDrive . $homePath : null;
+ }
+
+ /**
+ * Fetches the value of an environment variable by checking $_SERVER and getenv().
+ *
+ * @param string $var Name of the environment variable
+ *
+ * @return mixed|null
+ */
+ private static function getEnvVar($var)
+ {
+ return isset($_SERVER[$var]) ? $_SERVER[$var] : getenv($var);
+ }
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/NullCredentials.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/NullCredentials.php
new file mode 100644
index 00000000000..0656c391906
--- /dev/null
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Credentials/NullCredentials.php
@@ -0,0 +1,68 @@
+<?php
+namespace Aws\Common\Credentials;
+
+/**
+ * A blank set of credentials. AWS clients must be provided credentials, but
+ * there are some types of requests that do not need authentication. This class
+ * can be used to pivot on that scenario, and also serve as a mock credentials
+ * object when testing
+ *
+ * @codeCoverageIgnore
+ */
+class NullCredentials implements CredentialsInterface
+{
+ public function getAccessKeyId()
+ {
+ return '';
+ }
+
+ public function getSecretKey()
+ {
+ return '';
+ }
+
+ public function getSecurityToken()
+ {
+ return null;
+ }
+
+ public function getExpiration()
+ {
+ return null;
+ }
+
+ public function isExpired()
+ {
+ return false;
+ }
+
+ public function serialize()
+ {
+ return 'N;';
+ }
+
+ public function unserialize($serialized)
+ {
+ // Nothing to do here.
+ }
+
+ public function setAccessKeyId($key)
+ {
+ // Nothing to do here.
+ }
+
+ public function setSecretKey($secret)
+ {
+ // Nothing to do here.
+ }
+
+ public function setSecurityToken($token)
+ {
+ // Nothing to do here.
+ }
+
+ public function setExpiration($timestamp)
+ {
+ // Nothing to do here.
+ }
+}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/ClientOptions.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/ClientOptions.php
index 5a94adcffcb..4027cae0b4a 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/ClientOptions.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/ClientOptions.php
@@ -39,6 +39,11 @@ class ClientOptions extends Enum
const CREDENTIALS = 'credentials';
/**
+ * @var string Name of a credential profile to read from your ~/.aws/credentials file
+ */
+ const PROFILE = 'profile';
+
+ /**
* @var string Custom AWS security token to use with request authentication
*/
const TOKEN = 'token';
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/Region.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/Region.php
index 4cbcef902d3..b44bd971beb 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/Region.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Enum/Region.php
@@ -22,7 +22,7 @@ use Aws\Common\Enum;
* Contains enumerable region code values. These should be useful in most cases,
* with Amazon S3 being the most notable exception
*
- * @link http://docs.amazonwebservices.com/general/latest/gr/rande.html AWS Regions and Endpoints
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html AWS Regions and Endpoints
*/
class Region extends Enum
{
@@ -52,6 +52,9 @@ class Region extends Enum
const SA_EAST_1 = 'sa-east-1';
const SAO_PAULO = 'sa-east-1';
+ const CN_NORTH_1 = 'cn-north-1';
+ const BEIJING = 'cn-north-1';
+
const US_GOV_WEST_1 = 'us-gov-west-1';
const GOV_CLOUD_US = 'us-gov-west-1';
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Exception/TransferException.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Exception/TransferException.php
new file mode 100644
index 00000000000..47aa80d192b
--- /dev/null
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Exception/TransferException.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Aws\Common\Exception;
+
+use Guzzle\Http\Exception\CurlException;
+
+/**
+ * Transfer request exception
+ */
+class TransferException extends CurlException implements AwsExceptionInterface {}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/Facade.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/Facade.php
index 3a13e4d4d9d..03797732841 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/Facade.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/Facade.php
@@ -41,7 +41,7 @@ abstract class Facade implements FacadeInterface
if (isset($service['alias'], $service['class'])) {
$facadeClass = __NAMESPACE__ . '\\' . $service['alias'];
$facadeAlias = ltrim($targetNamespace . '\\' . $service['alias'], '\\');
- if (!class_exists($facadeAlias)) {
+ if (!class_exists($facadeAlias) && class_exists($facadeClass)) {
// @codeCoverageIgnoreStart
class_alias($facadeClass, $facadeAlias);
// @codeCoverageIgnoreEnd
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/facade-classes.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/facade-classes.php
index 5cb8e10b7cc..b1041902be7 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/facade-classes.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Facade/facade-classes.php
@@ -56,6 +56,14 @@ class CloudSearch extends Facade
}
}
+class CloudTrail extends Facade
+{
+ public static function getServiceBuilderKey()
+ {
+ return 'cloudtrail';
+ }
+}
+
class CloudWatch extends Facade
{
public static function getServiceBuilderKey()
@@ -160,6 +168,14 @@ class ImportExport extends Facade
}
}
+class Kinesis extends Facade
+{
+ public static function getServiceBuilderKey()
+ {
+ return 'kinesis';
+ }
+}
+
class OpsWorks extends Facade
{
public static function getServiceBuilderKey()
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/HostNameUtils.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/HostNameUtils.php
index 460bc770a12..4b791aa0be5 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/HostNameUtils.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/HostNameUtils.php
@@ -33,7 +33,7 @@ class HostNameUtils
* @param Url $url HTTP URL
*
* @return string
- * @link http://docs.amazonwebservices.com/general/latest/gr/rande.html
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html
*/
public static function parseRegionName(Url $url)
{
@@ -68,7 +68,7 @@ class HostNameUtils
* @param Url $url HTTP URL
*
* @return string Returns a service name (or empty string)
- * @link http://docs.amazonwebservices.com/general/latest/gr/rande.html
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html
*/
public static function parseServiceName(Url $url)
{
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/InstanceMetadata/InstanceMetadataClient.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/InstanceMetadata/InstanceMetadataClient.php
index 4a2e6333829..229be1581e8 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/InstanceMetadata/InstanceMetadataClient.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/InstanceMetadata/InstanceMetadataClient.php
@@ -45,6 +45,10 @@ class InstanceMetadataClient extends AbstractClient
$config = Collection::fromConfig($config, array(
Options::BASE_URL => 'http://169.254.169.254/{version}/',
'version' => 'latest',
+ 'request.options' => array(
+ 'connect_timeout' => 5,
+ 'timeout' => 10
+ )
), array('base_url', 'version'));
return new self($config);
@@ -71,15 +75,14 @@ class InstanceMetadataClient extends AbstractClient
{
try {
$request = $this->get('meta-data/iam/security-credentials/');
- $request->getCurlOptions()->set(CURLOPT_TIMEOUT, 1)->set(CURLOPT_CONNECTTIMEOUT, 1);
$credentials = trim($request->send()->getBody(true));
$result = $this->get("meta-data/iam/security-credentials/{$credentials}")->send()->json();
} catch (\Exception $e) {
- $message = 'Error retrieving credentials from the instance profile metadata server. When you are not'
- . ' running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in'
+ $message = sprintf('Error retrieving credentials from the instance profile metadata server. When you are'
+ . ' not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in'
. ' the "key" and "secret" options when creating a client or provide an instantiated'
- . ' Aws\\Common\\Credentials\\CredentialsInterface object.';
- throw new InstanceProfileCredentialsException($message, $e->getCode(), $e);
+ . ' Aws\\Common\\Credentials\\CredentialsInterface object. (%s)', $e->getMessage());
+ throw new InstanceProfileCredentialsException($message, $e->getCode());
}
// Ensure that the status code was successful
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIterator.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIterator.php
index a384617b51c..cdd81199853 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIterator.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIterator.php
@@ -32,7 +32,8 @@ class AwsResourceIterator extends ResourceIterator
protected $lastResult = null;
/**
- * Provides access to the most recent result obtained by the iterator.
+ * Provides access to the most recent result obtained by the iterator. This makes it easier to extract any
+ * additional information from the result which you do not have access to from the values emitted by the iterator
*
* @return Model|null
*/
@@ -71,45 +72,37 @@ class AwsResourceIterator extends ResourceIterator
return $resources;
}
- /**
- * {@inheritdoc}
- */
protected function prepareRequest()
{
// Get the limit parameter key to set
- $param = $this->get('limit_param');
- if ($param && ($limit = $this->command->get($param))) {
+ $limitKey = $this->get('limit_key');
+ if ($limitKey && ($limit = $this->command->get($limitKey))) {
$pageSize = $this->calculatePageSize();
// If the limit of the command is different than the pageSize of the iterator, use the smaller value
if ($limit && $pageSize) {
- $this->command->set('limit', min($limit, $pageSize));
+ $realLimit = min($limit, $pageSize);
+ $this->command->set($limitKey, $realLimit);
}
}
}
- /**
- * {@inheritdoc}
- */
protected function handleResults(Model $result)
{
$results = array();
// Get the result key that contains the results
if ($resultKey = $this->get('result_key')) {
- $results = $result->getPath($resultKey) ?: array();
+ $results = $this->getValueFromResult($result, $resultKey) ?: array();
}
return $results;
}
- /**
- * {@inheritdoc}
- */
protected function applyNextToken()
{
// Get the token parameter key to set
- if ($tokenParam = $this->get('token_param')) {
+ if ($tokenParam = $this->get('input_token')) {
// Set the next token. Works with multi-value tokens
if (is_array($tokenParam)) {
if (is_array($this->nextToken) && count($tokenParam) === count($this->nextToken)) {
@@ -126,24 +119,51 @@ class AwsResourceIterator extends ResourceIterator
}
}
- /**
- * {@inheritdoc}
- */
protected function determineNextToken(Model $result)
{
$this->nextToken = null;
- // If the value of "more key" is true or there is no "more key" to check, then try to get the next token
- $moreKey = $this->get('more_key');
- if ($moreKey === null || $result->getPath($moreKey)) {
+ // If the value of "more_results" is true or there is no "more_results" to check, then try to get the next token
+ $moreKey = $this->get('more_results');
+ if ($moreKey === null || $this->getValueFromResult($result, $moreKey)) {
// Get the token key to check
- if ($tokenKey = $this->get('token_key')) {
+ if ($tokenKey = $this->get('output_token')) {
// Get the next token's value. Works with multi-value tokens
- $getToken = function ($key) use ($result) {
- return $result->getPath((string) $key);
- };
- $this->nextToken = is_array($tokenKey) ? array_map($getToken, $tokenKey) : $getToken($tokenKey);
+ if (is_array($tokenKey)) {
+ $this->nextToken = array();
+ foreach ($tokenKey as $key) {
+ $this->nextToken[] = $this->getValueFromResult($result, $key);
+ }
+ } else {
+ $this->nextToken = $this->getValueFromResult($result, $tokenKey);
+ }
+ }
+ }
+ }
+
+ /**
+ * Extracts the value from the result using Collection::getPath. Also adds some additional logic for keys that need
+ * to access n-1 indexes (e.g., ImportExport, Kinesis). The n-1 logic only works for the known cases. We will switch
+ * to a jmespath implementation in the future to cover all cases
+ *
+ * @param Model $result
+ * @param string $key
+ *
+ * @return mixed|null
+ */
+ protected function getValueFromResult(Model $result, $key)
+ {
+ // Special handling for keys that need to access n-1 indexes
+ if (strpos($key, '#') !== false) {
+ $keyParts = explode('#', $key, 2);
+ $items = $result->getPath(trim($keyParts[0], '/'));
+ if ($items && is_array($items)) {
+ $index = count($items) - 1;
+ $key = strtr($key, array('#' => $index));
}
}
+
+ // Get the value
+ return $result->getPath($key);
}
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIteratorFactory.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIteratorFactory.php
index 1d4ac279d5e..ce668a289c4 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIteratorFactory.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Iterator/AwsResourceIteratorFactory.php
@@ -16,24 +16,28 @@ class AwsResourceIteratorFactory implements ResourceIteratorFactoryInterface
/**
* @var array Default configuration values for iterators
*/
- protected static $defaultConfig = array(
- 'limit_key' => null,
- 'limit_param' => null,
- 'more_key' => null,
- 'token_key' => null,
- 'token_param' => null,
- 'operations' => array(),
+ protected static $defaultIteratorConfig = array(
+ 'input_token' => null,
+ 'output_token' => null,
+ 'limit_key' => null,
+ 'result_key' => null,
+ 'more_results' => null,
);
/**
- * @var Collection The configuration for the iterators
+ * @var array Legacy configuration options mapped to their new names
*/
- protected $config;
+ private static $legacyConfigOptions = array(
+ 'token_param' => 'input_token',
+ 'token_key' => 'output_token',
+ 'limit_param' => 'limit_key',
+ 'more_key' => 'more_results',
+ );
/**
- * @var Collection Additional configurations for specific iterators
+ * @var array Iterator configuration for each iterable operation
*/
- protected $operations;
+ protected $config;
/**
* @var ResourceIteratorFactoryInterface Another factory that will be used first to instantiate the iterator
@@ -43,59 +47,60 @@ class AwsResourceIteratorFactory implements ResourceIteratorFactoryInterface
/**
* @param array $config An array of configuration values for the factory
* @param ResourceIteratorFactoryInterface $primaryIteratorFactory Another factory to use for chain of command
- *
- * @throws InvalidArgumentException
*/
public function __construct(array $config, ResourceIteratorFactoryInterface $primaryIteratorFactory = null)
{
$this->primaryIteratorFactory = $primaryIteratorFactory;
- // Set up the config with default values
- $this->config = Collection::fromConfig($config, self::$defaultConfig);
-
- // Pull out the operation-specific configurations
- $this->operations = new Collection();
- $potentialOperations = $this->config->get('operations') ?: array();
- $this->config->remove('operations');
- foreach ($potentialOperations as $key => $value) {
- if (is_int($key) && is_string($value)) {
- $this->operations->set($value, array());
- } elseif (is_string($key) && is_array($value)) {
- $this->operations->set($key, $value);
- } else {
- throw new InvalidArgumentException('The iterator factory configuration was invalid.');
- }
+ $this->config = array();
+ foreach ($config as $name => $operation) {
+ $this->config[$name] = $operation + self::$defaultIteratorConfig;
}
}
- /**
- * {@inheritdoc}
- */
public function build(CommandInterface $command, array $options = array())
{
// Get the configuration data for the command
$commandName = $command->getName();
- $iteratorConfig = $this->operations->get($commandName) ?: array();
- $options = array_replace($this->config->getAll(), $iteratorConfig, $options);
+ $commandSupported = isset($this->config[$commandName]);
+ $options = $this->translateLegacyConfigOptions($options);
+ $options += $commandSupported ? $this->config[$commandName] : array();
- // Instantiate the iterator using the primary factory (if there is one)
+ // Instantiate the iterator using the primary factory (if one was provided)
if ($this->primaryIteratorFactory && $this->primaryIteratorFactory->canBuild($command)) {
$iterator = $this->primaryIteratorFactory->build($command, $options);
- } elseif (!$this->operations->hasKey($commandName)) {
+ } elseif (!$commandSupported) {
throw new InvalidArgumentException("Iterator was not found for {$commandName}.");
} else {
- // Fallback to this factory for creating the iterator if the primary factory did not work
+ // Instantiate a generic AWS resource iterator
$iterator = new AwsResourceIterator($command, $options);
}
return $iterator;
}
+ public function canBuild(CommandInterface $command)
+ {
+ if ($this->primaryIteratorFactory) {
+ return $this->primaryIteratorFactory->canBuild($command);
+ } else {
+ return isset($this->config[$command->getName()]);
+ }
+ }
+
/**
- * {@inheritdoc}
+ * @param array $config The config for a single operation
+ *
+ * @return array The modified config with legacy options translated
*/
- public function canBuild(CommandInterface $command)
+ private function translateLegacyConfigOptions($config)
{
- return ($this->primaryIteratorFactory && $this->primaryIteratorFactory->canBuild($command))
- || $this->operations->hasKey($command->getName());
+ foreach (self::$legacyConfigOptions as $legacyOption => $newOption) {
+ if (isset($config[$legacyOption])) {
+ $config[$newOption] = $config[$legacyOption];
+ unset($config[$legacyOption]);
+ }
+ }
+
+ return $config;
}
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Resources/aws-config.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Resources/aws-config.php
index 7aa60c35451..6a1e30c6413 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Resources/aws-config.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Resources/aws-config.php
@@ -53,12 +53,53 @@ return array(
'class' => 'Aws\CloudSearch\CloudSearchClient'
),
+ 'cloudsearch_20110201' => array(
+ 'extends' => 'cloudsearch',
+ 'params' => array(
+ 'version' => '2011-02-01'
+ )
+ ),
+
+ 'cloudsearchdomain' => array(
+ 'alias' => 'CloudSearchDomain',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\CloudSearchDomain\CloudSearchDomainClient'
+ ),
+
+ 'cloudtrail' => array(
+ 'alias' => 'CloudTrail',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\CloudTrail\CloudTrailClient'
+ ),
+
'cloudwatch' => array(
'alias' => 'CloudWatch',
'extends' => 'default_settings',
'class' => 'Aws\CloudWatch\CloudWatchClient'
),
+ 'cognito-identity' => array(
+ 'alias' => 'CognitoIdentity',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\CognitoIdentity\CognitoIdentityClient'
+ ),
+
+ 'cognitoidentity' => array('extends' => 'cognito-identity'),
+
+ 'cognito-sync' => array(
+ 'alias' => 'CognitoSync',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\CognitoSync\CognitoSyncClient'
+ ),
+
+ 'cognitosync' => array('extends' => 'cognito-sync'),
+
+ 'cloudwatchlogs' => array(
+ 'alias' => 'CloudWatchLogs',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\CloudWatchLogs\CloudWatchLogsClient'
+ ),
+
'datapipeline' => array(
'alias' => 'DataPipeline',
'extends' => 'default_settings',
@@ -126,6 +167,12 @@ return array(
'class' => 'Aws\Glacier\GlacierClient'
),
+ 'kinesis' => array(
+ 'alias' => 'Kinesis',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\Kinesis\KinesisClient'
+ ),
+
'iam' => array(
'alias' => 'Iam',
'extends' => 'default_settings',
@@ -162,6 +209,12 @@ return array(
'class' => 'Aws\Route53\Route53Client'
),
+ 'route53domains' => array(
+ 'alias' => 'Route53Domains',
+ 'extends' => 'default_settings',
+ 'class' => 'Aws\Route53Domains\Route53DomainsClient'
+ ),
+
's3' => array(
'alias' => 'S3',
'extends' => 'default_settings',
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/AbstractSignature.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/AbstractSignature.php
index 00d66f819ab..2d25d873c64 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/AbstractSignature.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/AbstractSignature.php
@@ -16,75 +16,29 @@
namespace Aws\Common\Signature;
+use Aws\Common\Credentials\CredentialsInterface;
use Guzzle\Http\Message\RequestInterface;
-/**
- * Abstract signature class that can be used when implementing new concrete
- * AWS signature protocol strategies
- */
abstract class AbstractSignature implements SignatureInterface
{
/**
- * @var int Timestamp
- */
- private $timestamp;
-
- /**
- * Get the canonicalized query string for a request
- *
- * @param RequestInterface $request
- * @return string
- */
- protected function getCanonicalizedQueryString(RequestInterface $request)
- {
- $queryParams = $request->getQuery()->getAll();
- unset($queryParams['X-Amz-Signature']);
- if (empty($queryParams)) {
- return '';
- }
-
- $qs = '';
- ksort($queryParams);
- foreach ($queryParams as $key => $values) {
- if (is_array($values)) {
- sort($values);
- } elseif (!$values) {
- $values = array('');
- }
-
- foreach ((array) $values as $value) {
- $qs .= rawurlencode($key) . '=' . rawurlencode($value) . '&';
- }
- }
-
- return substr($qs, 0, -1);
- }
-
- /**
- * Provides the timestamp used for the class
- *
- * @param bool $refresh Set to TRUE to refresh the cached timestamp
+ * Provides the timestamp used for the class (used for mocking PHP's time() function)
*
* @return int
*/
- protected function getTimestamp($refresh = false)
+ protected function getTimestamp()
{
- if (!$this->timestamp || $refresh) {
- $this->timestamp = time();
- }
-
- return $this->timestamp;
+ return time();
}
/**
- * Get a date for one of the parts of the requests
- *
- * @param string $format Date format
- *
- * @return string
+ * @codeCoverageIgnore
*/
- protected function getDateTime($format)
- {
- return gmdate($format, $this->getTimestamp());
+ public function createPresignedUrl(
+ RequestInterface $request,
+ CredentialsInterface $credentials,
+ $expires
+ ) {
+ throw new \BadMethodCallException(__METHOD__ . ' not implemented');
}
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureInterface.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureInterface.php
index 35117ed41b1..e3536ba46a6 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureInterface.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureInterface.php
@@ -34,4 +34,19 @@ interface SignatureInterface
* @param CredentialsInterface $credentials Signing credentials
*/
public function signRequest(RequestInterface $request, CredentialsInterface $credentials);
+
+ /**
+ * Create a pre-signed URL
+ *
+ * @param RequestInterface $request Request to sign
+ * @param CredentialsInterface $credentials Credentials used to sign
+ * @param int|string|\DateTime $expires The time at which the URL should expire. This can be a Unix timestamp, a
+ * PHP DateTime object, or a string that can be evaluated by strtotime
+ * @return string
+ */
+ public function createPresignedUrl(
+ RequestInterface $request,
+ CredentialsInterface $credentials,
+ $expires
+ );
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV2.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV2.php
index 8b2f3a47fb8..c900287643d 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV2.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV2.php
@@ -25,16 +25,13 @@ use Guzzle\Http\Message\RequestInterface;
*/
class SignatureV2 extends AbstractSignature
{
- /**
- * {@inheritDoc}
- */
public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
{
// refresh the cached timestamp
- $this->getTimestamp(true);
+ $timestamp = $this->getTimestamp(true);
// set values we need in CanonicalizedParameterString
- $this->addParameter($request, 'Timestamp', $this->getDateTime('c'));
+ $this->addParameter($request, 'Timestamp', gmdate('c', $timestamp));
$this->addParameter($request, 'SignatureVersion', '2');
$this->addParameter($request, 'SignatureMethod', 'HmacSHA256');
$this->addParameter($request, 'AWSAccessKeyId', $credentials->getAccessKeyId());
@@ -90,7 +87,7 @@ class SignatureV2 extends AbstractSignature
*
* @return string
*/
- public function getCanonicalizedParameterString(RequestInterface $request)
+ private function getCanonicalizedParameterString(RequestInterface $request)
{
if ($request->getMethod() == 'POST') {
$params = $request->getPostFields()->toArray();
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3.php
deleted file mode 100644
index bde4534817c..00000000000
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-/**
- * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-namespace Aws\Common\Signature;
-
-use Aws\Common\Credentials\CredentialsInterface;
-use Aws\Common\Enum\DateFormat;
-use Guzzle\Http\Message\RequestInterface;
-use Guzzle\Http\Message\EntityEnclosingRequestInterface;
-
-/**
- * Implementation of Signature Version 3
- * @link http://docs.amazonwebservices.com/amazonswf/latest/developerguide/HMACAuth-swf.html
- */
-class SignatureV3 extends AbstractSignature
-{
- /**
- * Get an array of headers to be signed
- *
- * @param RequestInterface $request Request to get headers from
- *
- * @return array
- */
- protected function getHeadersToSign(RequestInterface $request)
- {
- $headers = array();
- foreach ($request->getHeaders()->toArray() as $k => $v) {
- $k = strtolower($k);
- if ($k == 'host' || strpos($k, 'x-amz-') !== false) {
- $headers[$k] = implode(',', $v);
- }
- }
-
- // Sort the headers alphabetically and add them to the string to sign
- ksort($headers);
-
- return $headers;
- }
-
- /**
- * {@inheritdoc}
- */
- public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
- {
- // Refresh the cached timestamp
- $this->getTimestamp(true);
-
- // Add default headers
- $request->setHeader('x-amz-date', $this->getDateTime(DateFormat::RFC1123));
-
- // Add the security token if one is present
- if ($credentials->getSecurityToken()) {
- $request->setHeader('x-amz-security-token', $credentials->getSecurityToken());
- }
-
- // Grab the path and ensure that it is absolute
- $path = '/' . ltrim($request->getUrl(true)->normalizePath()->getPath(), '/');
-
- // Begin building the string to sign
- $sign = $request->getMethod() . "\n"
- . "{$path}\n"
- . $this->getCanonicalizedQueryString($request) . "\n";
-
- // Get all of the headers that must be signed (host and x-amz-*)
- $headers = $this->getHeadersToSign($request);
- foreach ($headers as $key => $value) {
- $sign .= $key . ':' . $value . "\n";
- }
-
- $sign .= "\n";
-
- // Add the body of the request if a body is present
- if ($request instanceof EntityEnclosingRequestInterface) {
- $sign .= (string) $request->getBody();
- }
-
- // Add the string to sign to the request for debugging purposes
- $request->getParams()->set('aws.string_to_sign', $sign);
-
- $signature = base64_encode(hash_hmac('sha256',
- hash('sha256', $sign, true), $credentials->getSecretKey(), true));
-
- // Add the authorization header to the request
- $request->setHeader('x-amzn-authorization', sprintf('AWS3 AWSAccessKeyId=%s,Algorithm=HmacSHA256,SignedHeaders=%s,Signature=%s',
- $credentials->getAccessKeyId(),
- implode(';', array_keys($headers)),
- $signature));
- }
-}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3Https.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3Https.php
index dfe88ffb1cd..be0514e2729 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3Https.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV3Https.php
@@ -22,18 +22,15 @@ use Guzzle\Http\Message\RequestInterface;
/**
* Implementation of Signature Version 3 HTTPS
- * @link http://docs.amazonwebservices.com/Route53/latest/DeveloperGuide/RESTAuthentication.html
+ * @link http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RESTAuthentication.html
*/
class SignatureV3Https extends AbstractSignature
{
- /**
- * {@inheritdoc}
- */
public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
{
// Add a date header if one is not set
if (!$request->hasHeader('date') && !$request->hasHeader('x-amz-date')) {
- $request->setHeader('Date', $this->getDateTime(DateFormat::RFC1123));
+ $request->setHeader('Date', gmdate(DateFormat::RFC1123, $this->getTimestamp()));
}
// Add the security token if one is present
@@ -42,7 +39,7 @@ class SignatureV3Https extends AbstractSignature
}
// Determine the string to sign
- $stringToSign = $request->getHeader('Date', true) ?: $request->getHeader('x-amz-date', true);
+ $stringToSign = (string) ($request->getHeader('Date') ?: $request->getHeader('x-amz-date'));
$request->getParams()->set('aws.string_to_sign', $stringToSign);
// Calculate the signature
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV4.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV4.php
index 06d4d45dfbf..fda63a95fc4 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV4.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Signature/SignatureV4.php
@@ -19,45 +19,46 @@ namespace Aws\Common\Signature;
use Aws\Common\Credentials\CredentialsInterface;
use Aws\Common\Enum\DateFormat;
use Aws\Common\HostNameUtils;
+use Guzzle\Http\Message\EntityEnclosingRequest;
use Guzzle\Http\Message\EntityEnclosingRequestInterface;
+use Guzzle\Http\Message\RequestFactory;
use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\QueryString;
use Guzzle\Http\Url;
/**
* Signature Version 4
- * @link http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html
+ * @link http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
*/
class SignatureV4 extends AbstractSignature implements EndpointSignatureInterface
{
- /**
- * @var string Cache of the default empty entity-body payload
- */
+ /** @var string Cache of the default empty entity-body payload */
const DEFAULT_PAYLOAD = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
- /**
- * @var string Explicitly set service name
- */
+ /** @var string Explicitly set service name */
protected $serviceName;
- /**
- * @var string Explicitly set region name
- */
+ /** @var string Explicitly set region name */
protected $regionName;
- /**
- * @var int Maximum number of hashes to cache
- */
+ /** @var int Maximum number of hashes to cache */
protected $maxCacheSize = 50;
- /**
- * @var array Cache of previously signed values
- */
+ /** @var array Cache of previously signed values */
protected $hashCache = array();
+ /** @var int Size of the hash cache */
+ protected $cacheSize = 0;
+
/**
- * @var int Size of the hash cache
+ * @param string $serviceName Bind the signing to a particular service name
+ * @param string $regionName Bind the signing to a particular region name
*/
- protected $cacheSize = 0;
+ public function __construct($serviceName = null, $regionName = null)
+ {
+ $this->serviceName = $serviceName;
+ $this->regionName = $regionName;
+ }
/**
* Set the service name instead of inferring it from a request URL
@@ -101,26 +102,20 @@ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterfac
return $this;
}
- /**
- * {@inheritdoc}
- */
public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
{
- // Refresh the cached timestamp
- $this->getTimestamp(true);
-
- $longDate = $this->getDateTime(DateFormat::ISO8601);
- $shortDate = $this->getDateTime(DateFormat::SHORT);
+ $timestamp = $this->getTimestamp();
+ $longDate = gmdate(DateFormat::ISO8601, $timestamp);
+ $shortDate = substr($longDate, 0, 8);
- // Remove any previously set Authorization headers so that
- // exponential backoff works correctly
+ // Remove any previously set Authorization headers so that retries work
$request->removeHeader('Authorization');
// Requires a x-amz-date header or Date
if ($request->hasHeader('x-amz-date') || !$request->hasHeader('Date')) {
$request->setHeader('x-amz-date', $longDate);
} else {
- $request->setHeader('Date', $this->getDateTime(DateFormat::RFC1123));
+ $request->setHeader('Date', gmdate(DateFormat::RFC1123, $timestamp));
}
// Add the security token if one is present
@@ -129,22 +124,22 @@ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterfac
}
// Parse the service and region or use one that is explicitly set
- $url = null;
- if (!$this->regionName || !$this->serviceName) {
+ $region = $this->regionName;
+ $service = $this->serviceName;
+ if (!$region || !$service) {
$url = Url::factory($request->getUrl());
- }
- if (!$region = $this->regionName) {
- $region = HostNameUtils::parseRegionName($url);
- }
- if (!$service = $this->serviceName) {
- $service = HostNameUtils::parseServiceName($url);
+ $region = $region ?: HostNameUtils::parseRegionName($url);
+ $service = $service ?: HostNameUtils::parseServiceName($url);
}
- $credentialScope = "{$shortDate}/{$region}/{$service}/aws4_request";
-
- $signingContext = $this->createCanonicalRequest($request);
- $signingContext['string_to_sign'] = "AWS4-HMAC-SHA256\n{$longDate}\n{$credentialScope}\n"
- . hash('sha256', $signingContext['canonical_request']);
+ $credentialScope = $this->createScope($shortDate, $region, $service);
+ $payload = $this->getPayload($request);
+ $signingContext = $this->createSigningContext($request, $payload);
+ $signingContext['string_to_sign'] = $this->createStringToSign(
+ $longDate,
+ $credentialScope,
+ $signingContext['canonical_request']
+ );
// Calculate the signing key using a series of derived keys
$signingKey = $this->getSigningKey($shortDate, $region, $service, $credentials->getSecretKey());
@@ -158,32 +153,175 @@ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterfac
$request->getParams()->set('aws.signature', $signingContext);
}
+ public function createPresignedUrl(
+ RequestInterface $request,
+ CredentialsInterface $credentials,
+ $expires
+ ) {
+ $request = $this->createPresignedRequest($request, $credentials);
+ $query = $request->getQuery();
+ $httpDate = gmdate(DateFormat::ISO8601, $this->getTimestamp());
+ $shortDate = substr($httpDate, 0, 8);
+ $scope = $this->createScope(
+ $shortDate,
+ $this->regionName,
+ $this->serviceName
+ );
+ $this->addQueryValues($scope, $request, $credentials, $expires);
+ $payload = $this->getPresignedPayload($request);
+ $context = $this->createSigningContext($request, $payload);
+ $stringToSign = $this->createStringToSign(
+ $httpDate,
+ $scope,
+ $context['canonical_request']
+ );
+ $key = $this->getSigningKey(
+ $shortDate,
+ $this->regionName,
+ $this->serviceName,
+ $credentials->getSecretKey()
+ );
+ $query['X-Amz-Signature'] = hash_hmac('sha256', $stringToSign, $key);
+
+ return $request->getUrl();
+ }
+
+ /**
+ * Converts a POST request to a GET request by moving POST fields into the
+ * query string.
+ *
+ * Useful for pre-signing query protocol requests.
+ *
+ * @param EntityEnclosingRequestInterface $request Request to clone
+ *
+ * @return RequestInterface
+ * @throws \InvalidArgumentException if the method is not POST
+ */
+ public static function convertPostToGet(EntityEnclosingRequestInterface $request)
+ {
+ if ($request->getMethod() !== 'POST') {
+ throw new \InvalidArgumentException('Expected a POST request but '
+ . 'received a ' . $request->getMethod() . ' request.');
+ }
+
+ $cloned = RequestFactory::getInstance()
+ ->cloneRequestWithMethod($request, 'GET');
+
+ // Move POST fields to the query if they are present
+ foreach ($request->getPostFields() as $name => $value) {
+ $cloned->getQuery()->set($name, $value);
+ }
+
+ return $cloned;
+ }
+
+ /**
+ * Get the payload part of a signature from a request.
+ *
+ * @param RequestInterface $request
+ *
+ * @return string
+ */
+ protected function getPayload(RequestInterface $request)
+ {
+ // Calculate the request signature payload
+ if ($request->hasHeader('x-amz-content-sha256')) {
+ // Handle streaming operations (e.g. Glacier.UploadArchive)
+ return (string) $request->getHeader('x-amz-content-sha256');
+ }
+
+ if ($request instanceof EntityEnclosingRequestInterface) {
+ return hash(
+ 'sha256',
+ $request->getMethod() == 'POST' && count($request->getPostFields())
+ ? (string) $request->getPostFields()
+ : (string) $request->getBody()
+ );
+ }
+
+ return self::DEFAULT_PAYLOAD;
+ }
+
+ /**
+ * Get the payload of a request for use with pre-signed URLs.
+ *
+ * @param RequestInterface $request
+ *
+ * @return string
+ */
+ protected function getPresignedPayload(RequestInterface $request)
+ {
+ return $this->getPayload($request);
+ }
+
+ protected function createCanonicalizedPath(RequestInterface $request)
+ {
+ $doubleEncoded = rawurlencode(ltrim($request->getPath(), '/'));
+
+ return '/' . str_replace('%2F', '/', $doubleEncoded);
+ }
+
+ private function createStringToSign($longDate, $credentialScope, $creq)
+ {
+ return "AWS4-HMAC-SHA256\n{$longDate}\n{$credentialScope}\n"
+ . hash('sha256', $creq);
+ }
+
+ private function createPresignedRequest(
+ RequestInterface $request,
+ CredentialsInterface $credentials
+ ) {
+ $sr = RequestFactory::getInstance()->cloneRequestWithMethod($request, 'GET');
+
+ // Move POST fields to the query if they are present
+ if ($request instanceof EntityEnclosingRequestInterface) {
+ foreach ($request->getPostFields() as $name => $value) {
+ $sr->getQuery()->set($name, $value);
+ }
+ }
+
+ // Make sure to handle temporary credentials
+ if ($token = $credentials->getSecurityToken()) {
+ $sr->setHeader('X-Amz-Security-Token', $token);
+ $sr->getQuery()->set('X-Amz-Security-Token', $token);
+ }
+
+ $this->moveHeadersToQuery($sr);
+
+ return $sr;
+ }
+
/**
* Create the canonical representation of a request
*
* @param RequestInterface $request Request to canonicalize
+ * @param string $payload Request payload (typically the value
+ * of the x-amz-content-sha256 header.
*
- * @return array Returns an array of context information
+ * @return array Returns an array of context information including:
+ * - canonical_request
+ * - signed_headers
*/
- private function createCanonicalRequest(RequestInterface $request)
+ private function createSigningContext(RequestInterface $request, $payload)
{
// Normalize the path as required by SigV4 and ensure it's absolute
- $method = $request->getMethod();
- $canon = $method . "\n"
- . '/' . ltrim($request->getUrl(true)->normalizePath()->getPath(), '/') . "\n"
+ $canon = $request->getMethod() . "\n"
+ . $this->createCanonicalizedPath($request) . "\n"
. $this->getCanonicalizedQueryString($request) . "\n";
// Create the canonical headers
$headers = array();
foreach ($request->getHeaders()->getAll() as $key => $values) {
- if ($key != 'User-Agent') {
- $key = strtolower($key);
- if (!isset($headers[$key])) {
- $headers[$key] = array();
- }
+ $key = strtolower($key);
+ if ($key != 'user-agent') {
+ $headers[$key] = array();
foreach ($values as $value) {
$headers[$key][] = preg_replace('/\s+/', ' ', trim($value));
}
+ // Sort the value if there is more than one
+ if (count($values) > 1) {
+ sort($headers[$key]);
+ }
}
}
@@ -192,30 +330,13 @@ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterfac
// Continue to build the canonical request by adding headers
foreach ($headers as $key => $values) {
- // Combine multi-value headers into a sorted comma separated list
- if (count($values) > 1) {
- sort($values);
- }
+ // Combine multi-value headers into a comma separated list
$canon .= $key . ':' . implode(',', $values) . "\n";
}
// Create the signed headers
$signedHeaders = implode(';', array_keys($headers));
- $canon .= "\n{$signedHeaders}\n";
-
- // Create the payload if this request has an entity body
- if ($request->hasHeader('x-amz-content-sha256')) {
- // Handle streaming operations (e.g. Glacier.UploadArchive)
- $canon .= $request->getHeader('x-amz-content-sha256');
- } elseif ($request instanceof EntityEnclosingRequestInterface) {
- $canon .= hash(
- 'sha256',
- $method == 'POST' && count($request->getPostFields())
- ? (string) $request->getPostFields() : (string) $request->getBody()
- );
- } else {
- $canon .= self::DEFAULT_PAYLOAD;
- }
+ $canon .= "\n{$signedHeaders}\n{$payload}";
return array(
'canonical_request' => $canon,
@@ -253,4 +374,97 @@ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterfac
return $this->hashCache[$cacheKey];
}
+
+ /**
+ * Get the canonicalized query string for a request
+ *
+ * @param RequestInterface $request
+ * @return string
+ */
+ private function getCanonicalizedQueryString(RequestInterface $request)
+ {
+ $queryParams = $request->getQuery()->getAll();
+ unset($queryParams['X-Amz-Signature']);
+ if (empty($queryParams)) {
+ return '';
+ }
+
+ $qs = '';
+ ksort($queryParams);
+ foreach ($queryParams as $key => $values) {
+ if (is_array($values)) {
+ sort($values);
+ } elseif (!$values) {
+ $values = array('');
+ }
+
+ foreach ((array) $values as $value) {
+ if ($value === QueryString::BLANK) {
+ $value = '';
+ }
+ $qs .= rawurlencode($key) . '=' . rawurlencode($value) . '&';
+ }
+ }
+
+ return substr($qs, 0, -1);
+ }
+
+ private function convertExpires($expires)
+ {
+ if ($expires instanceof \DateTime) {
+ $expires = $expires->getTimestamp();
+ } elseif (!is_numeric($expires)) {
+ $expires = strtotime($expires);
+ }
+
+ $duration = $expires - time();
+
+ // Ensure that the duration of the signature is not longer than a week
+ if ($duration > 604800) {
+ throw new \InvalidArgumentException('The expiration date of a '
+ . 'signature version 4 presigned URL must be less than one '
+ . 'week');
+ }
+
+ return $duration;
+ }
+
+ private function createScope($shortDate, $region, $service)
+ {
+ return $shortDate
+ . '/' . $region
+ . '/' . $service
+ . '/aws4_request';
+ }
+
+ private function addQueryValues(
+ $scope,
+ RequestInterface $request,
+ CredentialsInterface $credentials,
+ $expires
+ ) {
+ $credential = $credentials->getAccessKeyId() . '/' . $scope;
+
+ // Set query params required for pre-signed URLs
+ $request->getQuery()
+ ->set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256')
+ ->set('X-Amz-Credential', $credential)
+ ->set('X-Amz-Date', gmdate('Ymd\THis\Z', $this->getTimestamp()))
+ ->set('X-Amz-SignedHeaders', 'Host')
+ ->set('X-Amz-Expires', $this->convertExpires($expires));
+ }
+
+ private function moveHeadersToQuery(RequestInterface $request)
+ {
+ $query = $request->getQuery();
+
+ foreach ($request->getHeaders() as $name => $header) {
+ if (substr($name, 0, 5) == 'x-amz') {
+ $query[$header->getName()] = (string) $header;
+ }
+ if ($name !== 'host') {
+ $request->removeHeader($name);
+ }
+ }
+ }
}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Waiter/AbstractWaiter.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Waiter/AbstractWaiter.php
index 5d294cc26af..09dbea1fc3c 100644
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Waiter/AbstractWaiter.php
+++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Waiter/AbstractWaiter.php
@@ -89,6 +89,16 @@ abstract class AbstractWaiter extends AbstractHasDispatcher implements WaiterInt
*/
public function setConfig(array $config)
{
+ if (isset($config['waiter.before_attempt'])) {
+ $this->getEventDispatcher()->addListener('waiter.before_attempt', $config['waiter.before_attempt']);
+ unset($config['waiter.before_attempt']);
+ }
+
+ if (isset($config['waiter.before_wait'])) {
+ $this->getEventDispatcher()->addListener('waiter.before_wait', $config['waiter.before_wait']);
+ unset($config['waiter.before_wait']);
+ }
+
$this->config = $config;
return $this;