summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bonafide/src/leap/bonafide/_protocol.py19
-rw-r--r--bonafide/src/leap/bonafide/service.py17
2 files changed, 28 insertions, 8 deletions
diff --git a/bonafide/src/leap/bonafide/_protocol.py b/bonafide/src/leap/bonafide/_protocol.py
index 617c93c..f1c3834 100644
--- a/bonafide/src/leap/bonafide/_protocol.py
+++ b/bonafide/src/leap/bonafide/_protocol.py
@@ -114,17 +114,20 @@ class BonafideProtocol(object):
d.addCallback(lambda _: '%s logged out' % full_id)
return d
- def do_stats(self):
- log.msg('Calculating Bonafide Service STATS')
- mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
- return '[+] Bonafide service: [%s sessions] [Mem usage: %s KB]' % (
- len(self._sessions), mem / 1024)
+ def do_get_smtp_cert(self, full_id):
+ session = self._get_session(full_id)
+ d = session.get_smtp_cert()
+ return d
def do_get_vpn_cert(self):
pass
- def do_get_smtp_cert(self):
- pass
-
def do_update_user(self):
pass
+
+ def do_stats(self):
+ log.msg('Calculating Bonafide Service STATS')
+ mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
+ return '[+] Bonafide service: [%s sessions] [Mem usage: %s KB]' % (
+ len(self._sessions), mem / 1024)
+
diff --git a/bonafide/src/leap/bonafide/service.py b/bonafide/src/leap/bonafide/service.py
index 2ff4eed..468721b 100644
--- a/bonafide/src/leap/bonafide/service.py
+++ b/bonafide/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