|
1
|
|
|
from PyQt5.QtWidgets import QDialog, QFileDialog |
|
2
|
|
|
|
|
3
|
|
|
from uaclient.connection_ui import Ui_ConnectionDialog |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class ConnectionDialog(QDialog): |
|
7
|
|
|
def __init__(self, parent, uri): |
|
8
|
|
|
QDialog.__init__(self) |
|
9
|
|
|
self.ui = Ui_ConnectionDialog() |
|
10
|
|
|
self.ui.setupUi(self) |
|
11
|
|
|
|
|
12
|
|
|
self.uaclient = parent.uaclient |
|
13
|
|
|
self.uri = uri |
|
14
|
|
|
|
|
15
|
|
|
self.ui.modeComboBox.addItem("None") |
|
16
|
|
|
self.ui.modeComboBox.addItem("Sign") |
|
17
|
|
|
self.ui.modeComboBox.addItem("SignAndEncrypt") |
|
18
|
|
|
|
|
19
|
|
|
self.ui.policyComboBox.addItem("None") |
|
20
|
|
|
self.ui.policyComboBox.addItem("Basic128Rsa15") |
|
21
|
|
|
self.ui.policyComboBox.addItem("Basic256") |
|
22
|
|
|
|
|
23
|
|
|
self.ui.closeButton.clicked.connect(self.accept) |
|
24
|
|
|
self.ui.certificateButton.clicked.connect(self.get_certificate) |
|
25
|
|
|
self.ui.privateKeyButton.clicked.connect(self.get_private_key) |
|
26
|
|
|
|
|
27
|
|
|
@property |
|
28
|
|
|
def security_mode(self): |
|
29
|
|
|
return self.ui.modeComboBox.currentText() |
|
30
|
|
|
|
|
31
|
|
|
@security_mode.setter |
|
32
|
|
|
def security_mode(self, value): |
|
33
|
|
|
self.ui.modeComboBox.setCurrentText(value) |
|
34
|
|
|
|
|
35
|
|
|
@property |
|
36
|
|
|
def security_policy(self): |
|
37
|
|
|
return self.ui.policyComboBox.currentText() |
|
38
|
|
|
|
|
39
|
|
|
@security_policy.setter |
|
40
|
|
|
def security_policy(self, value): |
|
41
|
|
|
self.ui.policyComboBox.setCurrentText(value) |
|
42
|
|
|
|
|
43
|
|
|
@property |
|
44
|
|
|
def certificate_path(self): |
|
45
|
|
|
return self.ui.certificateLabel.text() |
|
46
|
|
|
|
|
47
|
|
|
@certificate_path.setter |
|
48
|
|
|
def certificate_path(self, value): |
|
49
|
|
|
self.ui.certificateLabel.setText(value) |
|
50
|
|
|
|
|
51
|
|
|
@property |
|
52
|
|
|
def private_key_path(self): |
|
53
|
|
|
return self.ui.privateKeyLabel.text() |
|
54
|
|
|
|
|
55
|
|
|
@private_key_path.setter |
|
56
|
|
|
def private_key_path(self, value): |
|
57
|
|
|
self.ui.privateKeyLabel.setText(value) |
|
58
|
|
|
|
|
59
|
|
|
def get_certificate(self): |
|
60
|
|
|
path, ok = QFileDialog.getOpenFileName(self, "Select certificate", self.certificate_path, "Certificate (*.der)") |
|
61
|
|
|
if ok: |
|
62
|
|
|
self.ui.certificateLabel.setText(path) |
|
63
|
|
|
|
|
64
|
|
|
def get_private_key(self): |
|
65
|
|
|
path, ok = QFileDialog.getOpenFileName(self, "Select private key", self.private_key_path, "Private key (*.pem)") |
|
66
|
|
|
if ok: |
|
67
|
|
|
self.ui.privateKeyLabel.setText(path) |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
|