Unverified Commit c416fd56 authored by meskio's avatar meskio
Browse files

[feat] Adapt to the new KeyManager API without key types

- Related: #8031
parent 7ba3e07b
......@@ -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)
......
......@@ -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
......
......@@ -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):
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment