PluginProbe
Media Cloud Sync / 1.2.9
Media Cloud Sync v1.2.9
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Sts / StsClient.php

StsClient.php in Media Cloud Sync 1.2.9, at includes/sdk/s3/Aws/Sts/StsClient.php

75 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Sts;
4
5 use Dudlewebs\WPMCS\s3\Aws\AwsClient;
6 use Dudlewebs\WPMCS\s3\Aws\CacheInterface;
7 use Dudlewebs\WPMCS\s3\Aws\Credentials\Credentials;
8 use Dudlewebs\WPMCS\s3\Aws\Result;
9 use Dudlewebs\WPMCS\s3\Aws\Sts\RegionalEndpoints\ConfigurationProvider;
10 /**
11 * This client is used to interact with the **AWS Security Token Service (AWS STS)**.
12 *
13 * @method \Aws\Result assumeRole(array $args = [])
14 * @method \GuzzleHttp\Promise\Promise assumeRoleAsync(array $args = [])
15 * @method \Aws\Result assumeRoleWithSAML(array $args = [])
16 * @method \GuzzleHttp\Promise\Promise assumeRoleWithSAMLAsync(array $args = [])
17 * @method \Aws\Result assumeRoleWithWebIdentity(array $args = [])
18 * @method \GuzzleHttp\Promise\Promise assumeRoleWithWebIdentityAsync(array $args = [])
19 * @method \Aws\Result decodeAuthorizationMessage(array $args = [])
20 * @method \GuzzleHttp\Promise\Promise decodeAuthorizationMessageAsync(array $args = [])
21 * @method \Aws\Result getAccessKeyInfo(array $args = [])
22 * @method \GuzzleHttp\Promise\Promise getAccessKeyInfoAsync(array $args = [])
23 * @method \Aws\Result getCallerIdentity(array $args = [])
24 * @method \GuzzleHttp\Promise\Promise getCallerIdentityAsync(array $args = [])
25 * @method \Aws\Result getFederationToken(array $args = [])
26 * @method \GuzzleHttp\Promise\Promise getFederationTokenAsync(array $args = [])
27 * @method \Aws\Result getSessionToken(array $args = [])
28 * @method \GuzzleHttp\Promise\Promise getSessionTokenAsync(array $args = [])
29 */
30 class StsClient extends AwsClient
31 {
32 /**
33 * {@inheritdoc}
34 *
35 * In addition to the options available to
36 * {@see \Aws\AwsClient::__construct}, StsClient accepts the following
37 * options:
38 *
39 * - sts_regional_endpoints:
40 * (Aws\Sts\RegionalEndpoints\ConfigurationInterface|Aws\CacheInterface\|callable|string|array)
41 * Specifies whether to use regional or legacy endpoints for legacy regions.
42 * Provide an Aws\Sts\RegionalEndpoints\ConfigurationInterface object, an
43 * instance of Aws\CacheInterface, a callable configuration provider used
44 * to create endpoint configuration, a string value of `legacy` or
45 * `regional`, or an associative array with the following keys:
46 * endpoint_types (string) Set to `legacy` or `regional`, defaults to
47 * `legacy`
48 *
49 * @param array $args
50 */
51 public function __construct(array $args)
52 {
53 if (!isset($args['sts_regional_endpoints']) || $args['sts_regional_endpoints'] instanceof CacheInterface) {
54 $args['sts_regional_endpoints'] = ConfigurationProvider::defaultProvider($args);
55 }
56 parent::__construct($args);
57 }
58 /**
59 * Creates credentials from the result of an STS operations
60 *
61 * @param Result $result Result of an STS operation
62 *
63 * @return Credentials
64 * @throws \InvalidArgumentException if the result contains no credentials
65 */
66 public function createCredentials(Result $result)
67 {
68 if (!$result->hasKey('Credentials')) {
69 throw new \InvalidArgumentException('Result contains no credentials');
70 }
71 $c = $result['Credentials'];
72 return new Credentials($c['AccessKeyId'], $c['SecretAccessKey'], isset($c['SessionToken']) ? $c['SessionToken'] : null, isset($c['Expiration']) && $c['Expiration'] instanceof \DateTimeInterface ? (int) $c['Expiration']->format('U') : null);
73 }
74 }
75