1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QOAUTH1SIGNATURE_H
5#define QOAUTH1SIGNATURE_H
6
7#ifndef QT_NO_HTTP
8
9#include <QtNetworkAuth/qoauthglobal.h>
10
11#include <QtCore/qurl.h>
12#include <QtCore/qvariant.h>
13#include <QtCore/qshareddata.h>
14
15QT_BEGIN_NAMESPACE
16
17class QUrlQuery;
18
19class QOAuth1SignaturePrivate;
20class Q_OAUTH_EXPORT QOAuth1Signature
21{
22public:
23 enum class HttpRequestMethod {
24 Head = 1,
25 Get,
26 Put,
27 Post,
28 Delete,
29 Custom,
30
31 Unknown = 0
32 };
33
34 explicit QOAuth1Signature(const QUrl &url = QUrl(),
35 HttpRequestMethod method = HttpRequestMethod::Post,
36 const QMultiMap<QString, QVariant> &parameters = {});
37 QOAuth1Signature(const QUrl &url, const QString &clientSharedKey, const QString &tokenSecret,
38 HttpRequestMethod method = HttpRequestMethod::Post,
39 const QMultiMap<QString, QVariant> &parameters = {});
40 QOAuth1Signature(const QOAuth1Signature &other);
41 QOAuth1Signature(QOAuth1Signature &&other);
42 ~QOAuth1Signature();
43
44 HttpRequestMethod httpRequestMethod() const;
45 void setHttpRequestMethod(HttpRequestMethod method);
46
47 QByteArray customMethodString() const;
48 void setCustomMethodString(const QByteArray &verb);
49
50 QUrl url() const;
51 void setUrl(const QUrl &url);
52
53 QMultiMap<QString, QVariant> parameters() const;
54 void setParameters(const QMultiMap<QString, QVariant> &parameters);
55 void addRequestBody(const QUrlQuery &body);
56
57 void insert(const QString &key, const QVariant &value);
58 QList<QString> keys() const;
59 QVariant take(const QString &key);
60 QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
61
62 QString clientSharedKey() const;
63 void setClientSharedKey(const QString &secret);
64
65 QString tokenSecret() const;
66 void setTokenSecret(const QString &secret);
67
68 QByteArray hmacSha1() const;
69 QByteArray rsaSha1() const;
70 QByteArray plainText() const;
71
72 static QByteArray plainText(const QString &clientSharedSecret, const QString &tokenSecret);
73
74 void swap(QOAuth1Signature &other);
75 QOAuth1Signature &operator=(const QOAuth1Signature &other);
76 QOAuth1Signature &operator=(QOAuth1Signature &&other);
77
78private:
79 QSharedDataPointer<QOAuth1SignaturePrivate> d;
80};
81
82QT_END_NAMESPACE
83
84#endif // QT_NO_HTTP
85
86#endif // QOAUTH1SIGNATURE_H
87

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