Файл: sngine-v2.8/Script/includes/libs/AWS/Aws/Sts/StsClient.php
Строк: 157
<?php
namespace AwsSts;
use AwsAwsClient;
use AwsCacheInterface;
use AwsCredentialsCredentials;
use AwsResult;
use AwsStsRegionalEndpointsConfigurationProvider;
/**
* This client is used to interact with the **AWS Security Token Service (AWS STS)**.
*
* @method AwsResult assumeRole(array $args = [])
* @method GuzzleHttpPromisePromise assumeRoleAsync(array $args = [])
* @method AwsResult assumeRoleWithSAML(array $args = [])
* @method GuzzleHttpPromisePromise assumeRoleWithSAMLAsync(array $args = [])
* @method AwsResult assumeRoleWithWebIdentity(array $args = [])
* @method GuzzleHttpPromisePromise assumeRoleWithWebIdentityAsync(array $args = [])
* @method AwsResult decodeAuthorizationMessage(array $args = [])
* @method GuzzleHttpPromisePromise decodeAuthorizationMessageAsync(array $args = [])
* @method AwsResult getAccessKeyInfo(array $args = [])
* @method GuzzleHttpPromisePromise getAccessKeyInfoAsync(array $args = [])
* @method AwsResult getCallerIdentity(array $args = [])
* @method GuzzleHttpPromisePromise getCallerIdentityAsync(array $args = [])
* @method AwsResult getFederationToken(array $args = [])
* @method GuzzleHttpPromisePromise getFederationTokenAsync(array $args = [])
* @method AwsResult getSessionToken(array $args = [])
* @method GuzzleHttpPromisePromise getSessionTokenAsync(array $args = [])
*/
class StsClient extends AwsClient
{
/**
* {@inheritdoc}
*
* In addition to the options available to
* {@see AwsAwsClient::__construct}, StsClient accepts the following
* options:
*
* - sts_regional_endpoints:
* (AwsStsRegionalEndpointsConfigurationInterface|AwsCacheInterface|callable|string|array)
* Specifies whether to use regional or legacy endpoints for legacy regions.
* Provide an AwsStsRegionalEndpointsConfigurationInterface object, an
* instance of AwsCacheInterface, a callable configuration provider used
* to create endpoint configuration, a string value of `legacy` or
* `regional`, or an associative array with the following keys:
* endpoint_types (string) Set to `legacy` or `regional`, defaults to
* `legacy`
*
* @param array $args
*/
public function __construct(array $args)
{
if (!isset($args['sts_regional_endpoints'])) {
$args['sts_regional_endpoints'] = ConfigurationProvider::defaultProvider();
} elseif ($args['sts_regional_endpoints'] instanceof CacheInterface) {
$args['sts_regional_endpoints'] = ConfigurationProvider::defaultProvider($args);
}
parent::__construct($args);
}
/**
* Creates credentials from the result of an STS operations
*
* @param Result $result Result of an STS operation
*
* @return Credentials
* @throws InvalidArgumentException if the result contains no credentials
*/
public function createCredentials(Result $result)
{
if (!$result->hasKey('Credentials')) {
throw new InvalidArgumentException('Result contains no credentials');
}
$c = $result['Credentials'];
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
);
}
}