1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QOPCUAGDSCLIENTPRIVATE_H |
5 | #define QOPCUAGDSCLIENTPRIVATE_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QOpcUaClient> |
19 | #include <QOpcUaAuthenticationInformation> |
20 | #include <QOpcUaApplicationRecordDataType> |
21 | #include <QOpcUaEndpointDescription> |
22 | #include <QOpcUaPkiConfiguration> |
23 | #include <private/qobject_p.h> |
24 | #include "qopcuagdsclient.h" |
25 | #include <QOpcUaX509CertificateSigningRequest> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QTimer; |
30 | |
31 | #define ApplicationRecordDataType_Encoding_DefaultBinary 134 |
32 | |
33 | class QOpcUaGdsClientPrivate : public QObjectPrivate |
34 | { |
35 | Q_DECLARE_PUBLIC(QOpcUaGdsClient) |
36 | public: |
37 | QOpcUaGdsClientPrivate(); |
38 | ~QOpcUaGdsClientPrivate(); |
39 | |
40 | void initializePrivateConnections(); |
41 | |
42 | void setEndpoint(const QOpcUaEndpointDescription &url); |
43 | const QOpcUaEndpointDescription &endpoint() const; |
44 | |
45 | void setBackend(const QString &); |
46 | const QString &backend() const; |
47 | |
48 | void setPkiConfiguration(const QOpcUaPkiConfiguration &pkiConfig); |
49 | const QOpcUaPkiConfiguration &pkiConfiguration() const; |
50 | |
51 | void setApplicationIdentity(const QOpcUaApplicationIdentity &appIdentity); |
52 | const QOpcUaApplicationIdentity &applicationIdentity() const; |
53 | |
54 | void setApplicationRecord(const QOpcUaApplicationRecordDataType &appIdentity); |
55 | const QOpcUaApplicationRecordDataType &applicationRecord() const; |
56 | |
57 | void setCertificateSigningRequestPresets(const QOpcUaX509DistinguishedName &dn, const QString &dns); |
58 | const QOpcUaX509DistinguishedName &distinguishedNameCertificateSigningRequestPreset() const; |
59 | const QString &dnsCertificateSigningRequestPreset() const; |
60 | |
61 | void setCertificateCheckInterval(int timeout); |
62 | int certificateCheckInterval() const; |
63 | |
64 | void setTrustListUpdateInterval(int interval); |
65 | int trustListUpdateInterval() const; |
66 | |
67 | void start(); |
68 | void unregisterApplication(); |
69 | QString applicationId() const; |
70 | |
71 | QOpcUaGdsClient::Error error() const; |
72 | QOpcUaGdsClient::State state() const; |
73 | |
74 | |
75 | private: |
76 | void setError(QOpcUaGdsClient::Error); |
77 | void setState(QOpcUaGdsClient::State); |
78 | void _q_handleDirectoryNodeMethodCallFinished(QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode); |
79 | void _q_handleResolveBrowsePathFinished(QList<QOpcUaBrowsePathTarget> targets, QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode statusCode); |
80 | void _q_certificateCheckTimeout(); |
81 | void _q_updateTrustList(); |
82 | |
83 | void getApplication(); |
84 | void registerApplication(); |
85 | void resolveMethodNodes(); |
86 | void resolveDirectoryNode(); |
87 | void findRegisteredApplication(); |
88 | void getCertificateGroups(); |
89 | void resolveCertificateTypes(); |
90 | void getCertificateTypes(); |
91 | void getCertificateStatus(); |
92 | void startCertificateRequest(); |
93 | void finishCertificateRequest(); |
94 | void localCertificateCheck(); |
95 | void registrationDone(); |
96 | void restartWithCredentials(); |
97 | void handleUnregisterApplicationFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
98 | void handleFinishRequestFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
99 | void handleStartSigningRequestFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
100 | void handleGetCertificateStatusFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
101 | void handleGetCertificateGroupsFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
102 | void handleRegisterApplicationFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
103 | void handleFindApplicationsFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
104 | void handleGetApplicationFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
105 | void handleGetTrustListFinished(const QVariant &result, QOpcUa::UaStatusCode statusCode); |
106 | QOpcUaX509CertificateSigningRequest createSigningRequest() const; |
107 | |
108 | QOpcUaClient *m_client = nullptr; |
109 | QOpcUaEndpointDescription m_endpoint; |
110 | QOpcUaPkiConfiguration m_pkiConfig; |
111 | QOpcUaApplicationIdentity m_appIdentitiy; |
112 | QOpcUaApplicationRecordDataType m_appRecord; |
113 | QString m_backend; |
114 | QStringList m_certificateGroups; |
115 | QOpcUaGdsClient::Error m_error = QOpcUaGdsClient::Error::NoError; |
116 | QOpcUaGdsClient::State m_state = QOpcUaGdsClient::State::Idle; |
117 | QMap<QString, QString> m_directoryNodes; |
118 | QOpcUaNode *m_directoryNode = nullptr; |
119 | QOpcUaNode *m_certificateGroupNode = nullptr; |
120 | QString m_certificateTypesNodeId; |
121 | int m_gdsNamespaceIndex = -1; |
122 | QOpcUaNode *m_certificateTypesNode = nullptr; |
123 | QOpcUaNode *m_trustListNode = nullptr; |
124 | QTimer *m_certificateFinishTimer = nullptr; |
125 | QTimer *m_certificateCheckTimer = nullptr; |
126 | QString m_certificateRequestId; |
127 | QTimer *m_trustListUpdateTimer = nullptr; |
128 | bool m_restartRequired = false; |
129 | QString m_configFilePath; |
130 | |
131 | struct { |
132 | QOpcUaX509DistinguishedName dn; |
133 | QString dns; |
134 | } csrPresets; |
135 | }; |
136 | |
137 | QT_END_NAMESPACE |
138 | |
139 | #endif // QOPCUAGDSCLIENTPRIVATE_H |
140 | |
141 | |