Mercurial > libervia-backend
annotate sat_frontends/jp/cmd_encryption.py @ 3616:59d6d4afebf2
misc: update VERSION
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Aug 2021 21:51:55 +0200 |
parents | be6d91572633 |
children | 524856bd7b19 |
rev | line source |
---|---|
3137 | 1 #!/usr/bin/env python3 |
2 | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # jp: a SAT command line tool |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from sat_frontends.jp import base |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from sat_frontends.jp.constants import Const as C |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat.core.i18n import _ |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from sat.tools.common import data_format |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat_frontends.jp import xmlui_manager |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 __commands__ = ["Encryption"] |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 class EncryptionAlgorithms(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 extra_outputs = {"default": self.default_output} |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 super(EncryptionAlgorithms, self).__init__( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 host, "algorithms", |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 use_output=C.OUTPUT_LIST_DICT, |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 extra_outputs=extra_outputs, |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 use_profile=False, |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 help=_("show available encryption algorithms")) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 def add_parser_options(self): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 pass |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 def default_output(self, plugins): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 if not plugins: |
3028 | 45 self.disp(_("No encryption plugin registered!")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 else: |
3028 | 47 self.disp(_("Following encryption algorithms are available: {algos}").format( |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 algos=', '.join([p['name'] for p in plugins]))) |
3040 | 49 |
50 async def start(self): | |
51 try: | |
3102
7574f795bd1e
core, bridge: encryptionPluginsGet now returns a serialised list + added "directed" in metadata
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
52 plugins_ser = await self.host.bridge.encryptionPluginsGet() |
7574f795bd1e
core, bridge: encryptionPluginsGet now returns a serialised list + added "directed" in metadata
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
53 plugins = data_format.deserialise(plugins_ser, type_check=list) |
3040 | 54 except Exception as e: |
55 self.disp(f"can't retrieve plugins: {e}", error=True) | |
56 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
57 else: | |
58 await self.output(plugins) | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 self.host.quit() |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 class EncryptionGet(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 super(EncryptionGet, self).__init__( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 host, "get", |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 use_output=C.OUTPUT_DICT, |
3028 | 68 help=_("get encryption session data")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 def add_parser_options(self): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 self.parser.add_argument( |
3028 | 72 "jid", |
73 help=_("jid of the entity to check") | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 ) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
3040 | 76 async def start(self): |
77 jids = await self.host.check_jids([self.args.jid]) | |
78 jid = jids[0] | |
79 try: | |
80 serialised = await self.host.bridge.messageEncryptionGet(jid, self.profile) | |
81 except Exception as e: | |
82 self.disp(f"can't get session: {e}", error=True) | |
83 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
84 | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 session_data = data_format.deserialise(serialised) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 if session_data is None: |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 self.disp( |
3028 | 88 "No encryption session found, the messages are sent in plain text.") |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 self.host.quit(C.EXIT_NOT_FOUND) |
3040 | 90 await self.output(session_data) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 self.host.quit() |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 class EncryptionStart(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 super(EncryptionStart, self).__init__( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 host, "start", |
3028 | 99 help=_("start encrypted session with an entity")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 def add_parser_options(self): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 self.parser.add_argument( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 "--encrypt-noreplace", |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 action="store_true", |
3028 | 105 help=_("don't replace encryption algorithm if an other one is already used")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 algorithm = self.parser.add_mutually_exclusive_group() |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 algorithm.add_argument( |
3028 | 108 "-n", "--name", help=_("algorithm name (DEFAULT: choose automatically)")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 algorithm.add_argument( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 "-N", "--namespace", |
3028 | 111 help=_("algorithm namespace (DEFAULT: choose automatically)")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 self.parser.add_argument( |
3028 | 113 "jid", |
114 help=_("jid of the entity to stop encrypted session with") | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 ) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 |
3040 | 117 async def start(self): |
118 if self.args.name is not None: | |
119 try: | |
120 namespace = await self.host.bridge.encryptionNamespaceGet(self.args.name) | |
121 except Exception as e: | |
122 self.disp(f"can't get encryption namespace: {e}", error=True) | |
123 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
124 elif self.args.namespace is not None: | |
125 namespace = self.args.namespace | |
126 else: | |
127 namespace = "" | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 |
3040 | 129 jids = await self.host.check_jids([self.args.jid]) |
130 jid = jids[0] | |
131 | |
132 try: | |
133 await self.host.bridge.messageEncryptionStart( | |
134 jid, namespace, not self.args.encrypt_noreplace, | |
135 self.profile) | |
136 except Exception as e: | |
137 self.disp(f"can't get encryption namespace: {e}", error=True) | |
138 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
139 | |
140 self.host.quit() | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 class EncryptionStop(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 super(EncryptionStop, self).__init__( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 host, "stop", |
3028 | 148 help=_("stop encrypted session with an entity")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 def add_parser_options(self): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 self.parser.add_argument( |
3028 | 152 "jid", |
153 help=_("jid of the entity to stop encrypted session with") | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 ) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 |
3040 | 156 async def start(self): |
157 jids = await self.host.check_jids([self.args.jid]) | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 jid = jids[0] |
3040 | 159 try: |
160 await self.host.bridge.messageEncryptionStop(jid, self.profile) | |
161 except Exception as e: | |
162 self.disp(f"can't end encrypted session: {e}", error=True) | |
163 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
164 | |
165 self.host.quit() | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 class TrustUI(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 super(TrustUI, self).__init__( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 host, "ui", |
3028 | 173 help=_("get UI to manage trust")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 def add_parser_options(self): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 self.parser.add_argument( |
3028 | 177 "jid", |
178 help=_("jid of the entity to stop encrypted session with") | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 ) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 algorithm = self.parser.add_mutually_exclusive_group() |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 algorithm.add_argument( |
3028 | 182 "-n", "--name", help=_("algorithm name (DEFAULT: current algorithm)")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 algorithm.add_argument( |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 "-N", "--namespace", |
3028 | 185 help=_("algorithm namespace (DEFAULT: current algorithm)")) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 |
3040 | 187 async def start(self): |
188 if self.args.name is not None: | |
189 try: | |
190 namespace = await self.host.bridge.encryptionNamespaceGet(self.args.name) | |
191 except Exception as e: | |
192 self.disp(f"can't get encryption namespace: {e}", error=True) | |
193 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
194 elif self.args.namespace is not None: | |
195 namespace = self.args.namespace | |
196 else: | |
197 namespace = "" | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 |
3040 | 199 jids = await self.host.check_jids([self.args.jid]) |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 jid = jids[0] |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 |
3040 | 202 try: |
203 xmlui_raw = await self.host.bridge.encryptionTrustUIGet( | |
204 jid, namespace, self.profile) | |
205 except Exception as e: | |
206 self.disp(f"can't get encryption session trust UI: {e}", error=True) | |
207 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 |
3040 | 209 xmlui = xmlui_manager.create(self.host, xmlui_raw) |
210 await xmlui.show() | |
211 if xmlui.type != C.XMLUI_DIALOG: | |
212 await xmlui.submitForm() | |
213 self.host.quit() | |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 class EncryptionTrust(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 subcommands = (TrustUI,) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 super(EncryptionTrust, self).__init__( |
3028 | 220 host, "trust", use_profile=False, help=_("trust manangement") |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 ) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
224 class Encryption(base.CommandBase): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
225 subcommands = (EncryptionAlgorithms, EncryptionGet, EncryptionStart, EncryptionStop, |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 EncryptionTrust) |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
227 |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 def __init__(self, host): |
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 super(Encryption, self).__init__( |
3028 | 230 host, "encryption", use_profile=False, help=_("encryption sessions handling") |
2740
8fd8ce5a5855
jp (message/send, encryption): encryption handling:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
231 ) |