From c416fd56ebba9924c1bb0caa60da667204c701e3 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 3 May 2016 11:56:08 -0300 Subject: [feat] Adapt to the new KeyManager API without key types - Related: #8031 --- src/leap/bitmask/backend/components.py | 8 +++----- src/leap/bitmask/core/mail_services.py | 9 ++++----- src/leap/bitmask/pix.py | 9 ++++----- src/leap/bitmask/services/soledad/soledadbootstrapper.py | 11 +++++------ 4 files changed, 16 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/leap/bitmask/backend/components.py b/src/leap/bitmask/backend/components.py index ba64fd65..714de4ca 100644 --- a/src/leap/bitmask/backend/components.py +++ b/src/leap/bitmask/backend/components.py @@ -987,9 +987,8 @@ class Keymanager(object): "Error exporting key. {0!r}".format(failure.value)) self._signaler.signal(self._signaler.keymanager_export_error) - dpub = keymanager.get_key(username, openpgp.OpenPGPKey) - dpriv = keymanager.get_key(username, openpgp.OpenPGPKey, - private=True) + dpub = keymanager.get_key(username) + dpriv = keymanager.get_key(username, private=True) d = defer.gatherResults([dpub, dpriv]) d.addCallback(export) d.addErrback(log_error) @@ -1011,8 +1010,7 @@ class Keymanager(object): self._signaler.signal(self._signaler.keymanager_key_details, dict(public_key)) - d = self._keymanager_proxy.get_key(username, - openpgp.OpenPGPKey) + d = self._keymanager_proxy.get_key(username) d.addCallback(signal_details) diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index fb9ee698..2e023f3b 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -31,7 +31,7 @@ from twisted.python import log from leap.bonafide import config from leap.common.service_hooks import HookableService -from leap.keymanager import KeyManager, openpgp +from leap.keymanager import KeyManager from leap.keymanager.errors import KeyNotFound from leap.soledad.client.api import Soledad from leap.mail.constants import INBOX_NAME @@ -234,7 +234,7 @@ class KeymanagerContainer(Container): # -------------------------------------------------------------- failure.trap(KeyNotFound) log.msg("Core: Key not found. Generating key for %s" % (userid,)) - d = keymanager.gen_key(openpgp.OpenPGPKey) + d = keymanager.gen_key() d.addCallbacks(send_key, log_key_error("generating")) return d @@ -244,7 +244,7 @@ class KeymanagerContainer(Container): # but this hasn't been successfully uploaded. How do we know that? # XXX Should this be a method of bonafide instead? # ----------------------------------------------------------------- - d = keymanager.send_key(openpgp.OpenPGPKey) + d = keymanager.send_key() d.addCallbacks( lambda _: log.msg( "Key generated successfully for %s" % userid), @@ -258,8 +258,7 @@ class KeymanagerContainer(Container): return failure return log_error - d = keymanager.get_key( - userid, openpgp.OpenPGPKey, private=True, fetch_remote=False) + d = keymanager.get_key(userid, private=True, fetch_remote=False) d.addErrback(if_not_found_generate) d.addCallback(lambda _: keymanager) return d diff --git a/src/leap/bitmask/pix.py b/src/leap/bitmask/pix.py index b510106d..d58944cf 100644 --- a/src/leap/bitmask/pix.py +++ b/src/leap/bitmask/pix.py @@ -26,7 +26,7 @@ from twisted.python import log from leap.bitmask.util import get_path_prefix from leap.mail.mail import Account -from leap.keymanager import openpgp, KeyNotFound +from leap.keymanager import KeyNotFound try: from pixelated.adapter.mailstore import LeapMailStore @@ -114,14 +114,13 @@ class NickNym(object): def fetch_key(self, email, private=False, fetch_remote=True): return self.keymanager.get_key( - email, openpgp.OpenPGPKey, - private=private, fetch_remote=fetch_remote) + email, private=private, fetch_remote=fetch_remote) def _gen_key(self): - return self.keymanager.gen_key(openpgp.OpenPGPKey) + return self.keymanager.gen_key() def _send_key_to_leap(self): - return self.keymanager.send_key(openpgp.OpenPGPKey) + return self.keymanager.send_key() class LeapSessionAdapter(object): diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py index 21cdee31..150ce5d8 100644 --- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py +++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py @@ -41,7 +41,7 @@ from leap.bitmask.util import here from leap.bitmask.platform_init import IS_WIN, IS_MAC from leap.common.check import leap_assert, leap_assert_type, leap_check from leap.common.files import which -from leap.keymanager import KeyManager, openpgp +from leap.keymanager import KeyManager from leap.keymanager.errors import KeyNotFound from leap.soledad.common.errors import InvalidAuthTokenError from leap.soledad.client import Soledad @@ -513,7 +513,7 @@ class SoledadBootstrapper(AbstractBootstrapper): logger.exception(failure.value) # but we do not raise - d = self._keymanager.send_key(openpgp.OpenPGPKey) + d = self._keymanager.send_key() d.addErrback(send_errback) return d else: @@ -538,12 +538,12 @@ class SoledadBootstrapper(AbstractBootstrapper): failure.trap(KeyNotFound) logger.debug("Key not found. Generating key for %s" % (address,)) - d = self._keymanager.gen_key(openpgp.OpenPGPKey) + d = self._keymanager.gen_key() d.addCallbacks(send_key, log_key_error("generating")) return d def send_key(_): - d = self._keymanager.send_key(openpgp.OpenPGPKey) + d = self._keymanager.send_key() d.addCallbacks( lambda _: logger.debug("Key generated successfully."), log_key_error("sending")) @@ -555,8 +555,7 @@ class SoledadBootstrapper(AbstractBootstrapper): return failure return log_err - d = self._keymanager.get_key( - address, openpgp.OpenPGPKey, private=True, fetch_remote=False) + d = self._keymanager.get_key(address, private=True, fetch_remote=False) d.addErrback(if_not_found_generate) return d -- cgit v1.2.3