libqtaws  0.1.0
UnofficialAWSlibraryforQt
awssignaturev4_p.h
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 #ifndef AWSSIGNATUREV4_P_H
21 #define AWSSIGNATUREV4_P_H
22 
23 #include "qtawsglobal.h"
24 #include "awsabstractsignature_p.h"
25 
26 #include <QCryptographicHash>
27 #include <QDateTime>
28 #include <QNetworkAccessManager>
29 #include <QUrl>
30 #include <QUrlQuery>
31 
32 QTAWS_BEGIN_NAMESPACE
33 
34 class AwsSignatureV4;
35 
36 class QTAWS_EXPORT AwsSignatureV4Private : public AwsAbstractSignaturePrivate {
37 
38 public:
39  AwsSignatureV4Private(const QCryptographicHash::Algorithm hashAlgorithm, AwsSignatureV4 * const q);
40 
41  void setAuthorizationHeader(const AwsAbstractCredentials &credentials,
42  const QNetworkAccessManager::Operation operation,
43  QNetworkRequest &request, const QByteArray &payload,
44  const QDateTime &timestamp) const;
45 
46  QDateTime setDateHeader(QNetworkRequest &request, const QDateTime &dateTime = QDateTime::currentDateTimeUtc()) const;
47 
48 protected:
49  static const QLatin1String DateFormat;
50  static const QLatin1String DateTimeFormat;
51 
52  const QCryptographicHash::Algorithm hashAlgorithm;
53 
54  QByteArray algorithmDesignation(const QCryptographicHash::Algorithm algorithm) const;
55 
56  QByteArray authorizationHeaderValue(const AwsAbstractCredentials &credentials,
57  const QNetworkAccessManager::Operation operation,
58  QNetworkRequest &request, const QByteArray &payload,
59  const QDateTime &timestamp) const;
60 
61  QByteArray canonicalHeader(const QByteArray &headerName, const QByteArray &headerValue) const;
62 
63  QByteArray canonicalHeaders(const QNetworkRequest &request, QByteArray * const signedHeaders) const;
64 
65  QByteArray canonicalRequest(const QNetworkAccessManager::Operation operation, const QNetworkRequest &request,
66  const QByteArray &payload, QByteArray * const signedHeaders) const;
67 
68  QByteArray credentialScope(const QDate &date, const QString &region, const QString &service) const;
69 
70  QByteArray signingKey(const AwsAbstractCredentials &credentials, const QDate &date,
71  const QString &region, const QString &service) const;
72 
73  QByteArray stringToSign(const QByteArray &algorithmDesignation, const QDateTime &requestDate,
74  const QByteArray &credentialScope, const QByteArray &canonicalRequest) const;
75 
76 private:
77  Q_DECLARE_PUBLIC(AwsSignatureV4)
78  friend class TestAwsSignatureV4;
79 };
80 
81 QTAWS_END_NAMESPACE
82 
83 #endif
Interface class for providing AWS credentials.
Definition: awsabstractcredentials.h:30
Implements AWS Signature Version 4.
Definition: awssignaturev4.h:32