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 | |
7 | QT_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 | |
110 | class QOpcUaEndpointDescriptionData : public QSharedData |
111 | { |
112 | public: |
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 | QOpcUaEndpointDescription::QOpcUaEndpointDescription() |
124 | : data(new QOpcUaEndpointDescriptionData) |
125 | { |
126 | } |
127 | |
128 | /*! |
129 | Constructs an endpoint description from \a rhs. |
130 | */ |
131 | QOpcUaEndpointDescription::QOpcUaEndpointDescription(const QOpcUaEndpointDescription &rhs) |
132 | : data(rhs.data) |
133 | { |
134 | } |
135 | |
136 | /*! |
137 | Sets the values from \a rhs in this endpoint description. |
138 | */ |
139 | QOpcUaEndpointDescription &QOpcUaEndpointDescription::operator=(const QOpcUaEndpointDescription &rhs) |
140 | { |
141 | if (this != &rhs) |
142 | data.operator=(o: rhs.data); |
143 | return *this; |
144 | } |
145 | |
146 | /*! |
147 | Returns \c true if this endpoint description has the same value as \a rhs. |
148 | */ |
149 | bool QOpcUaEndpointDescription::operator==(const QOpcUaEndpointDescription &rhs) const |
150 | { |
151 | return rhs.server() == server() && |
152 | rhs.endpointUrl() == endpointUrl() && |
153 | rhs.securityMode() == securityMode() && |
154 | rhs.securityLevel() == securityLevel() && |
155 | rhs.securityPolicy() == securityPolicy() && |
156 | rhs.serverCertificate() == serverCertificate() && |
157 | rhs.userIdentityTokens() == userIdentityTokens() && |
158 | rhs.transportProfileUri() == transportProfileUri(); |
159 | } |
160 | |
161 | QOpcUaEndpointDescription::~QOpcUaEndpointDescription() |
162 | { |
163 | } |
164 | |
165 | /*! |
166 | Returns a relative index assigned by the server. It describes how secure this |
167 | endpoint is compared to other endpoints of the same server. An endpoint with strong |
168 | security measures has a higher security level than one with weaker or no security |
169 | measures. |
170 | |
171 | Security level 0 indicates an endpoint for backward compatibility purposes which |
172 | should only be used if the client does not support the security measures required |
173 | by more secure endpoints. |
174 | */ |
175 | quint8 QOpcUaEndpointDescription::securityLevel() const |
176 | { |
177 | return data->securityLevel; |
178 | } |
179 | |
180 | /*! |
181 | Sets the security level to \a securityLevel. |
182 | */ |
183 | void QOpcUaEndpointDescription::setSecurityLevel(quint8 securityLevel) |
184 | { |
185 | data->securityLevel = securityLevel; |
186 | } |
187 | |
188 | /*! |
189 | Returns the URI of the transport profile supported by the endpoint. |
190 | */ |
191 | QString QOpcUaEndpointDescription::transportProfileUri() const |
192 | { |
193 | return data->transportProfileUri; |
194 | } |
195 | |
196 | /*! |
197 | Sets the URI of the transport profile supported by the endpoint to \a transportProfileUri. |
198 | */ |
199 | void QOpcUaEndpointDescription::setTransportProfileUri(const QString &transportProfileUri) |
200 | { |
201 | data->transportProfileUri = transportProfileUri; |
202 | } |
203 | |
204 | /*! |
205 | Returns a list of user identity tokens the endpoint will accept. |
206 | */ |
207 | QList<QOpcUaUserTokenPolicy> QOpcUaEndpointDescription::userIdentityTokens() const |
208 | { |
209 | return data->userIdentityTokens; |
210 | } |
211 | |
212 | /*! |
213 | Returns a reference to a list of user identity tokens the endpoint will accept. |
214 | */ |
215 | QList<QOpcUaUserTokenPolicy> &QOpcUaEndpointDescription::userIdentityTokensRef() |
216 | { |
217 | return data->userIdentityTokens; |
218 | } |
219 | |
220 | /*! |
221 | Sets the user identity tokens to \a userIdentityTokens. |
222 | */ |
223 | void QOpcUaEndpointDescription::setUserIdentityTokens(const QList<QOpcUaUserTokenPolicy> &userIdentityTokens) |
224 | { |
225 | data->userIdentityTokens = userIdentityTokens; |
226 | } |
227 | |
228 | /*! |
229 | Returns the URI of the security policy. |
230 | */ |
231 | QString QOpcUaEndpointDescription::securityPolicy() const |
232 | { |
233 | return data->securityPolicy; |
234 | } |
235 | |
236 | /*! |
237 | Sets the URI of the security policy to \a securityPolicy. |
238 | */ |
239 | void QOpcUaEndpointDescription::setSecurityPolicy(const QString &securityPolicy) |
240 | { |
241 | data->securityPolicy = securityPolicy; |
242 | } |
243 | |
244 | /*! |
245 | Returns the security mode supported by this endpoint. |
246 | */ |
247 | QOpcUaEndpointDescription::MessageSecurityMode QOpcUaEndpointDescription::securityMode() const |
248 | { |
249 | return data->securityMode; |
250 | } |
251 | |
252 | /*! |
253 | Sets the security mode supported by this endpoint to \a securityMode. |
254 | */ |
255 | void QOpcUaEndpointDescription::setSecurityMode(MessageSecurityMode securityMode) |
256 | { |
257 | data->securityMode = securityMode; |
258 | } |
259 | |
260 | /*! |
261 | Returns the application instance certificate of the server. |
262 | */ |
263 | QByteArray QOpcUaEndpointDescription::serverCertificate() const |
264 | { |
265 | return data->serverCertificate; |
266 | } |
267 | |
268 | /*! |
269 | Sets the application instance certificate of the server to \a serverCertificate. |
270 | */ |
271 | void QOpcUaEndpointDescription::setServerCertificate(const QByteArray &serverCertificate) |
272 | { |
273 | data->serverCertificate = serverCertificate; |
274 | } |
275 | |
276 | /*! |
277 | Returns the application description of the server. |
278 | */ |
279 | QOpcUaApplicationDescription QOpcUaEndpointDescription::server() const |
280 | { |
281 | return data->server; |
282 | } |
283 | |
284 | /*! |
285 | Returns a reference to the application description of the server. |
286 | */ |
287 | QOpcUaApplicationDescription &QOpcUaEndpointDescription::serverRef() |
288 | { |
289 | return data->server; |
290 | } |
291 | |
292 | /*! |
293 | Sets the application description of the server to \a server. |
294 | */ |
295 | void QOpcUaEndpointDescription::setServer(const QOpcUaApplicationDescription &server) |
296 | { |
297 | data->server = server; |
298 | } |
299 | |
300 | /*! |
301 | Returns the URL for the endpoint. |
302 | */ |
303 | QString QOpcUaEndpointDescription::endpointUrl() const |
304 | { |
305 | return data->endpointUrl; |
306 | } |
307 | |
308 | /*! |
309 | Sets the URL for the endpoint to \a endpointUrl. |
310 | */ |
311 | void QOpcUaEndpointDescription::setEndpointUrl(const QString &endpointUrl) |
312 | { |
313 | data->endpointUrl = endpointUrl; |
314 | } |
315 | |
316 | QT_END_NAMESPACE |
317 |