|
1
|
|
|
package credentials |
|
2
|
|
|
|
|
3
|
|
|
import "github.com/alibabacloud-go/tea/tea" |
|
4
|
|
|
|
|
5
|
|
|
// StsTokenCredential is a kind of credentials |
|
6
|
|
|
type StsTokenCredential struct { |
|
7
|
|
|
AccessKeyId string |
|
8
|
|
|
AccessKeySecret string |
|
9
|
|
|
SecurityToken string |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
|
func newStsTokenCredential(accessKeyId, accessKeySecret, securityToken string) *StsTokenCredential { |
|
13
|
|
|
return &StsTokenCredential{ |
|
14
|
|
|
AccessKeyId: accessKeyId, |
|
15
|
|
|
AccessKeySecret: accessKeySecret, |
|
16
|
|
|
SecurityToken: securityToken, |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
func (s *StsTokenCredential) GetCredential() (*CredentialModel, error) { |
|
21
|
|
|
credential := &CredentialModel{ |
|
22
|
|
|
AccessKeyId: tea.String(s.AccessKeyId), |
|
23
|
|
|
AccessKeySecret: tea.String(s.AccessKeySecret), |
|
24
|
|
|
SecurityToken: tea.String(s.SecurityToken), |
|
25
|
|
|
Type: tea.String("sts"), |
|
26
|
|
|
} |
|
27
|
|
|
return credential, nil |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
// GetAccessKeyId reutrns StsTokenCredential's AccessKeyId |
|
31
|
|
|
func (s *StsTokenCredential) GetAccessKeyId() (*string, error) { |
|
32
|
|
|
return tea.String(s.AccessKeyId), nil |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// GetAccessSecret reutrns StsTokenCredential's AccessKeySecret |
|
36
|
|
|
func (s *StsTokenCredential) GetAccessKeySecret() (*string, error) { |
|
37
|
|
|
return tea.String(s.AccessKeySecret), nil |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
// GetSecurityToken reutrns StsTokenCredential's SecurityToken |
|
41
|
|
|
func (s *StsTokenCredential) GetSecurityToken() (*string, error) { |
|
42
|
|
|
return tea.String(s.SecurityToken), nil |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// GetBearerToken is useless StsTokenCredential |
|
46
|
|
|
func (s *StsTokenCredential) GetBearerToken() *string { |
|
47
|
|
|
return tea.String("") |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
// GetType reutrns StsTokenCredential's type |
|
51
|
|
|
func (s *StsTokenCredential) GetType() *string { |
|
52
|
|
|
return tea.String("sts") |
|
53
|
|
|
} |
|
54
|
|
|
|