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 | #ifndef QOAUTH1SIGNATURE_H |
31 | #define QOAUTH1SIGNATURE_H |
32 | |
33 | #ifndef QT_NO_HTTP |
34 | |
35 | #include <QtNetworkAuth/qoauthglobal.h> |
36 | |
37 | #include <QtCore/qurl.h> |
38 | #include <QtCore/qvariant.h> |
39 | #include <QtCore/qshareddata.h> |
40 | |
41 | QT_BEGIN_NAMESPACE |
42 | |
43 | class QUrlQuery; |
44 | |
45 | class QOAuth1SignaturePrivate; |
46 | class Q_OAUTH_EXPORT QOAuth1Signature |
47 | { |
48 | public: |
49 | enum class HttpRequestMethod { |
50 | Head = 1, |
51 | Get, |
52 | Put, |
53 | Post, |
54 | Delete, |
55 | Custom, |
56 | |
57 | Unknown = 0 |
58 | }; |
59 | |
60 | explicit QOAuth1Signature(const QUrl &url = QUrl(), |
61 | HttpRequestMethod method = HttpRequestMethod::Post, |
62 | const QVariantMap ¶meters = QVariantMap()); |
63 | QOAuth1Signature(const QUrl &url, const QString &clientSharedKey, const QString &tokenSecret, |
64 | HttpRequestMethod method = HttpRequestMethod::Post, |
65 | const QVariantMap ¶meters = QVariantMap()); |
66 | QOAuth1Signature(const QOAuth1Signature &other); |
67 | QOAuth1Signature(QOAuth1Signature &&other); |
68 | ~QOAuth1Signature(); |
69 | |
70 | HttpRequestMethod httpRequestMethod() const; |
71 | void setHttpRequestMethod(HttpRequestMethod method); |
72 | |
73 | QByteArray customMethodString() const; |
74 | void setCustomMethodString(const QByteArray &verb); |
75 | |
76 | QUrl url() const; |
77 | void setUrl(const QUrl &url); |
78 | |
79 | QVariantMap parameters() const; |
80 | void setParameters(const QVariantMap ¶meters); |
81 | void addRequestBody(const QUrlQuery &body); |
82 | |
83 | void insert(const QString &key, const QVariant &value); |
84 | QList<QString> keys() const; |
85 | QVariant take(const QString &key); |
86 | QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; |
87 | |
88 | QString clientSharedKey() const; |
89 | void setClientSharedKey(const QString &secret); |
90 | |
91 | QString tokenSecret() const; |
92 | void setTokenSecret(const QString &secret); |
93 | |
94 | QByteArray hmacSha1() const; |
95 | QByteArray rsaSha1() const; |
96 | QByteArray plainText() const; |
97 | |
98 | static QByteArray plainText(const QString &clientSharedSecret, const QString &tokenSecret); |
99 | |
100 | void swap(QOAuth1Signature &other); |
101 | QOAuth1Signature &operator=(const QOAuth1Signature &other); |
102 | QOAuth1Signature &operator=(QOAuth1Signature &&other); |
103 | |
104 | private: |
105 | QSharedDataPointer<QOAuth1SignaturePrivate> d; |
106 | }; |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // QT_NO_HTTP |
111 | |
112 | #endif // QOAUTH1SIGNATURE_H |
113 | |