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
53QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy()
54 : data(new QOpcUaUserTokenPolicyData)
55{
56}
57
58/*!
59 Constructs an user token policy from \a rhs.
60*/
61QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy(const QOpcUaUserTokenPolicy &rhs)
62 : data(rhs.data)
63{
64}
65
66/*!
67 Sets the values from \a rhs in this user token policy.
68*/
69QOpcUaUserTokenPolicy &QOpcUaUserTokenPolicy::operator=(const QOpcUaUserTokenPolicy &rhs)
70{
71 if (this != &rhs)
72 data.operator=(o: rhs.data);
73 return *this;
74}
75
76/*!
77 Returns \c true if this user token policy has the same value as \a rhs.
78*/
79bool QOpcUaUserTokenPolicy::operator==(const QOpcUaUserTokenPolicy &rhs) const
80{
81 return rhs.policyId() == policyId() &&
82 rhs.tokenType() == tokenType() &&
83 rhs.issuedTokenType() == issuedTokenType() &&
84 rhs.issuerEndpointUrl() == issuerEndpointUrl() &&
85 rhs.securityPolicy() == securityPolicy();
86}
87
88QOpcUaUserTokenPolicy::~QOpcUaUserTokenPolicy()
89{
90}
91
92/*!
93 Returns the URI of the security policy required when encrypting or signing the token for ActivateSession.
94*/
95QString QOpcUaUserTokenPolicy::securityPolicy() const
96{
97 return data->securityPolicy;
98}
99
100/*!
101 Sets the URI of the security policy to \a securityPolicy.
102*/
103void QOpcUaUserTokenPolicy::setSecurityPolicy(const QString &securityPolicy)
104{
105 data->securityPolicy = securityPolicy;
106}
107
108/*!
109 Returns the URL of a token issuing service.
110*/
111QString QOpcUaUserTokenPolicy::issuerEndpointUrl() const
112{
113 return data->issuerEndpointUrl;
114}
115
116/*!
117 Sets the URL of the token issuing service to \a issuerEndpointUrl.
118*/
119void QOpcUaUserTokenPolicy::setIssuerEndpointUrl(const QString &issuerEndpointUrl)
120{
121 data->issuerEndpointUrl = issuerEndpointUrl;
122}
123
124/*!
125 Returns the URI for the token type.
126*/
127QString QOpcUaUserTokenPolicy::issuedTokenType() const
128{
129 return data->issuedTokenType;
130}
131
132/*!
133 Sets the URI for the token type to \a issuedTokenType.
134*/
135void QOpcUaUserTokenPolicy::setIssuedTokenType(const QString &issuedTokenType)
136{
137 data->issuedTokenType = issuedTokenType;
138}
139
140/*!
141 Returns the type of the required user identity token.
142*/
143QOpcUaUserTokenPolicy::TokenType QOpcUaUserTokenPolicy::tokenType() const
144{
145 return data->tokenType;
146}
147
148/*!
149 Sets the type of the required user identity token to \a tokenType.
150*/
151void QOpcUaUserTokenPolicy::setTokenType(TokenType tokenType)
152{
153 data->tokenType = tokenType;
154}
155
156/*!
157 Returns a server assigned identifier for this policy.
158*/
159QString QOpcUaUserTokenPolicy::policyId() const
160{
161 return data->policyId;
162}
163
164/*!
165 Sets the identifier for this policy to \a policyId.
166*/
167void QOpcUaUserTokenPolicy::setPolicyId(const QString &policyId)
168{
169 data->policyId = policyId;
170}
171
172QT_END_NAMESPACE
173

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