| 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 | |
| 7 | QT_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 | |
| 23 | class QMqttAuthenticationPropertiesData : public QSharedData |
| 24 | { |
| 25 | public: |
| 26 | QString authenticationMethod; |
| 27 | QByteArray authenticationData; |
| 28 | QString reason; |
| 29 | QMqttUserProperties userProperties; |
| 30 | }; |
| 31 | |
| 32 | /*! |
| 33 | \internal |
| 34 | */ |
| 35 | QMqttAuthenticationProperties::QMqttAuthenticationProperties() : data(new QMqttAuthenticationPropertiesData) |
| 36 | { |
| 37 | |
| 38 | } |
| 39 | |
| 40 | /*! |
| 41 | \internal |
| 42 | */ |
| 43 | QMqttAuthenticationProperties::QMqttAuthenticationProperties(const QMqttAuthenticationProperties &) = default; |
| 44 | |
| 45 | QMqttAuthenticationProperties &QMqttAuthenticationProperties::operator=(const QMqttAuthenticationProperties &rhs) |
| 46 | { |
| 47 | if (this != &rhs) |
| 48 | data.operator=(o: rhs.data); |
| 49 | return *this; |
| 50 | } |
| 51 | |
| 52 | QMqttAuthenticationProperties::~QMqttAuthenticationProperties() = default; |
| 53 | |
| 54 | /*! |
| 55 | Returns the authentication method. |
| 56 | */ |
| 57 | QString QMqttAuthenticationProperties::authenticationMethod() const |
| 58 | { |
| 59 | return data->authenticationMethod; |
| 60 | } |
| 61 | |
| 62 | /*! |
| 63 | Sets the authentication method to \a method. |
| 64 | */ |
| 65 | void QMqttAuthenticationProperties::setAuthenticationMethod(const QString &method) |
| 66 | { |
| 67 | data->authenticationMethod = method; |
| 68 | } |
| 69 | |
| 70 | /*! |
| 71 | Returns the authentication data |
| 72 | */ |
| 73 | QByteArray 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 | */ |
| 86 | void 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 | */ |
| 95 | QString QMqttAuthenticationProperties::reason() const |
| 96 | { |
| 97 | return data->reason; |
| 98 | } |
| 99 | |
| 100 | /*! |
| 101 | Sets the reason string to \a r. |
| 102 | */ |
| 103 | void QMqttAuthenticationProperties::setReason(const QString &r) |
| 104 | { |
| 105 | data->reason = r; |
| 106 | } |
| 107 | |
| 108 | /*! |
| 109 | Returns the user properties. |
| 110 | */ |
| 111 | QMqttUserProperties QMqttAuthenticationProperties::userProperties() const |
| 112 | { |
| 113 | return data->userProperties; |
| 114 | } |
| 115 | |
| 116 | /*! |
| 117 | Sets the user properties to \a user. |
| 118 | */ |
| 119 | void QMqttAuthenticationProperties::setUserProperties(const QMqttUserProperties &user) |
| 120 | { |
| 121 | data->userProperties = user; |
| 122 | } |
| 123 | |
| 124 | QT_END_NAMESPACE |
| 125 |
