1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of the Network Access API. This header file may change from
10// version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QOAUTH1_P_H
16#define QOAUTH1_P_H
17
18#ifndef QT_NO_HTTP
19
20#include <private/qabstractoauth_p.h>
21
22#include <QtNetworkAuth/qoauth1.h>
23#include <QtNetworkAuth/qoauthglobal.h>
24
25#include <QtCore/qurl.h>
26#include <QtCore/qpair.h>
27#include <QtCore/qobject.h>
28#include <QtCore/qstring.h>
29
30#include <QtNetwork/qnetworkreply.h>
31#include <QtNetwork/qnetworkaccessmanager.h>
32
33QT_BEGIN_NAMESPACE
34
35class QOAuth1Signature;
36
37class QOAuth1Private : public QAbstractOAuthPrivate
38{
39public:
40 Q_DECLARE_PUBLIC(QOAuth1)
41
42 QOAuth1Private(const QPair<QString, QString> &clientCredentials,
43 QNetworkAccessManager *networkAccessManager = nullptr);
44
45 void appendCommonHeaders(QVariantMap *headers);
46 void appendSignature(QAbstractOAuth::Stage stage,
47 QVariantMap *headers,
48 const QUrl &url,
49 QNetworkAccessManager::Operation operation,
50 const QMultiMap<QString, QVariant> parameters);
51
52 QNetworkReply *requestToken(QNetworkAccessManager::Operation operation,
53 const QUrl &url,
54 const QPair<QString, QString> &token,
55 const QVariantMap &additionalParameters);
56
57 QString signatureMethodString() const;
58 QByteArray generateSignature(const QMultiMap<QString, QVariant> &parameters,
59 const QUrl &url,
60 QNetworkAccessManager::Operation operation) const;
61 QByteArray generateSignature(const QMultiMap<QString, QVariant> &parameters,
62 const QUrl &url,
63 const QByteArray &verb) const;
64 QByteArray formatSignature(const QOAuth1Signature &signature) const;
65
66 QVariantMap createOAuthBaseParams() const;
67
68 void _q_onTokenRequestError(QNetworkReply::NetworkError error);
69 void _q_tokensReceived(const QVariantMap &tokens);
70
71 QString clientIdentifierSharedKey;
72 QString tokenSecret;
73 QString verifier;
74 QUrl temporaryCredentialsUrl;
75 QUrl tokenCredentialsUrl;
76 QOAuth1::SignatureMethod signatureMethod = QOAuth1::SignatureMethod::Hmac_Sha1;
77 const QString oauthVersion = QStringLiteral("1.0");
78 bool tokenRequested = false;
79
80 struct OAuth1KeyString
81 {
82 static const QString oauthCallback;
83 static const QString oauthCallbackConfirmed;
84 static const QString oauthConsumerKey;
85 static const QString oauthNonce;
86 static const QString oauthSignature;
87 static const QString oauthSignatureMethod;
88 static const QString oauthTimestamp;
89 static const QString oauthToken;
90 static const QString oauthTokenSecret;
91 static const QString oauthVerifier;
92 static const QString oauthVersion;
93 };
94};
95
96QT_END_NAMESPACE
97
98#endif // QT_NO_HTTP
99
100#endif // QOAUTH1_P_H
101

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