Line data Source code
1 : /*
2 : Copyright 2013-2015 Paul Colby
3 :
4 : This file is part of libqtaws.
5 :
6 : Libqtaws is free software: you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as published by
8 : the Free Software Foundation, either version 3 of the License, or
9 : (at your option) any later version.
10 :
11 : Libqtaws is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : GNU Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public License
17 : along with libqtaws. If not, see <http://www.gnu.org/licenses/>.
18 : */
19 :
20 : #include "awsbasiccredentials.h"
21 : #include "awsbasiccredentials_p.h"
22 :
23 : QTAWS_BEGIN_NAMESPACE
24 :
25 : /**
26 : * @class AwsBasicCredentials
27 : *
28 : * @brief Basic non-refreshable implementation of AwsAbstractCredentials.
29 : */
30 :
31 : /**
32 : * @brief Constructs a new AwsBasicCredentials object.
33 : *
34 : * Constructs a new AwsBasicCredentials object, with the specified AWS access key, AWS secret
35 : * key, and AWS security token.
36 : *
37 : * @param accessKeyId The AWS access key ID to use for this credentials object.
38 : * @param secretKey The AWS secret access key to use for this credentials object.
39 : * @param token The AWS security token to use for this credentials object.
40 : * @param parent This object's parent.
41 : */
42 10 : AwsBasicCredentials::AwsBasicCredentials(
43 : const QString &accessKeyId,
44 : const QString &secretKey,
45 : const QString &token,
46 : QObject * const parent)
47 10 : : AwsAbstractCredentials(parent), d_ptr(new AwsBasicCredentialsPrivate(this))
48 : {
49 10 : Q_D(AwsBasicCredentials);
50 10 : d->accessKeyId = accessKeyId;
51 10 : d->secretKey = secretKey;
52 10 : d->token = token;
53 10 : }
54 :
55 : /**
56 : * @brief Constructs a new AwsBasicCredentials object.
57 : *
58 : * Constructs a new AwsBasicCredentials object, with the specified AWS access key and AWS secret
59 : * key. The object's security token will be left as null string, unless set later via setToken().
60 : *
61 : * @param accessKeyId The AWS access key ID to use for this credentials object.
62 : * @param secretKey The AWS secret access key to use for this credentials object.
63 : * @param parent This object's parent.
64 : */
65 113 : AwsBasicCredentials::AwsBasicCredentials(
66 : const QString &accessKeyId,
67 : const QString &secretKey,
68 : QObject * const parent)
69 113 : : AwsAbstractCredentials(parent), d_ptr(new AwsBasicCredentialsPrivate(this))
70 : {
71 113 : Q_D(AwsBasicCredentials);
72 113 : d->accessKeyId = accessKeyId;
73 113 : d->secretKey = secretKey;
74 113 : }
75 :
76 246 : AwsBasicCredentials::~AwsBasicCredentials()
77 : {
78 123 : delete d_ptr;
79 123 : }
80 :
81 125 : QString AwsBasicCredentials::accessKeyId() const
82 : {
83 125 : Q_D(const AwsBasicCredentials);
84 125 : return d->accessKeyId;
85 : }
86 :
87 122 : QString AwsBasicCredentials::secretKey() const
88 : {
89 122 : Q_D(const AwsBasicCredentials);
90 122 : return d->secretKey;
91 : }
92 :
93 45 : QString AwsBasicCredentials::token() const
94 : {
95 45 : Q_D(const AwsBasicCredentials);
96 45 : return d->token;
97 : }
98 :
99 : /**
100 : * @brief Set the AWS access key ID for this credentials object.
101 : *
102 : * @param accessKeyId The AWS access key ID to set for this credentials object.
103 : */
104 5 : void AwsBasicCredentials::setAccessKeyId(const QString &accessKeyId)
105 : {
106 5 : Q_D(AwsBasicCredentials);
107 5 : d->accessKeyId = accessKeyId;
108 5 : emit changed();
109 5 : }
110 :
111 : /**
112 : * @brief Set the AWS secret access key for this credentials object.
113 : *
114 : * @param secretKey The AWS secret access key to set for this credentials object.
115 : */
116 5 : void AwsBasicCredentials::setSecretKey(const QString &secretKey)
117 : {
118 5 : Q_D(AwsBasicCredentials);
119 5 : d->secretKey = secretKey;
120 5 : emit changed();
121 5 : }
122 :
123 : /**
124 : * @brief Set the AWS security token for this credentials object.
125 : *
126 : * @param token The AWS security token to set for this credentials object.
127 : */
128 5 : void AwsBasicCredentials::setToken(const QString &token)
129 : {
130 5 : Q_D(AwsBasicCredentials);
131 5 : d->token = token;
132 5 : emit changed();
133 5 : }
134 :
135 : /**
136 : * @internal
137 : *
138 : * @class AwsBasicCredentialsPrivate
139 : *
140 : * @brief Private implementation for AwsBasicCredentials.
141 : *
142 : * @see http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
143 : */
144 :
145 : /**
146 : * @internal
147 : *
148 : * @brief Constructs a new AwsBasicCredentialsPrivate object.
149 : *
150 : * @param q Pointer to this object's public AwsBasicCredentials instance.
151 : */
152 123 : AwsBasicCredentialsPrivate::AwsBasicCredentialsPrivate(AwsBasicCredentials * const q)
153 123 : : q_ptr(q)
154 : {
155 :
156 123 : }
157 :
158 : QTAWS_END_NAMESPACE
|