| 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 | \deprecated [6.9] |
| 22 | |
| 23 | The user token policy contains information about an user token accepted by the server. |
| 24 | */ |
| 25 | |
| 26 | /*! |
| 27 | \enum QOpcUaUserTokenPolicy::TokenType |
| 28 | |
| 29 | \value Anonymous No token required. |
| 30 | \value Username Username and password are required. |
| 31 | \value Certificate A client certificate is required. |
| 32 | \value IssuedToken Any Web Services Security (WS-Security) defined token. |
| 33 | */ |
| 34 | |
| 35 | /*! |
| 36 | \qmlproperty enumeration UserTokenPolicy::TokenType |
| 37 | |
| 38 | \value Anonymous No token required. |
| 39 | \value Username Username and password are required. |
| 40 | \value Certificate A client certificate is required. |
| 41 | \value IssuedToken Any Web Services Security (WS-Security) defined token. |
| 42 | */ |
| 43 | |
| 44 | class QOpcUaUserTokenPolicyData : public QSharedData |
| 45 | { |
| 46 | public: |
| 47 | QString policyId; |
| 48 | QOpcUaUserTokenPolicy::TokenType tokenType{QOpcUaUserTokenPolicy::TokenType::Anonymous}; |
| 49 | QString issuedTokenType; |
| 50 | QString issuerEndpointUrl; |
| 51 | QString securityPolicy; |
| 52 | }; |
| 53 | |
| 54 | /*! |
| 55 | Default constructs a user token policy with no parameters set. |
| 56 | */ |
| 57 | QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy() |
| 58 | : data(new QOpcUaUserTokenPolicyData) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | /*! |
| 63 | Constructs an user token policy from \a rhs. |
| 64 | */ |
| 65 | QOpcUaUserTokenPolicy::QOpcUaUserTokenPolicy(const QOpcUaUserTokenPolicy &rhs) |
| 66 | : data(rhs.data) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | /*! |
| 71 | Sets the values from \a rhs in this user token policy. |
| 72 | */ |
| 73 | QOpcUaUserTokenPolicy &QOpcUaUserTokenPolicy::operator=(const QOpcUaUserTokenPolicy &rhs) |
| 74 | { |
| 75 | if (this != &rhs) |
| 76 | data.operator=(o: rhs.data); |
| 77 | return *this; |
| 78 | } |
| 79 | |
| 80 | /*! |
| 81 | Returns \c true if this user token policy has the same value as \a rhs. |
| 82 | */ |
| 83 | bool QOpcUaUserTokenPolicy::operator==(const QOpcUaUserTokenPolicy &rhs) const |
| 84 | { |
| 85 | return rhs.policyId() == policyId() && |
| 86 | rhs.tokenType() == tokenType() && |
| 87 | rhs.issuedTokenType() == issuedTokenType() && |
| 88 | rhs.issuerEndpointUrl() == issuerEndpointUrl() && |
| 89 | rhs.securityPolicy() == securityPolicy(); |
| 90 | } |
| 91 | |
| 92 | QOpcUaUserTokenPolicy::~QOpcUaUserTokenPolicy() |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | /*! |
| 97 | Returns the URI of the security policy required when encrypting or signing the token for ActivateSession. |
| 98 | |
| 99 | The Basic128Rsa15 and Basic256 security policies are deprecated and should only be used |
| 100 | for backward compatibility if the server doesn't support any of the policies currently |
| 101 | considered as secure. |
| 102 | */ |
| 103 | QString QOpcUaUserTokenPolicy::securityPolicy() const |
| 104 | { |
| 105 | return data->securityPolicy; |
| 106 | } |
| 107 | |
| 108 | /*! |
| 109 | Sets the URI of the security policy to \a securityPolicy. |
| 110 | |
| 111 | The Basic128Rsa15 and Basic256 security policies are deprecated and should only be used |
| 112 | for backward compatibility if the server doesn't support any of the policies currently |
| 113 | considered as secure. |
| 114 | */ |
| 115 | void QOpcUaUserTokenPolicy::setSecurityPolicy(const QString &securityPolicy) |
| 116 | { |
| 117 | data->securityPolicy = securityPolicy; |
| 118 | } |
| 119 | |
| 120 | /*! |
| 121 | Returns the URL of a token issuing service. |
| 122 | */ |
| 123 | QString QOpcUaUserTokenPolicy::issuerEndpointUrl() const |
| 124 | { |
| 125 | return data->issuerEndpointUrl; |
| 126 | } |
| 127 | |
| 128 | /*! |
| 129 | Sets the URL of the token issuing service to \a issuerEndpointUrl. |
| 130 | */ |
| 131 | void QOpcUaUserTokenPolicy::setIssuerEndpointUrl(const QString &issuerEndpointUrl) |
| 132 | { |
| 133 | data->issuerEndpointUrl = issuerEndpointUrl; |
| 134 | } |
| 135 | |
| 136 | /*! |
| 137 | Returns the URI for the token type. |
| 138 | */ |
| 139 | QString QOpcUaUserTokenPolicy::issuedTokenType() const |
| 140 | { |
| 141 | return data->issuedTokenType; |
| 142 | } |
| 143 | |
| 144 | /*! |
| 145 | Sets the URI for the token type to \a issuedTokenType. |
| 146 | */ |
| 147 | void QOpcUaUserTokenPolicy::setIssuedTokenType(const QString &issuedTokenType) |
| 148 | { |
| 149 | data->issuedTokenType = issuedTokenType; |
| 150 | } |
| 151 | |
| 152 | /*! |
| 153 | Returns the type of the required user identity token. |
| 154 | */ |
| 155 | QOpcUaUserTokenPolicy::TokenType QOpcUaUserTokenPolicy::tokenType() const |
| 156 | { |
| 157 | return data->tokenType; |
| 158 | } |
| 159 | |
| 160 | /*! |
| 161 | Sets the type of the required user identity token to \a tokenType. |
| 162 | */ |
| 163 | void QOpcUaUserTokenPolicy::setTokenType(TokenType tokenType) |
| 164 | { |
| 165 | data->tokenType = tokenType; |
| 166 | } |
| 167 | |
| 168 | /*! |
| 169 | Returns a server assigned identifier for this policy. |
| 170 | */ |
| 171 | QString QOpcUaUserTokenPolicy::policyId() const |
| 172 | { |
| 173 | return data->policyId; |
| 174 | } |
| 175 | |
| 176 | /*! |
| 177 | Sets the identifier for this policy to \a policyId. |
| 178 | */ |
| 179 | void QOpcUaUserTokenPolicy::setPolicyId(const QString &policyId) |
| 180 | { |
| 181 | data->policyId = policyId; |
| 182 | } |
| 183 | |
| 184 | QT_END_NAMESPACE |
| 185 |
