diff sat/core/xmpp.py @ 2646:712cb4ff3e13

core: new EncryptionHandler class which manage encrypted session as a core feature: Plugin handling encryption can now register using host.registerEncryptionPlugin, and an encryption session can now be started using messageEncryptionStart bridge method. This will make encryption handling more easy, as we now know if a session is clear or e2e encrypted, and which plugin handle it.
author Goffi <goffi@goffi.org>
date Sun, 29 Jul 2018 19:22:56 +0200
parents f2cf1daa42cb
children 3a8e7ec4648a
line wrap: on
line diff
--- a/sat/core/xmpp.py	Sun Jul 29 19:22:51 2018 +0200
+++ b/sat/core/xmpp.py	Sun Jul 29 19:22:56 2018 +0200
@@ -34,6 +34,7 @@
 
 log = getLogger(__name__)
 from sat.core import exceptions
+from sat.memory import encryption
 from zope.interface import implements
 import time
 import calendar
@@ -60,6 +61,7 @@
         self._progress_cb = {}  # callback called when a progress is requested
                                 # (key = progress id)
         self.actions = {}  # used to keep track of actions for retrieval (key = action_id)
+        self.encryption = encryption.EncryptionHandler(host_app)
 
     ## initialisation ##
 
@@ -403,6 +405,7 @@
             if None, an uuid will be generated
         @param no_trigger (bool): if True, sendMessage[suffix] trigger will no be used
             useful when a message need to be sent without any modification
+            /!\ this will also skip encryption methods!
         """
         if subject is None:
             subject = {}
@@ -455,6 +458,9 @@
         send_only = data["extra"].get("send_only", False)
 
         if not no_trigger and not send_only:
+            # is the session encrypted? If so we indicate it in data
+            self.encryption.setEncryptionFlag(data)
+
             if not self.host_app.trigger.point(
                 "sendMessage" + self.trigger_suffix,
                 self,