1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Network Auth module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30//
31// W A R N I N G
32// -------------
33//
34// This file is not part of the Qt API. It exists for the convenience
35// of the Network Access API. This header file may change from
36// version to version without notice, or even be removed.
37//
38// We mean it.
39//
40
41#ifndef QOAUTH1_P_H
42#define QOAUTH1_P_H
43
44#ifndef QT_NO_HTTP
45
46#include <private/qabstractoauth_p.h>
47
48#include <QtNetworkAuth/qoauth1.h>
49#include <QtNetworkAuth/qoauthglobal.h>
50
51#include <QtCore/qurl.h>
52#include <QtCore/qpair.h>
53#include <QtCore/qobject.h>
54#include <QtCore/qstring.h>
55
56#include <QtNetwork/qnetworkreply.h>
57#include <QtNetwork/qnetworkaccessmanager.h>
58
59QT_BEGIN_NAMESPACE
60
61class QOAuth1Signature;
62
63class QOAuth1Private : public QAbstractOAuthPrivate
64{
65 Q_DECLARE_PUBLIC(QOAuth1)
66
67public:
68 QOAuth1Private(const QPair<QString, QString> &clientCredentials,
69 QNetworkAccessManager *networkAccessManager = nullptr);
70
71 void appendCommonHeaders(QVariantMap *headers);
72 void appendSignature(QAbstractOAuth::Stage stage,
73 QVariantMap *headers,
74 const QUrl &url,
75 QNetworkAccessManager::Operation operation,
76 const QVariantMap parameters);
77
78 QNetworkReply *requestToken(QNetworkAccessManager::Operation operation,
79 const QUrl &url,
80 const QPair<QString, QString> &token,
81 const QVariantMap &additionalParameters);
82
83 QString signatureMethodString() const;
84 QByteArray generateSignature(const QVariantMap &parameters,
85 const QUrl &url,
86 QNetworkAccessManager::Operation operation) const;
87 QByteArray generateSignature(const QVariantMap &parameters,
88 const QUrl &url,
89 const QByteArray &verb) const;
90 QByteArray formatSignature(const QOAuth1Signature &signature) const;
91
92 QVariantMap createOAuthBaseParams() const;
93
94 void prepareRequestImpl(QNetworkRequest *request,
95 const QByteArray &verb,
96 const QByteArray &body) override;
97
98 void _q_onTokenRequestError(QNetworkReply::NetworkError error);
99 void _q_tokensReceived(const QVariantMap &tokens);
100
101 QString clientIdentifierSharedKey;
102 QString tokenSecret;
103 QString verifier;
104 QUrl temporaryCredentialsUrl;
105 QUrl tokenCredentialsUrl;
106 QOAuth1::SignatureMethod signatureMethod = QOAuth1::SignatureMethod::Hmac_Sha1;
107 const QString oauthVersion = QStringLiteral("1.0");
108 bool tokenRequested = false;
109
110 struct OAuth1KeyString
111 {
112 static const QString oauthCallback;
113 static const QString oauthCallbackConfirmed;
114 static const QString oauthConsumerKey;
115 static const QString oauthNonce;
116 static const QString oauthSignature;
117 static const QString oauthSignatureMethod;
118 static const QString oauthTimestamp;
119 static const QString oauthToken;
120 static const QString oauthTokenSecret;
121 static const QString oauthVerifier;
122 static const QString oauthVersion;
123 };
124};
125
126QT_END_NAMESPACE
127
128#endif // QT_NO_HTTP
129
130#endif // QOAUTH1_P_H
131

source code of qtnetworkauth/src/oauth/qoauth1_p.h