From 1d4a3d68869dd9c416b104399097a6bb0c1bace3 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Wed, 1 Feb 2017 14:49:45 +0100 Subject: [feature] new commands: get_cert --- src/leap/bitmask/bonafide/_protocol.py | 9 ++++++--- src/leap/bitmask/bonafide/service.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/leap/bitmask/bonafide') diff --git a/src/leap/bitmask/bonafide/_protocol.py b/src/leap/bitmask/bonafide/_protocol.py index ac631d8c..91b8b242 100644 --- a/src/leap/bitmask/bonafide/_protocol.py +++ b/src/leap/bitmask/bonafide/_protocol.py @@ -192,9 +192,12 @@ class BonafideProtocol(object): d = self._sessions[full_id].get_smtp_cert() return d - def do_get_vpn_cert(self): - # FIXME to be implemented - pass + def do_get_vpn_cert(self, full_id): + if (full_id not in self._sessions or + not self._sessions[full_id].is_authenticated): + return fail(RuntimeError("There is no session for such user")) + d = self._sessions[full_id].get_vpn_cert() + return d def do_update_user(self): # FIXME to be implemented diff --git a/src/leap/bitmask/bonafide/service.py b/src/leap/bitmask/bonafide/service.py index 37d1e214..69aac2df 100644 --- a/src/leap/bitmask/bonafide/service.py +++ b/src/leap/bitmask/bonafide/service.py @@ -120,7 +120,21 @@ class BonafideService(HookableService): def do_provider_list(self, seeded=False): return self._bonafide.do_provider_list(seeded) - def do_get_smtp_cert(self, username): + # TODO make username mandatory + # and move active_user to the cli machinery + def do_get_vpn_cert(self, username=None): + if not username: + username = self._active_user + if not username: + return defer.fail( + RuntimeError('No active user, cannot get VPN cert.')) + d = self._bonafide.do_get_vpn_cert(username) + d.addCallback(lambda response: (username, response)) + 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 username, cannot get SMTP cert.')) -- cgit v1.2.3