QOpcUaGdsClient Class

Handles communication with the GDS Server. 更多...

头: #include <QOpcUaGdsClient>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
继承: QObject

公共类型

enum class Error { NoError, InvalidBackend, InvalidEndpoint, ConnectionError, DirectoryNodeNotFound, …, FailedToGetCertificate }
enum class State { Idle, BackendInstantiated, Connecting, Connected, RegisteringApplication, …, Error }

公共函数

QOpcUaGdsClient (QObject * parent = nullptr)
virtual ~QOpcUaGdsClient ()
QString applicationId () const
const QOpcUaApplicationIdentity & applicationIdentity () const
const QOpcUaApplicationRecordDataType & applicationRecord () const
const QString & backend () const
int certificateCheckInterval () const
const QOpcUaX509DistinguishedName & distinguishedNameCertificateSigningRequestPreset () const
const QString & dnsCertificateSigningRequestPreset () const
const QOpcUaEndpointDescription & endpoint () const
QOpcUaGdsClient::Error error () const
const QOpcUaPkiConfiguration & pkiConfiguration () const
void setApplicationIdentity (const QOpcUaApplicationIdentity & appIdentity )
void setApplicationRecord (const QOpcUaApplicationRecordDataType & appRecord )
void setBackend (const QString & backend )
void setCertificateCheckInterval (int interval )
void setCertificateSigningRequestPresets (const QOpcUaX509DistinguishedName & dn , const QString & dns )
void setEndpoint (const QOpcUaEndpointDescription & endpoint )
void setPkiConfiguration (const QOpcUaPkiConfiguration & pkiConfig )
void setTrustListUpdateInterval (int interval )
void start ()
QOpcUaGdsClient::State state () const
int trustListUpdateInterval () const
void unregisterApplication ()

信号

void applicationRegistered ()
void authenticationRequired (QOpcUaAuthenticationInformation & authInfo )
void certificateGroupsReceived (QStringList certificateGroups )
void certificateUpdateRequired ()
void certificateUpdated ()
void errorChanged (QOpcUaGdsClient::Error error )
void stateChanged (QOpcUaGdsClient::State state )
void trustListUpdated ()
void unregistered ()

详细描述

This class is currently available as a Technology Preview, and therefore the API and functionality provided by the class may be subject to change at any time without prior notice.

This class handles all steps needed for communication with a GDS server. Provided with information about the application it does registering with the server and managing key/certificates.

Only few details need to be known in order to take part in a secured network.

First time registration requires administrative privileges using username and password for authentication. All further authentications are application based, using the certificate which was received first.

Expecting the whole process to succeed, you have to wait for the applicationRegistered 信号。

Most of the setup structs have to be the same as for the connection with QOpcUaClient afterwards and can be shared.

Setting up a GDS client:

QOpcUaGdsClient c;
// In case the credentials are needed
QObject::connect(&c, &QOpcUaGdsClient::authenticationRequired, [&](QOpcUaAuthenticationInformation &authInfo) {
        authInfo.setUsernameAuthentication("root", "secret");
 });
// Await success
QObject::connect(&c, &QOpcUaGdsClient::applicationRegistered, [&]() {
    qDebug() << "Application" << c.applicationId() << "registered";
});
c.setBackend(...);
c.setEndpoint(...);
c.setApplicationIdentity(...);
c.setPkiConfiguration(...);
c.setApplicationRecord(...);
c.setCertificateSigningRequestPresets(...);
c.start();
					

成员类型文档编制

enum class QOpcUaGdsClient:: Error

This enum is used to specify errors, that could happen during the registration process.

