QOpcUaAuthenticationInformation Class

The OPC UA authentication information. More...

Header: #include <QOpcUaAuthenticationInformation>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
Since: QtOpcUa 5.13

Public Functions

QOpcUaAuthenticationInformation(const QOpcUaAuthenticationInformation &rhs)
const QVariant &authenticationData() const
QOpcUaUserTokenPolicy::TokenType authenticationType() const
void setAnonymousAuthentication()
void setCertificateAuthentication()
void setUsernameAuthentication(const QString &username, const QString &password)
QOpcUaAuthenticationInformation &operator=(const QOpcUaAuthenticationInformation &rhs)
bool operator==(const QOpcUaAuthenticationInformation &rhs) const

Detailed Description

This class holds the information necessary to perform a login on a server. Supported authentication mechanisms are

  • Anonymous
  • Username
  • Certificate

The anonymous method is used by default but also can be set manually.

This is an example authentication using username and password.

QOpcUaAuthenticationInformation authInfo;
authInfo.setUsernameAuthentication("user", "password");

m_client->setAuthenticationInformation(authInfo);
m_client->connectToEndpoint(endpoint);

See also setAnonymousAuthentication(), setUsernameAuthentication(), and setCertificateAuthentication().

Member Function Documentation

QOpcUaAuthenticationInformation::QOpcUaAuthenticationInformation(const QOpcUaAuthenticationInformation &rhs)

Constructs an authentication information from rhs.

const QVariant &QOpcUaAuthenticationInformation::authenticationData() const

The content of the QVariant returned by this method depends on the currently selected authentication method.

[invokable] QOpcUaUserTokenPolicy::TokenType QOpcUaAuthenticationInformation::authenticationType() const

Returns the current authentication type.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also QOpcUaUserTokenPolicy::TokenType.

[invokable] void QOpcUaAuthenticationInformation::setAnonymousAuthentication()

Sets the authentication method to anonymous.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QOpcUaAuthenticationInformation::setCertificateAuthentication()

Sets the authentication method to use certificates.

When using this authentication type a proper configured QOpcUaPkiConfiguration has to be set to the QOpcUaClient.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also QOpcUaPkiConfiguration and QOpcUaClient::setPkiConfiguration().

[invokable] void QOpcUaAuthenticationInformation::setUsernameAuthentication(const QString &username, const QString &password)

Sets the authentication method to username, using the given username and password.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

QOpcUaAuthenticationInformation &QOpcUaAuthenticationInformation::operator=(const QOpcUaAuthenticationInformation &rhs)

Sets the values from rhs in this authentication information.

bool QOpcUaAuthenticationInformation::operator==(const QOpcUaAuthenticationInformation &rhs) const

Returns true if this authentication information has the same value as rhs.

© 2023 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.