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 | |
6 | QT_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 | |
43 | class QOpcUaUserTokenPolicyData : public QSharedData |
44 | { |
45 | public: |
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 | */ |
56 | QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy() |
57 | : data(new QOpcUaUserTokenPolicyData) |
58 | { |
59 | } |
60 | |
61 | /*! |
62 | Constructs an user token policy from \a rhs. |
63 | */ |
64 | QOpcUaUserTokenPolicy::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 | */ |
72 | QOpcUaUserTokenPolicy &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 | */ |
82 | bool 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 | |
91 | QOpcUaUserTokenPolicy::~QOpcUaUserTokenPolicy() |
92 | { |
93 | } |
94 | |
95 | /*! |
96 | Returns the URI of the security policy required when encrypting or signing the token for ActivateSession. |
97 | */ |
98 | QString QOpcUaUserTokenPolicy::securityPolicy() const |
99 | { |
100 | return data->securityPolicy; |
101 | } |
102 | |
103 | /*! |
104 | Sets the URI of the security policy to \a securityPolicy. |
105 | */ |
106 | void QOpcUaUserTokenPolicy::setSecurityPolicy(const QString &securityPolicy) |
107 | { |
108 | data->securityPolicy = securityPolicy; |
109 | } |
110 | |
111 | /*! |
112 | Returns the URL of a token issuing service. |
113 | */ |
114 | QString QOpcUaUserTokenPolicy::issuerEndpointUrl() const |
115 | { |
116 | return data->issuerEndpointUrl; |
117 | } |
118 | |
119 | /*! |
120 | Sets the URL of the token issuing service to \a issuerEndpointUrl. |
121 | */ |
122 | void QOpcUaUserTokenPolicy::setIssuerEndpointUrl(const QString &issuerEndpointUrl) |
123 | { |
124 | data->issuerEndpointUrl = issuerEndpointUrl; |
125 | } |
126 | |
127 | /*! |
128 | Returns the URI for the token type. |
129 | */ |
130 | QString QOpcUaUserTokenPolicy::issuedTokenType() const |
131 | { |
132 | return data->issuedTokenType; |
133 | } |
134 | |
135 | /*! |
136 | Sets the URI for the token type to \a issuedTokenType. |
137 | */ |
138 | void QOpcUaUserTokenPolicy::setIssuedTokenType(const QString &issuedTokenType) |
139 | { |
140 | data->issuedTokenType = issuedTokenType; |
141 | } |
142 | |
143 | /*! |
144 | Returns the type of the required user identity token. |
145 | */ |
146 | QOpcUaUserTokenPolicy::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 | */ |
154 | void QOpcUaUserTokenPolicy::setTokenType(TokenType tokenType) |
155 | { |
156 | data->tokenType = tokenType; |
157 | } |
158 | |
159 | /*! |
160 | Returns a server assigned identifier for this policy. |
161 | */ |
162 | QString QOpcUaUserTokenPolicy::policyId() const |
163 | { |
164 | return data->policyId; |
165 | } |
166 | |
167 | /*! |
168 | Sets the identifier for this policy to \a policyId. |
169 | */ |
170 | void QOpcUaUserTokenPolicy::setPolicyId(const QString &policyId) |
171 | { |
172 | data->policyId = policyId; |
173 | } |
174 | |
175 | QT_END_NAMESPACE |
176 | |