summaryrefslogtreecommitdiff
path: root/bonafide/src
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2015-12-16 12:27:46 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2015-12-16 12:37:54 -0400
commitc4984f7e631f770f2bef17f037a23b9347fec85f (patch)
treef5e6257182b1d86329560c15e792ae0b3f406bdc /bonafide/src
parentd9b4b041035c018d3b24b4866647df6092c8f55b (diff)
add command to download smtp certificate
Diffstat (limited to 'bonafide/src')
-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