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\Credentials;
2
namespace Aws\Credentials;
Línea -... Línea 3...
-
 
3
 
-
 
4
use Aws\Identity\AwsCredentialIdentity;
3
 
5
 
4
/**
6
/**
5
 * Basic implementation of the AWS Credentials interface that allows callers to
7
 * Basic implementation of the AWS Credentials interface that allows callers to
6
 * pass in the AWS Access Key and AWS Secret Access Key in the constructor.
8
 * pass in the AWS Access Key and AWS Secret Access Key in the constructor.
7
 */
9
 */
-
 
10
class Credentials extends AwsCredentialIdentity implements
-
 
11
    CredentialsInterface,
8
class Credentials implements CredentialsInterface, \Serializable
12
    \Serializable
9
{
13
{
10
    private $key;
14
    private $key;
11
    private $secret;
15
    private $secret;
12
    private $token;
16
    private $token;
-
 
17
    private $expires;
-
 
18
    private $accountId;
Línea 13... Línea 19...
13
    private $expires;
19
    private $source;
14
 
20
 
15
    /**
21
    /**
16
     * Constructs a new BasicAWSCredentials object, with the specified AWS
22
     * Constructs a new BasicAWSCredentials object, with the specified AWS
17
     * access key and AWS secret key
23
     * access key and AWS secret key
18
     *
24
     *
19
     * @param string $key     AWS access key ID
25
     * @param string $key     AWS access key ID
20
     * @param string $secret  AWS secret access key
26
     * @param string $secret  AWS secret access key
21
     * @param string $token   Security token to use
27
     * @param string $token   Security token to use
22
     * @param int    $expires UNIX timestamp for when credentials expire
28
     * @param int    $expires UNIX timestamp for when credentials expire
-
 
29
     */
-
 
30
    public function __construct(
-
 
31
        $key,
-
 
32
        $secret,
-
 
33
        $token = null,
-
 
34
        $expires = null,
-
 
35
        $accountId = null,
23
     */
36
        $source = CredentialSources::STATIC
24
    public function __construct($key, $secret, $token = null, $expires = null)
37
    )
25
    {
38
    {
26
        $this->key = trim($key);
39
        $this->key = trim((string) $key);
27
        $this->secret = trim($secret);
40
        $this->secret = trim((string) $secret);
-
 
41
        $this->token = $token;
-
 
42
        $this->expires = $expires;
28
        $this->token = $token;
43
        $this->accountId = $accountId;
Línea 29... Línea 44...
29
        $this->expires = $expires;
44
        $this->source = $source ?? CredentialSources::STATIC;
30
    }
45
    }
31
 
46
 
32
    public static function __set_state(array $state)
47
    public static function __set_state(array $state)
33
    {
48
    {
34
        return new self(
49
        return new self(
35
            $state['key'],
50
            $state['key'],
-
 
51
            $state['secret'],
-
 
52
            $state['token'],
36
            $state['secret'],
53
            $state['expires'],
37
            $state['token'],
54
            $state['accountId'],
Línea 38... Línea 55...
38
            $state['expires']
55
            $state['source'] ?? null
39
        );
56
        );
Línea 62... Línea 79...
62
    public function isExpired()
79
    public function isExpired()
63
    {
80
    {
64
        return $this->expires !== null && time() >= $this->expires;
81
        return $this->expires !== null && time() >= $this->expires;
65
    }
82
    }
Línea -... Línea 83...
-
 
83
 
-
 
84
    public function getAccountId()
-
 
85
    {
-
 
86
        return $this->accountId;
-
 
87
    }
-
 
88
 
-
 
89
    public function getSource()
-
 
90
    {
-
 
91
        return $this->source;
-
 
92
    }
66
 
93
 
67
    public function toArray()
94
    public function toArray()
68
    {
95
    {
69
        return [
96
        return [
70
            'key'     => $this->key,
97
            'key'     => $this->key,
71
            'secret'  => $this->secret,
98
            'secret'  => $this->secret,
72
            'token'   => $this->token,
99
            'token'   => $this->token,
-
 
100
            'expires' => $this->expires,
-
 
101
            'accountId' =>  $this->accountId,
73
            'expires' => $this->expires
102
            'source' => $this->source
74
        ];
103
        ];
Línea 75... Línea 104...
75
    }
104
    }
76
 
105
 
Línea 95... Línea 124...
95
    {
124
    {
96
        $this->key = $data['key'];
125
        $this->key = $data['key'];
97
        $this->secret = $data['secret'];
126
        $this->secret = $data['secret'];
98
        $this->token = $data['token'];
127
        $this->token = $data['token'];
99
        $this->expires = $data['expires'];
128
        $this->expires = $data['expires'];
-
 
129
        $this->accountId = $data['accountId'] ?? null;
-
 
130
        $this->source = $data['source'] ?? null;
100
    }
131
    }
Línea 101... Línea 132...
101
 
132
 
102
    /**
133
    /**
103
     * Internal-only. Used when IMDS is unreachable
134
     * Internal-only. Used when IMDS is unreachable