1 package authentication
2 3 import "time"
4 5 // IamToken represents an interface for accessing an IAM token and its expiry information.
6 // GetIamToken retrieves the IAM token string.
7 // GetExpiresAt returns the expiration time of the IAM token.
8 type IamToken interface {
9 GetIamToken() string
10 GetExpiresAt() time.Time
11 }
12 13 // IamTokenImpl is an implementation of the IamToken interface, representing an IAM token with its value and expiration time.
14 type IamTokenImpl struct {
15 Token string
16 ExpiresAt time.Time
17 }
18 19 // NewIamToken initializes and returns a new IamToken instance with the provided token value and expiration time.
20 func NewIamToken(token string, expiresAt time.Time) IamToken {
21 return &IamTokenImpl{
22 Token: token,
23 ExpiresAt: expiresAt,
24 }
25 }
26 27 // GetIamToken returns the IAM token stored in the IamTokenImpl instance.
28 func (token *IamTokenImpl) GetIamToken() string {
29 return token.Token
30 }
31 32 // GetExpiresAt returns the expiration time of the IAM token as a time.Time value.
33 func (token *IamTokenImpl) GetExpiresAt() time.Time {
34 return token.ExpiresAt
35 }
36