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
。
© 2025 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.