常量 描述
QOpcUaGdsClient::Error::NoError 0 Everying is fine
QOpcUaGdsClient::Error::InvalidBackend 1 The backend could not be instantiated. The backend string given, does not match any backend or loading the plugin failed.
QOpcUaGdsClient::Error::InvalidEndpoint 2 The given endpoint is not valid.
QOpcUaGdsClient::Error::ConnectionError 3 The connection to the server endpoint failed.
QOpcUaGdsClient::Error::DirectoryNodeNotFound 4 The directory node on the server could not be resolved
QOpcUaGdsClient::Error::FailedToRegisterApplication 5 The registration of the application was not successful.
QOpcUaGdsClient::Error::FailedToUnregisterApplication 6 The unregistration of the application was not successful.
QOpcUaGdsClient::Error::FailedToGetCertificateStatus 7 The status of the current certificate could not be retrieved.
QOpcUaGdsClient::Error::FailedToGetCertificate 8 A certificate could not be retrieved from the server.

enum class QOpcUaGdsClient:: State

This enum is used to specify the current state of the registration of the GDS client.

常量 描述
QOpcUaGdsClient::State::Idle 0 The client was not started yet.
QOpcUaGdsClient::State::BackendInstantiated 1 The backend was instantiated
QOpcUaGdsClient::State::Connecting 2 A connecting to the server is being made
QOpcUaGdsClient::State::Connected 3 The connection to the server endpoint was successful.
QOpcUaGdsClient::State::RegisteringApplication 4 The application is being registered with the server.
QOpcUaGdsClient::State::ApplicationRegistered 5 Registering the application with the server was successful.
QOpcUaGdsClient::State::Error 6 An error happened. See the return value of error () and the terminal output for more details.

成员函数文档编制

QOpcUaGdsClient:: QOpcUaGdsClient ( QObject * parent = nullptr)

Constructs a GDS client with parent 作为父级对象。

[virtual noexcept] QOpcUaGdsClient:: ~QOpcUaGdsClient ()

Destructs a GDS client.

QString QOpcUaGdsClient:: applicationId () const

Returns the application id assigned by the server.

Is is a shortcut to receive the application id from the application record data.

另请参阅 applicationRecord ().

const QOpcUaApplicationIdentity &QOpcUaGdsClient:: applicationIdentity () const

Returns the current applicationIdentity.

另请参阅 setApplicationIdentity ().

const QOpcUaApplicationRecordDataType &QOpcUaGdsClient:: applicationRecord () const

Returns the application record data that is used by the client.

另请参阅 setApplicationRecord ().

[signal] void QOpcUaGdsClient:: applicationRegistered ()

This signal is emitted when an application was registered successfully.

[signal] void QOpcUaGdsClient:: authenticationRequired ( QOpcUaAuthenticationInformation & authInfo )

This signal is emitted when the GDS client tries to do a first time authentication with a server, that requires administrative privileges.

authInfo has to be filled with valid authentication information. This slot must not be used crossing thread boundaries.

const QString &QOpcUaGdsClient:: backend () const

Returns the current backend setting.

If the backend was changed after starting the client, it will return the changed setting, but not the actually used instance.

另请参阅 setBackend ().

int QOpcUaGdsClient:: certificateCheckInterval () const

Returns the interval in milliseconds for checking the validity of the client certificate.

另请参阅 setCertificateCheckInterval ().

[signal] void QOpcUaGdsClient:: certificateGroupsReceived ( QStringList certificateGroups )

This signal is emitted when the GDS client receives a new list of certificateGroups for this application.

[signal] void QOpcUaGdsClient:: certificateUpdateRequired ()

This signal is emitted when the GDS client detects that an update of the currently used certificate is necessary.

This could be caused by the server, requesting the client to update the certificate, when the certificate's due date is met or if the certificate is self-signed.

The certificate update is handled automatically. This signal is only for informational purpose that an update is going to happen.

[signal] void QOpcUaGdsClient:: certificateUpdated ()

This signal is emitted when the GDS client received a new certificate that was stored on disk.

const QOpcUaX509DistinguishedName &QOpcUaGdsClient:: distinguishedNameCertificateSigningRequestPreset () const

Returns the distinguished name preset for certificate siging requests.

const QString &QOpcUaGdsClient:: dnsCertificateSigningRequestPreset () const

Returns the DNS preset for certificate siging requests.

