Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Token/SsoToken.php

raw symbols SCIP
1 <?php
2 namespace Aws\Token;
3
4 /**
5 * Token that comes from the SSO provider
6 */
7 class SsoToken extends Token
8 {
9 private $refreshToken;
10 private $clientId;
11 private $clientSecret;
12 private $registrationExpiresAt;
13 private $region;
14 private $startUrl;
15
16 /**
17 * Constructs a new SSO token object, with the specified AWS
18 * token
19 *
20 * @param string $token Security token to use
21 * @param int $expires UNIX timestamp for when the token expires
22 * @param int $refreshToken An opaque string returned by the sso-oidc service
23 * @param int $clientId The client ID generated when performing the registration portion of the OIDC authorization flow
24 * @param int $clientSecret The client secret generated when performing the registration portion of the OIDC authorization flow
25 * @param int $registrationExpiresAt The expiration time of the client registration (clientId and clientSecret)
26 * @param int $region The configured sso_region for the profile that credentials are being resolved for
27 * @param int $startUrl The configured sso_start_url for the profile that credentials are being resolved for
28 */
29 public function __construct(
30 $token,
31 $expires,
32 $refreshToken = null,
33 $clientId = null,
34 $clientSecret = null,
35 $registrationExpiresAt = null,
36 $region = null,
37 $startUrl = null
38 ) {
39 parent::__construct($token, $expires);
40 $this->refreshToken = $refreshToken;
41 $this->clientId = $clientId;
42 $this->clientSecret = $clientSecret;
43 $this->registrationExpiresAt = $registrationExpiresAt;
44 $this->region = $region;
45 $this->startUrl = $startUrl;
46 }
47
48 /**
49 * @return bool
50 */
51 public function isExpired()
52 {
53 if (isset($this->registrationExpiresAt)
54 && time() >= $this->registrationExpiresAt
55 ) {
56 return false;
57 }
58 return $this->expires !== null && time() >= $this->expires;
59 }
60
61 /**
62 * @return string|null
63 */
64 public function getRefreshToken()
65 {
66 return $this->refreshToken;
67 }
68
69 /**
70 * @return string|null
71 */
72 public function getClientId()
73 {
74 return $this->clientId;
75 }
76
77 /**
78 * @return string|null
79 */
80 public function getClientSecret()
81 {
82 return $this->clientSecret;
83 }
84
85 /**
86 * @return int|null
87 */
88 public function getRegistrationExpiresAt()
89 {
90 return $this->registrationExpiresAt;
91 }
92
93 /**
94 * @return string|null
95 */
96 public function getRegion()
97 {
98 return $this->region;
99 }
100
101 /**
102 * @return string|null
103 */
104 public function getStartUrl()
105 {
106 return $this->startUrl;
107 }
108
109 /**
110 * Creates an instance of SsoToken from a token data.
111 *
112 * @param $tokenData
113 *
114 * @return SsoToken
115 */
116 public static function fromTokenData($tokenData): SsoToken
117 {
118 return new SsoToken(
119 $tokenData['accessToken'],
120 \strtotime($tokenData['expiresAt']),
121 isset($tokenData['refreshToken']) ? $tokenData['refreshToken'] : null,
122 isset($tokenData['clientId']) ? $tokenData['clientId'] : null,
123 isset($tokenData['clientSecret']) ? $tokenData['clientSecret'] : null,
124 isset($tokenData['registrationExpiresAt']) ? $tokenData['registrationExpiresAt'] : null,
125 isset($tokenData['region']) ? $tokenData['region'] : null,
126 isset($tokenData['startUrl']) ? $tokenData['startUrl'] : null
127 );
128 }
129 }