1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qmqttauthenticationproperties.h"
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \class QMqttAuthenticationProperties
11
12 \inmodule QtMqtt
13 \since 5.12
14
15 \brief The QMqttAuthenticationProperties class represents configuration
16 options during the authentication process.
17
18 \note Authentication properties are part of the MQTT 5.0 specification and
19 cannot be used when connecting with a lower protocol level. See
20 QMqttClient::ProtocolVersion for more information.
21*/
22
23class QMqttAuthenticationPropertiesData : public QSharedData
24{
25public:
26 QString authenticationMethod;
27 QByteArray authenticationData;
28 QString reason;
29 QMqttUserProperties userProperties;
30};
31
32/*!
33 \internal
34*/
35QMqttAuthenticationProperties::QMqttAuthenticationProperties() : data(new QMqttAuthenticationPropertiesData)
36{
37
38}
39
40/*!
41 \internal
42*/
43QMqttAuthenticationProperties::QMqttAuthenticationProperties(const QMqttAuthenticationProperties &) = default;
44
45QMqttAuthenticationProperties &QMqttAuthenticationProperties::operator=(const QMqttAuthenticationProperties &rhs)
46{
47 if (this != &rhs)
48 data.operator=(o: rhs.data);
49 return *this;
50}
51
52QMqttAuthenticationProperties::~QMqttAuthenticationProperties() = default;
53
54/*!
55 Returns the authentication method.
56*/
57QString QMqttAuthenticationProperties::authenticationMethod() const
58{
59 return data->authenticationMethod;
60}
61
62/*!
63 Sets the authentication method to \a method.
64*/
65void QMqttAuthenticationProperties::setAuthenticationMethod(const QString &method)
66{
67 data->authenticationMethod = method;
68}
69
70/*!
71 Returns the authentication data
72*/
73QByteArray QMqttAuthenticationProperties::authenticationData() const
74{
75 return data->authenticationData;
76}
77
78/*!
79 Sets the authentication data to \a adata.
80
81 Authentication data can only be used if an authentication method has
82 been specified.
83
84 \sa authenticationMethod()
85*/
86void QMqttAuthenticationProperties::setAuthenticationData(const QByteArray &adata)
87{
88 data->authenticationData = adata;
89}
90
91/*!
92 Returns the reason string. The reason string specifies the reason for
93 a disconnect.
94*/
95QString QMqttAuthenticationProperties::reason() const
96{
97 return data->reason;
98}
99
100/*!
101 Sets the reason string to \a r.
102*/
103void QMqttAuthenticationProperties::setReason(const QString &r)
104{
105 data->reason = r;
106}
107
108/*!
109 Returns the user properties.
110*/
111QMqttUserProperties QMqttAuthenticationProperties::userProperties() const
112{
113 return data->userProperties;
114}
115
116/*!
117 Sets the user properties to \a user.
118*/
119void QMqttAuthenticationProperties::setUserProperties(const QMqttUserProperties &user)
120{
121 data->userProperties = user;
122}
123
124QT_END_NAMESPACE
125

source code of qtmqtt/src/mqtt/qmqttauthenticationproperties.cpp