summaryrefslogtreecommitdiffstats
path: root/src/OpcUaAuth.cpp
blob: 258c9c7aaf774d6ab5b93e14bb35dd4a740797c5 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 * @file   OpcUaAuth.cpp
 * @brief  OpcUaAuth implementation.
 */
#include "OpcUaAuth.h"

OpcUaAuth::OpcUaAuth (QObject *parent) : QObject (parent) {}

OpcUaAuth::AuthMode
OpcUaAuth::mode () const
{
  return m_mode;
}

void
OpcUaAuth::setMode (AuthMode mode)
{
  if (m_mode == mode)
    return;
  m_mode = mode;
  emit modeChanged ();
}

QString
OpcUaAuth::username () const
{
  return m_username;
}

void
OpcUaAuth::setUsername (const QString &username)
{
  if (m_username == username)
    return;
  m_username = username;
  emit usernameChanged ();
}

QString
OpcUaAuth::password () const
{
  return m_password;
}

void
OpcUaAuth::setPassword (const QString &password)
{
  if (m_password == password)
    return;
  m_password = password;
  emit passwordChanged ();
}

QString
OpcUaAuth::certPath () const
{
  return m_certPath;
}

void
OpcUaAuth::setCertPath (const QString &path)
{
  if (m_certPath == path)
    return;
  m_certPath = path;
  emit certPathChanged ();
}

QString
OpcUaAuth::keyPath () const
{
  return m_keyPath;
}

void
OpcUaAuth::setKeyPath (const QString &path)
{
  if (m_keyPath == path)
    return;
  m_keyPath = path;
  emit keyPathChanged ();
}

QOpcUaAuthenticationInformation
OpcUaAuth::toAuthenticationInformation () const
{
  QOpcUaAuthenticationInformation info;
  switch (m_mode)
    {
    case Anonymous:
      info.setAnonymousAuthentication ();
      break;
    case UserPass:
      info.setUsernameAuthentication (m_username, m_password);
      break;
    case Certificate:
      info.setCertificateAuthentication (m_certPath, m_keyPath);
      break;
    }
  return info;
}