1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QCOAPSECURITYCONFIGURATION_H
5#define QCOAPSECURITYCONFIGURATION_H
6
7#include <QtCoap/qcoapglobal.h>
8
9#include <QtCore/qglobal.h>
10#include <QtCore/QSharedDataPointer>
11#include <QtNetwork/QSslCertificate>
12
13QT_BEGIN_NAMESPACE
14
15class QCoapPrivateKeyPrivate;
16class Q_COAP_EXPORT QCoapPrivateKey
17{
18public:
19 QCoapPrivateKey();
20 QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm,
21 QSsl::EncodingFormat format = QSsl::Pem,
22 const QByteArray &passPhrase = QByteArray());
23 QCoapPrivateKey(const Qt::HANDLE &handle);
24
25 QCoapPrivateKey(const QCoapPrivateKey& other);
26 QCoapPrivateKey(QCoapPrivateKey&& other) noexcept;
27 ~QCoapPrivateKey();
28
29 QCoapPrivateKey &operator=(QCoapPrivateKey &&other) noexcept
30 { swap(other); return *this; }
31 QCoapPrivateKey &operator=(const QCoapPrivateKey &other);
32
33 void swap(QCoapPrivateKey &other) noexcept
34 { d.swap(other&: other.d); }
35
36 bool isNull() const;
37
38 QByteArray key() const;
39 Qt::HANDLE handle() const;
40 QSsl::KeyAlgorithm algorithm() const;
41 QSsl::EncodingFormat encodingFormat() const;
42 QByteArray passPhrase() const;
43private:
44 QSharedDataPointer<QCoapPrivateKeyPrivate> d;
45};
46
47class QCoapSecurityConfigurationPrivate;
48class Q_COAP_EXPORT QCoapSecurityConfiguration
49{
50public:
51 QCoapSecurityConfiguration();
52 QCoapSecurityConfiguration(const QCoapSecurityConfiguration &other);
53 ~QCoapSecurityConfiguration();
54
55 QCoapSecurityConfiguration(QCoapSecurityConfiguration &&other) noexcept;
56 QCoapSecurityConfiguration &operator=(QCoapSecurityConfiguration &&other) noexcept
57 { swap(other); return *this; }
58 QCoapSecurityConfiguration &operator=(const QCoapSecurityConfiguration &other);
59
60 void swap(QCoapSecurityConfiguration &other) noexcept
61 { d.swap(other&: other.d); }
62
63 void setPreSharedKeyIdentity(const QByteArray &preSharedKeyIdentity);
64 QByteArray preSharedKeyIdentity() const;
65
66 void setPreSharedKey(const QByteArray &preSharedKey);
67 QByteArray preSharedKey() const;
68
69 void setDefaultCipherString(const QString &cipherString);
70 QString defaultCipherString() const;
71
72 void setCaCertificates(const QList<QSslCertificate> &certificates);
73 QList<QSslCertificate> caCertificates() const;
74
75 void setLocalCertificateChain(const QList<QSslCertificate> &localChain);
76 QList<QSslCertificate> localCertificateChain() const;
77
78 void setPrivateKey(const QCoapPrivateKey &key);
79 QCoapPrivateKey privateKey() const;
80
81private:
82 QSharedDataPointer<QCoapSecurityConfigurationPrivate> d;
83};
84
85Q_DECLARE_SHARED(QCoapSecurityConfiguration)
86
87QT_END_NAMESPACE
88
89Q_DECLARE_METATYPE(QCoapSecurityConfiguration)
90
91#endif // QCOAPSECURITYCONFIGURATION_H
92

source code of qtcoap/src/coap/qcoapsecurityconfiguration.h