diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-06-28 18:39:12 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-07-03 16:04:41 +0200 |
commit | f15673c6591036882bb6a277d5b9e73d3c7e348a (patch) | |
tree | 034e4c6584bc74d73bd7343b8d7c8244782fc8d8 | |
parent | ff7c106ee5bd950bb87279188bde1c06c47507fb (diff) |
[feat] add delete key command to the cli
-rwxr-xr-x | src/leap/bitmask/cli/bitmask_cli.py | 5 | ||||
-rw-r--r-- | src/leap/bitmask/core/dispatcher.py | 11 | ||||
-rw-r--r-- | src/leap/bitmask/core/mail_services.py | 7 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py index e51a41b7..60dc5176 100755 --- a/src/leap/bitmask/cli/bitmask_cli.py +++ b/src/leap/bitmask/cli/bitmask_cli.py @@ -140,6 +140,8 @@ GENERAL COMMANDS: help='List all known keys') parser.add_argument('--export', action='store_true', help='Export the given key') + parser.add_argument('--delete', action='store_true', + help='Delete the given key') parser.add_argument('address', nargs='?', help='email address of the key') args = parser.parse_args(sys.argv[2:]) @@ -353,6 +355,9 @@ def send_command(cli): data += ['export'] cb = do_print_key + elif subargs.delete: + data += ['delete'] + else: error('Use bitmask_cli keys --help to see available subcommands', stop=True) diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index db40a675..785c60dc 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -171,6 +171,17 @@ class KeysCmd(SubCommand): d.addCallback(service.do_export, address) return d + @register_method('str') + def do_DELETE(self, service, *parts, **kw): + if len(parts) < 3: + return defer.fail("An email address is needed") + address = parts[2] + + bonafide = kw['bonafide'] + d = bonafide.do_get_active_user() + d.addCallback(service.do_delete, address) + return d + class CommandDispatcher(object): diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 0dd53189..8d205d92 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -358,6 +358,13 @@ class KeymanagerService(HookableService): d.addCallback(lambda key: dict(key)) return d + @defer.inlineCallbacks + def do_delete(self, userid, address): + km = self._container.get_instance(userid) + key = yield km.get_key(address, fetch_remote=False) + km.delete_key(key) + defer.returnValue(key.fingerprint) + class StandardMailService(service.MultiService, HookableService): """ |