1// Copyright (C) 2019 The Qt Company Ltd.
2// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qopcuaendpointdescription.h"
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \class QOpcUaEndpointDescription
11 \inmodule QtOpcUa
12 \brief The OPC UA EndpointDescription.
13
14 An endpoint description contains information about an endpoint and how to connect to it.
15*/
16
17/*!
18 \qmltype EndpointDescription
19 \inqmlmodule QtOpcUa
20 \brief The OPC UA EndpointDescription.
21 \since QtOpcUa 5.13
22
23 An endpoint description contains information about an endpoint and how to connect to it.
24*/
25
26/*!
27 \enum QOpcUaEndpointDescription::MessageSecurityMode
28
29 This enum type holds the security mode supported by the endpoint.
30
31 \value Invalid The default value, will be rejected by the server.
32 \value None No security.
33 \value Sign Messages are signed but not encrypted.
34 \value SignAndEncrypt Messages are signed and encrypted.
35*/
36
37/*!
38 \qmlproperty enumeration EndpointDescription::MessageSecurityMode
39
40 The security mode supported by the endpoint.
41
42 \value Invalid The default value, will be rejected by the server.
43 \value None No security.
44 \value Sign Messages are signed but not encrypted.
45 \value SignAndEncrypt Messages are signed and encrypted.
46*/
47
48
49/*!
50 \property QOpcUaEndpointDescription::endpointUrl
51
52 The URL for the endpoint.
53 */
54
55/*!
56 \qmlproperty string EndpointDescription::endpointUrl
57
58 The URL for the endpoint.
59 */
60
61/*!
62 \property QOpcUaEndpointDescription::securityMode
63
64 Security mode supported by this endpoint.
65 */
66
67/*!
68 \qmlproperty MessageSecurityMode EndpointDescription::securityMode
69
70 Security mode supported by this endpoint.
71 */
72
73/*!
74 \property QOpcUaEndpointDescription::securityPolicy
75
76 The URI of the security policy.
77 */
78
79/*!
80 \qmlproperty string EndpointDescription::securityPolicy
81
82 The URI of the security policy.
83 */
84
85
86/*!
87 \property QOpcUaEndpointDescription::server
88
89 The application description of the server.
90 */
91
92/*!
93 \qmlproperty ApplicationDescription EndpointDescription::server
94
95 The application description of the server.
96 */
97
98/*!
99 \property QOpcUaEndpointDescription::userIdentityTokens
100
101 List of user identity tokens the endpoint will accept.
102 */
103
104/*!
105 \qmlproperty list<UserTokenPolicy> EndpointDescription::userIdentityTokens
106
107 List of user identity tokens the endpoint will accept.
108 */
109
110class QOpcUaEndpointDescriptionData : public QSharedData
111{
112public:
113 QString endpointUrl;
114 QOpcUaApplicationDescription server;
115 QByteArray serverCertificate;
116 QOpcUaEndpointDescription::MessageSecurityMode securityMode{QOpcUaEndpointDescription::MessageSecurityMode::None};
117 QString securityPolicy;
118 QList<QOpcUaUserTokenPolicy> userIdentityTokens;
119 QString transportProfileUri;
120 quint8 securityLevel{0};
121};
122
123/*!
124 Default constructs an endpoint description with no parameters set.
125*/
126QOpcUaEndpointDescription::QOpcUaEndpointDescription()
127 : data(new QOpcUaEndpointDescriptionData)
128{
129}
130
131/*!
132 Constructs an endpoint description from \a rhs.
133*/
134QOpcUaEndpointDescription::QOpcUaEndpointDescription(const QOpcUaEndpointDescription &rhs)
135 : data(rhs.data)
136{
137}
138
139/*!
140 Sets the values from \a rhs in this endpoint description.
141*/
142QOpcUaEndpointDescription &QOpcUaEndpointDescription::operator=(const QOpcUaEndpointDescription &rhs)
143{
144 if (this != &rhs)
145 data.operator=(o: rhs.data);
146 return *this;
147}
148
149/*!
150 Returns \c true if this endpoint description has the same value as \a rhs.
151 */
152bool QOpcUaEndpointDescription::operator==(const QOpcUaEndpointDescription &rhs) const
153{
154 return rhs.server() == server() &&
155 rhs.endpointUrl() == endpointUrl() &&
156 rhs.securityMode() == securityMode() &&
157 rhs.securityLevel() == securityLevel() &&
158 rhs.securityPolicy() == securityPolicy() &&
159 rhs.serverCertificate() == serverCertificate() &&
160 rhs.userIdentityTokens() == userIdentityTokens() &&
161 rhs.transportProfileUri() == transportProfileUri();
162}
163
164QOpcUaEndpointDescription::~QOpcUaEndpointDescription()
165{
166}
167
168/*!
169 Returns a relative index assigned by the server. It describes how secure this
170 endpoint is compared to other endpoints of the same server. An endpoint with strong
171 security measures has a higher security level than one with weaker or no security
172 measures.
173
174 Security level 0 indicates an endpoint for backward compatibility purposes which
175 should only be used if the client does not support the security measures required
176 by more secure endpoints.
177*/
178quint8 QOpcUaEndpointDescription::securityLevel() const
179{
180 return data->securityLevel;
181}
182
183/*!
184 Sets the security level to \a securityLevel.
185*/
186void QOpcUaEndpointDescription::setSecurityLevel(quint8 securityLevel)
187{
188 data->securityLevel = securityLevel;
189}
190
191/*!
192 Returns the URI of the transport profile supported by the endpoint.
193*/
194QString QOpcUaEndpointDescription::transportProfileUri() const
195{
196 return data->transportProfileUri;
197}
198
199/*!
200 Sets the URI of the transport profile supported by the endpoint to \a transportProfileUri.
201*/
202void QOpcUaEndpointDescription::setTransportProfileUri(const QString &transportProfileUri)
203{
204 data->transportProfileUri = transportProfileUri;
205}
206
207/*!
208 Returns a list of user identity tokens the endpoint will accept.
209*/
210QList<QOpcUaUserTokenPolicy> QOpcUaEndpointDescription::userIdentityTokens() const
211{
212 return data->userIdentityTokens;
213}
214
215/*!
216 Returns a reference to a list of user identity tokens the endpoint will accept.
217*/
218QList<QOpcUaUserTokenPolicy> &QOpcUaEndpointDescription::userIdentityTokensRef()
219{
220 return data->userIdentityTokens;
221}
222
223/*!
224 Sets the user identity tokens to \a userIdentityTokens.
225*/
226void QOpcUaEndpointDescription::setUserIdentityTokens(const QList<QOpcUaUserTokenPolicy> &userIdentityTokens)
227{
228 data->userIdentityTokens = userIdentityTokens;
229}
230
231/*!
232 Returns the URI of the security policy.
233*/
234QString QOpcUaEndpointDescription::securityPolicy() const
235{
236 return data->securityPolicy;
237}
238
239/*!
240 Sets the URI of the security policy to \a securityPolicy.
241*/
242void QOpcUaEndpointDescription::setSecurityPolicy(const QString &securityPolicy)
243{
244 data->securityPolicy = securityPolicy;
245}
246
247/*!
248 Returns the security mode supported by this endpoint.
249*/
250QOpcUaEndpointDescription::MessageSecurityMode QOpcUaEndpointDescription::securityMode() const
251{
252 return data->securityMode;
253}
254
255/*!
256 Sets the security mode supported by this endpoint to \a securityMode.
257*/
258void QOpcUaEndpointDescription::setSecurityMode(MessageSecurityMode securityMode)
259{
260 data->securityMode = securityMode;
261}
262
263/*!
264 Returns the application instance certificate of the server.
265*/
266QByteArray QOpcUaEndpointDescription::serverCertificate() const
267{
268 return data->serverCertificate;
269}
270
271/*!
272 Sets the application instance certificate of the server to \a serverCertificate.
273*/
274void QOpcUaEndpointDescription::setServerCertificate(const QByteArray &serverCertificate)
275{
276 data->serverCertificate = serverCertificate;
277}
278
279/*!
280 Returns the application description of the server.
281*/
282QOpcUaApplicationDescription QOpcUaEndpointDescription::server() const
283{
284 return data->server;
285}
286
287/*!
288 Returns a reference to the application description of the server.
289*/
290QOpcUaApplicationDescription &QOpcUaEndpointDescription::serverRef()
291{
292 return data->server;
293}
294
295/*!
296 Sets the application description of the server to \a server.
297*/
298void QOpcUaEndpointDescription::setServer(const QOpcUaApplicationDescription &server)
299{
300 data->server = server;
301}
302
303/*!
304 Returns the URL for the endpoint.
305*/
306QString QOpcUaEndpointDescription::endpointUrl() const
307{
308 return data->endpointUrl;
309}
310
311/*!
312 Sets the URL for the endpoint to \a endpointUrl.
313*/
314void QOpcUaEndpointDescription::setEndpointUrl(const QString &endpointUrl)
315{
316 data->endpointUrl = endpointUrl;
317}
318
319QT_END_NAMESPACE
320

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtopcua/src/opcua/client/qopcuaendpointdescription.cpp