QOpcUaAuthenticationInformation Class
OPC UA 身份验证信息。更多内容...
| 标题: | #include <QOpcUaAuthenticationInformation> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
| qmake: | QT += opcua |
| 自: | QtOpcUa 5.13 |
公共函数
| QOpcUaAuthenticationInformation() | |
| QOpcUaAuthenticationInformation(const QOpcUaAuthenticationInformation &rhs) | |
| const QVariant & | authenticationData() const |
| QOpcUaUserTokenPolicy::TokenType | authenticationType() const |
| void | setAnonymousAuthentication() |
| void | setCertificateAuthentication() |
(since 6.9) void | setCertificateAuthentication(const QString &certificatePath, const QString &privateKeyPath) |
| void | setUsernameAuthentication(const QString &username, const QString &password) |
| QOpcUaAuthenticationInformation & | operator=(const QOpcUaAuthenticationInformation &rhs) |
| bool | operator==(const QOpcUaAuthenticationInformation &rhs) const |
详细说明
此类包含在服务器上执行登录所需的信息。支持的身份验证机制包括
- 匿名
- 用户名
- 证书
默认使用匿名方法,但也可以手动设置。
这是一个使用用户名和密码进行身份验证的示例。
QOpcUaAuthenticationInformation authInfo;
authInfo.setUsernameAuthentication("user", "password");
m_client->setAuthenticationInformation(authInfo);
m_client->connectToEndpoint(endpoint);另请参阅 setAnonymousAuthentication()、setUsernameAuthentication() 和setCertificateAuthentication()。
成员函数文档
QOpcUaAuthenticationInformation::QOpcUaAuthenticationInformation()
默认情况下,会构建一个未设置任何参数的身份验证信息。
QOpcUaAuthenticationInformation::QOpcUaAuthenticationInformation(const QOpcUaAuthenticationInformation &rhs)
根据rhs 构建一个身份验证信息。
const QVariant &QOpcUaAuthenticationInformation::authenticationData() const
此方法返回的QVariant 的内容取决于当前选定的身份验证方法。
[invokable] QOpcUaUserTokenPolicy::TokenType QOpcUaAuthenticationInformation::authenticationType() const
返回当前的身份验证类型。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 QOpcUaUserTokenPolicy::TokenType 。
[invokable] void QOpcUaAuthenticationInformation::setAnonymousAuthentication()
将身份验证方法设置为匿名。
注意:该 函数可通过元对象系统以及从 QML 中调用。请参阅Q_INVOKABLE 。
[invokable] void QOpcUaAuthenticationInformation::setCertificateAuthentication()
将身份验证方法设置为使用证书。
使用此身份验证类型时,必须将已正确配置的QOpcUaPkiConfiguration 设置为QOpcUaClient 。
注意: 可通过元对象系统和QML调用此 函数。参见Q_INVOKABLE 。
另请参阅 QOpcUaPkiConfiguration 和QOpcUaClient::setPkiConfiguration()。
[invokable, since 6.9] void QOpcUaAuthenticationInformation::setCertificateAuthentication(const QString &certificatePath, const QString &privateKeyPath)
将身份验证方法设置为证书身份验证,且使用的证书与客户端证书不同。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
该函数于 Qt 6.9 中引入。
[invokable] void QOpcUaAuthenticationInformation::setUsernameAuthentication(const QString &username, const QString &password)
将身份验证方法设置为“用户名”,并使用给定的username 和password 。
注意:此 函数可通过元对象系统以及从 QML 中调用。请参阅Q_INVOKABLE 。
QOpcUaAuthenticationInformation &QOpcUaAuthenticationInformation::operator=(const QOpcUaAuthenticationInformation &rhs)
将rhs 中的值设置到此身份验证信息中。
bool QOpcUaAuthenticationInformation::operator==(const QOpcUaAuthenticationInformation &rhs) const
如果此身份验证信息与rhs 的值相同,则返回true 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.