summaryrefslogtreecommitdiff
path: root/src/leap/bonafide/service.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bonafide/service.py')
-rw-r--r--src/leap/bonafide/service.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/leap/bonafide/service.py b/src/leap/bonafide/service.py
index 2ff4eed..468721b 100644
--- a/src/leap/bonafide/service.py
+++ b/src/leap/bonafide/service.py
@@ -24,6 +24,7 @@ import os
from leap.bonafide._protocol import BonafideProtocol
from twisted.application import service
+from twisted.internet import defer
class BonafideService(service.Service):
@@ -35,6 +36,10 @@ class BonafideService(service.Service):
self._basedir = os.path.expanduser(basedir)
self.service_hooks = {}
+ # XXX this is a quick hack to get a ref
+ # to the latest authenticated user.
+ self._active_user = None
+
def register_hook(self, kind, trigger):
self.service_hooks[kind] = trigger
@@ -66,6 +71,7 @@ class BonafideService(service.Service):
this_hook,
username=username, token=token, uuid=uuid,
password=password)
+ self._active_user = username
return result
# XXX I still have doubts from where it's best to trigger this.
@@ -91,3 +97,14 @@ class BonafideService(service.Service):
d = self._bonafide.do_logout(username, password)
d.addCallback(lambda response: 'LOGOUT -> ok')
return d
+
+ def do_get_smtp_cert(self, username=None):
+ if not username:
+ username = self._active_user
+ if not username:
+ return defer.fail(
+ RuntimeError('No active user, cannot get SMTP cert.'))
+
+ d = self._bonafide.do_get_smtp_cert(username)
+ d.addCallback(lambda response: (username, response))
+ return d