Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
namespace Aws\Sts;
2
namespace Aws\Sts;
Línea -... Línea 3...
-
 
3
 
3
 
4
use Aws\Arn\ArnParser;
4
use Aws\AwsClient;
5
use Aws\AwsClient;
5
use Aws\CacheInterface;
6
use Aws\CacheInterface;
6
use Aws\Credentials\Credentials;
7
use Aws\Credentials\Credentials;
7
use Aws\Result;
8
use Aws\Result;
Línea 14... Línea 15...
14
 * @method \GuzzleHttp\Promise\Promise assumeRoleAsync(array $args = [])
15
 * @method \GuzzleHttp\Promise\Promise assumeRoleAsync(array $args = [])
15
 * @method \Aws\Result assumeRoleWithSAML(array $args = [])
16
 * @method \Aws\Result assumeRoleWithSAML(array $args = [])
16
 * @method \GuzzleHttp\Promise\Promise assumeRoleWithSAMLAsync(array $args = [])
17
 * @method \GuzzleHttp\Promise\Promise assumeRoleWithSAMLAsync(array $args = [])
17
 * @method \Aws\Result assumeRoleWithWebIdentity(array $args = [])
18
 * @method \Aws\Result assumeRoleWithWebIdentity(array $args = [])
18
 * @method \GuzzleHttp\Promise\Promise assumeRoleWithWebIdentityAsync(array $args = [])
19
 * @method \GuzzleHttp\Promise\Promise assumeRoleWithWebIdentityAsync(array $args = [])
-
 
20
 * @method \Aws\Result assumeRoot(array $args = [])
-
 
21
 * @method \GuzzleHttp\Promise\Promise assumeRootAsync(array $args = [])
19
 * @method \Aws\Result decodeAuthorizationMessage(array $args = [])
22
 * @method \Aws\Result decodeAuthorizationMessage(array $args = [])
20
 * @method \GuzzleHttp\Promise\Promise decodeAuthorizationMessageAsync(array $args = [])
23
 * @method \GuzzleHttp\Promise\Promise decodeAuthorizationMessageAsync(array $args = [])
21
 * @method \Aws\Result getAccessKeyInfo(array $args = [])
24
 * @method \Aws\Result getAccessKeyInfo(array $args = [])
22
 * @method \GuzzleHttp\Promise\Promise getAccessKeyInfoAsync(array $args = [])
25
 * @method \GuzzleHttp\Promise\Promise getAccessKeyInfoAsync(array $args = [])
23
 * @method \Aws\Result getCallerIdentity(array $args = [])
26
 * @method \Aws\Result getCallerIdentity(array $args = [])
Línea 67... Línea 70...
67
     * @param Result $result Result of an STS operation
70
     * @param Result $result Result of an STS operation
68
     *
71
     *
69
     * @return Credentials
72
     * @return Credentials
70
     * @throws \InvalidArgumentException if the result contains no credentials
73
     * @throws \InvalidArgumentException if the result contains no credentials
71
     */
74
     */
72
    public function createCredentials(Result $result)
75
    public function createCredentials(Result $result, $source=null)
73
    {
76
    {
74
        if (!$result->hasKey('Credentials')) {
77
        if (!$result->hasKey('Credentials')) {
75
            throw new \InvalidArgumentException('Result contains no credentials');
78
            throw new \InvalidArgumentException('Result contains no credentials');
76
        }
79
        }
Línea -... Línea 80...
-
 
80
 
-
 
81
        $accountId = null;
-
 
82
        if ($result->hasKey('AssumedRoleUser')) {
-
 
83
            $parsedArn = ArnParser::parse($result->get('AssumedRoleUser')['Arn']);
-
 
84
            $accountId = $parsedArn->getAccountId();
-
 
85
        } elseif ($result->hasKey('FederatedUser')) {
-
 
86
            $parsedArn = ArnParser::parse($result->get('FederatedUser')['Arn']);
-
 
87
            $accountId = $parsedArn->getAccountId();
-
 
88
        }
77
 
89
 
-
 
90
        $credentials = $result['Credentials'];
-
 
91
        $expiration = isset($credentials['Expiration']) && $credentials['Expiration'] instanceof \DateTimeInterface
-
 
92
            ? (int) $credentials['Expiration']->format('U')
Línea 78... Línea 93...
78
        $c = $result['Credentials'];
93
            : null;
79
 
94
 
80
        return new Credentials(
95
        return new Credentials(
81
            $c['AccessKeyId'],
96
            $credentials['AccessKeyId'],
82
            $c['SecretAccessKey'],
97
            $credentials['SecretAccessKey'],
83
            isset($c['SessionToken']) ? $c['SessionToken'] : null,
98
            isset($credentials['SessionToken']) ? $credentials['SessionToken'] : null,
84
            isset($c['Expiration']) && $c['Expiration'] instanceof \DateTimeInterface
99
            $expiration,
85
                ? (int) $c['Expiration']->format('U')
100
            $accountId,
86
                : null
101
            $source
Línea 87... Línea 102...
87
        );
102
        );
88
    }
103
    }