AWS SDK for C++  1.8.95
AWS SDK for C++
AWSCredentials.h
Go to the documentation of this file.
1 
6  #pragma once
7 
11 namespace Aws
12 {
13  namespace Auth
14  {
19  {
20  public:
26  AWSCredentials() : m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)())
27  {
28  }
29 
35  AWSCredentials(const Aws::String& accessKeyId, const Aws::String& secretKey) :
36  m_accessKeyId(accessKeyId), m_secretKey(secretKey), m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)())
37  {
38  }
39 
44  AWSCredentials(const Aws::String& accessKeyId, const Aws::String& secretKey, const Aws::String& sessionToken) :
45  m_accessKeyId(accessKeyId), m_secretKey(secretKey), m_sessionToken(sessionToken), m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)())
46  {
47  }
48 
52  AWSCredentials(const Aws::String& accessKeyId, const Aws::String& secretKey, const Aws::String& sessionToken, Aws::Utils::DateTime expiration) :
53  m_accessKeyId(accessKeyId), m_secretKey(secretKey), m_sessionToken(sessionToken), m_expiration(expiration)
54  {
55  }
56 
57  bool operator == (const AWSCredentials& other) const
58  {
59  return m_accessKeyId == other.m_accessKeyId
60  && m_secretKey == other.m_secretKey
61  && m_sessionToken == other.m_sessionToken
62  && m_expiration == other.m_expiration;
63  }
64 
65  bool operator != (const AWSCredentials& other) const
66  {
67  return !(other == *this);
68  }
69 
74  inline bool IsEmpty() const { return m_accessKeyId.empty() && m_secretKey.empty(); }
75 
76  inline bool IsExpired() const { return m_expiration <= Aws::Utils::DateTime::Now(); }
77 
78  inline bool IsExpiredOrEmpty() const { return IsEmpty() || IsExpired(); }
79 
83  inline const Aws::String& GetAWSAccessKeyId() const
84  {
85  return m_accessKeyId;
86  }
87 
91  inline const Aws::String& GetAWSSecretKey() const
92  {
93  return m_secretKey;
94  }
95 
99  inline const Aws::String& GetSessionToken() const
100  {
101  return m_sessionToken;
102  }
103 
108  {
109  return m_expiration;
110  }
111 
115  inline void SetAWSAccessKeyId(const Aws::String& accessKeyId)
116  {
117  m_accessKeyId = accessKeyId;
118  }
119 
123  inline void SetAWSSecretKey(const Aws::String& secretKey)
124  {
125  m_secretKey = secretKey;
126  }
127 
131  inline void SetSessionToken(const Aws::String& sessionToken)
132  {
133  m_sessionToken = sessionToken;
134  }
135 
136 
140  inline void SetAWSAccessKeyId(const char* accessKeyId)
141  {
142  m_accessKeyId = accessKeyId;
143  }
144 
148  inline void SetAWSSecretKey(const char* secretKey)
149  {
150  m_secretKey = secretKey;
151  }
152 
156  inline void SetSessionToken(const char* sessionToken)
157  {
158  m_sessionToken = sessionToken;
159  }
160 
164  inline void SetExpiration(Aws::Utils::DateTime expiration)
165  {
166  m_expiration = expiration;
167  }
168 
169  private:
170  Aws::String m_accessKeyId;
171  Aws::String m_secretKey;
172  Aws::String m_sessionToken;
173  Aws::Utils::DateTime m_expiration;
174  };
175  }
176 }
const Aws::String & GetSessionToken() const
void SetAWSAccessKeyId(const Aws::String &accessKeyId)
void SetAWSSecretKey(const Aws::String &secretKey)
STL namespace.
AWSCredentials(const Aws::String &accessKeyId, const Aws::String &secretKey, const Aws::String &sessionToken, Aws::Utils::DateTime expiration)
static DateTime Now()
void SetAWSAccessKeyId(const char *accessKeyId)
const Aws::String & GetAWSAccessKeyId() const
void SetExpiration(Aws::Utils::DateTime expiration)
Aws::Utils::DateTime GetExpiration() const
void SetSessionToken(const char *sessionToken)
void SetAWSSecretKey(const char *secretKey)
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
void SetSessionToken(const Aws::String &sessionToken)
AWSCredentials(const Aws::String &accessKeyId, const Aws::String &secretKey, const Aws::String &sessionToken)
const Aws::String & GetAWSSecretKey() const
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
AWSCredentials(const Aws::String &accessKeyId, const Aws::String &secretKey)