const QOpcUaEndpointDescription &QOpcUaGdsClient:: endpoint () const

Returns the current endpoint setting.

If the endpoint was changed after starting the client, it will return the changed setting, but not the actually used endpoint.

另请参阅 setEndpoint ().

QOpcUaGdsClient::Error QOpcUaGdsClient:: error () const

返回当前错误状态。

[signal] void QOpcUaGdsClient:: errorChanged ( QOpcUaGdsClient::Error error )

此信号发射当 error 出现。

const QOpcUaPkiConfiguration &QOpcUaGdsClient:: pkiConfiguration () const

Returns the current pkiConfiguration.

另请参阅 setPkiConfiguration ().

void QOpcUaGdsClient:: setApplicationIdentity (const QOpcUaApplicationIdentity & appIdentity )

Sets the application identity appIdentity to be used by the client.

This identity is used to register with the GDS server. This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

另请参阅 applicationIdentity ().

void QOpcUaGdsClient:: setApplicationRecord (const QOpcUaApplicationRecordDataType & appRecord )

Sets the application record data appRecord to be used by the client.

This data is used to register with the GDS server. This function has to be called before starting the GDS client.

Most of the data is the same as in the application identity. After registration the assigned application id can be retrieved.

另请参阅 applicationRecord () 和 setApplicationIdentity .

void QOpcUaGdsClient:: setBackend (const QString & backend )

Sets the backend to be used by the client to communicate with the server to backend .

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

另请参阅 backend (), QOpcUaProvider::availableBackends (),和 start ().

void QOpcUaGdsClient:: setCertificateCheckInterval ( int interval )

Sets the interval in milliseconds for checking the validity of the client certificate to interval .

另请参阅 certificateCheckInterval ().

void QOpcUaGdsClient:: setCertificateSigningRequestPresets (const QOpcUaX509DistinguishedName & dn , const QString & dns )

Sets the presets for certificate siging requests; the distinguished name dn and the DNS string dns .

When creating a certificate signing request some additional information is needed, that is not provided by the application identity.

This function has to be called before starting the GDS client.

另请参阅 setApplicationIdentity ().

void QOpcUaGdsClient:: setEndpoint (const QOpcUaEndpointDescription & endpoint )

Sets the endpoint to be used by the client to communicate with the server to endpoint .

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

Communication to a GDS server is only possible through an encrypted endpoint. Using an unencrypted endpoint will fail.

另请参阅 endpoint ().

void QOpcUaGdsClient:: setPkiConfiguration (const QOpcUaPkiConfiguration & pkiConfig )

Sets the PKI configuration pkiConfig to be used by the client.

All certificates, keys and trust lists will be used from or stored to the locations given. In order to use the certificate received from the GDS, the same configuration has to be used with QOpcUaClient .

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

另请参阅 pkiConfiguration ().

void QOpcUaGdsClient:: setTrustListUpdateInterval ( int interval )

Sets the interval in milliseconds for updating the trust list from the server to interval .

另请参阅 trustListUpdateInterval ().

void QOpcUaGdsClient:: start ()

Starts the client process.

After setting up all information, the client can be started.

QOpcUaGdsClient::State QOpcUaGdsClient:: state () const

Returns the current client state.

[signal] void QOpcUaGdsClient:: stateChanged ( QOpcUaGdsClient::State state )

This signal is emitted when the internal state of the client changes. The state indicates the new state.

int QOpcUaGdsClient:: trustListUpdateInterval () const

Returns the interval in milliseconds for updating the trust list from the server.

另请参阅 setTrustListUpdateInterval ().

[signal] void QOpcUaGdsClient:: trustListUpdated ()

This signal is emitted when the GDS client has received a new trust list from the server and stored to disk.

void QOpcUaGdsClient:: unregisterApplication ()

Unregisters an application from the server.

This function can be used when an application has to be removed permanently from the network. It does not need to be called when rebooting or shutting down.

[signal] void QOpcUaGdsClient:: unregistered ()

This signal is emitted when the GDS client has unregistered the application.