blob: 8d53c1dda622b8a1768cce35a3236fe4f282ec33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* @file OpcUaAuth.h
* @brief QML component for OPC UA authentication configuration.
*/
#ifndef OPCUAAUTH_H
#define OPCUAAUTH_H
#include <QObject>
#include <QOpcUaAuthenticationInformation>
#include <QQmlEngine>
class OpcUaAuth : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY (AuthMode mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY (
QString username READ username WRITE setUsername NOTIFY usernameChanged)
Q_PROPERTY (
QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY (
QString certPath READ certPath WRITE setCertPath NOTIFY certPathChanged)
Q_PROPERTY (
QString keyPath READ keyPath WRITE setKeyPath NOTIFY keyPathChanged)
public:
/// Authentication modes supported by OPC UA.
enum AuthMode
{
Anonymous,
UserPass,
Certificate
};
Q_ENUM (AuthMode)
explicit OpcUaAuth (QObject *parent = nullptr);
AuthMode mode () const;
void setMode (AuthMode mode);
QString username () const;
void setUsername (const QString &username);
QString password () const;
void setPassword (const QString &password);
QString certPath () const;
void setCertPath (const QString &path);
QString keyPath () const;
void setKeyPath (const QString &path);
/**
* @brief Build a QOpcUaAuthenticationInformation from the
* current mode and credentials.
*/
QOpcUaAuthenticationInformation toAuthenticationInformation () const;
signals:
void modeChanged ();
void usernameChanged ();
void passwordChanged ();
void certPathChanged ();
void keyPathChanged ();
private:
AuthMode m_mode = Anonymous;
QString m_username;
QString m_password;
QString m_certPath;
QString m_keyPath;
};
#endif // OPCUAAUTH_H
|