1// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qopcuausertokenpolicy.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaUserTokenPolicy
10 \inmodule QtOpcUa
11 \brief The OPC UA UserTokenPolicy.
12
13 The user token policy contains information about an user token accepted by the server.
14*/
15
16/*!
17 \qmltype UserTokenPolicy
18 \inqmlmodule QtOpcUa
19 \brief The OPC UA ApplicationDescription.
20 \since QtOpcUa 5.13
21
22 The user token policy contains information about an user token accepted by the server.
23*/
24
25/*!
26 \enum QOpcUaUserTokenPolicy::TokenType
27
28 \value Anonymous No token required.
29 \value Username Username and password are required.
30 \value Certificate A client certificate is required.
31 \value IssuedToken Any Web Services Security (WS-Security) defined token.
32*/
33
34/*!
35 \qmlproperty enumeration UserTokenPolicy::TokenType
36
37 \value Anonymous No token required.
38 \value Username Username and password are required.
39 \value Certificate A client certificate is required.
40 \value IssuedToken Any Web Services Security (WS-Security) defined token.
41*/
42
43class QOpcUaUserTokenPolicyData : public QSharedData
44{
45public:
46 QString policyId;
47 QOpcUaUserTokenPolicy::TokenType tokenType{QOpcUaUserTokenPolicy::TokenType::Anonymous};
48 QString issuedTokenType;
49 QString issuerEndpointUrl;
50 QString securityPolicy;
51};
52
53/*!
54 Default constructs a user token policy with no parameters set.
55*/
56QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy()
57 : data(new QOpcUaUserTokenPolicyData)
58{
59}
60
61/*!
62 Constructs an user token policy from \a rhs.
63*/
64QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy(const QOpcUaUserTokenPolicy &rhs)
65 : data(rhs.data)
66{
67}
68
69/*!
70 Sets the values from \a rhs in this user token policy.
71*/
72QOpcUaUserTokenPolicy &QOpcUaUserTokenPolicy::operator=(const QOpcUaUserTokenPolicy &rhs)
73{
74 if (this != &rhs)
75 data.operator=(o: rhs.data);
76 return *this;
77}
78
79/*!
80 Returns \c true if this user token policy has the same value as \a rhs.
81*/
82bool QOpcUaUserTokenPolicy::operator==(const QOpcUaUserTokenPolicy &rhs) const
83{
84 return rhs.policyId() == policyId() &&
85 rhs.tokenType() == tokenType() &&
86 rhs.issuedTokenType() == issuedTokenType() &&
87 rhs.issuerEndpointUrl() == issuerEndpointUrl() &&
88 rhs.securityPolicy() == securityPolicy();
89}
90
91QOpcUaUserTokenPolicy::~QOpcUaUserTokenPolicy()
92{
93}
94
95/*!
96 Returns the URI of the security policy required when encrypting or signing the token for ActivateSession.
97*/
98QString QOpcUaUserTokenPolicy::securityPolicy() const
99{
100 return data->securityPolicy;
101}
102
103/*!
104 Sets the URI of the security policy to \a securityPolicy.
105*/
106void QOpcUaUserTokenPolicy::setSecurityPolicy(const QString &securityPolicy)
107{
108 data->securityPolicy = securityPolicy;
109}
110
111/*!
112 Returns the URL of a token issuing service.
113*/
114QString QOpcUaUserTokenPolicy::issuerEndpointUrl() const
115{
116 return data->issuerEndpointUrl;
117}
118
119/*!
120 Sets the URL of the token issuing service to \a issuerEndpointUrl.
121*/
122void QOpcUaUserTokenPolicy::setIssuerEndpointUrl(const QString &issuerEndpointUrl)
123{
124 data->issuerEndpointUrl = issuerEndpointUrl;
125}
126
127/*!
128 Returns the URI for the token type.
129*/
130QString QOpcUaUserTokenPolicy::issuedTokenType() const
131{
132 return data->issuedTokenType;
133}
134
135/*!
136 Sets the URI for the token type to \a issuedTokenType.
137*/
138void QOpcUaUserTokenPolicy::setIssuedTokenType(const QString &issuedTokenType)
139{
140 data->issuedTokenType = issuedTokenType;
141}
142
143/*!
144 Returns the type of the required user identity token.
145*/
146QOpcUaUserTokenPolicy::TokenType QOpcUaUserTokenPolicy::tokenType() const
147{
148 return data->tokenType;
149}
150
151/*!
152 Sets the type of the required user identity token to \a tokenType.
153*/
154void QOpcUaUserTokenPolicy::setTokenType(TokenType tokenType)
155{
156 data->tokenType = tokenType;
157}
158
159/*!
160 Returns a server assigned identifier for this policy.
161*/
162QString QOpcUaUserTokenPolicy::policyId() const
163{
164 return data->policyId;
165}
166
167/*!
168 Sets the identifier for this policy to \a policyId.
169*/
170void QOpcUaUserTokenPolicy::setPolicyId(const QString &policyId)
171{
172 data->policyId = policyId;
173}
174
175QT_END_NAMESPACE
176

Provided by KDAB

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

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