From 8ec64e41fd0069af61c48d54a41c3699005adf42 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 28 Oct 2022 18:47:17 +0200 Subject: [PATCH] cli (pubsub): new `signature` subcommands: A first `check` command can be used to check signature using the signature JSON data. More commands should follow to check or sign items. rel 381 --- sat_frontends/jp/cmd_pubsub.py | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sat_frontends/jp/cmd_pubsub.py b/sat_frontends/jp/cmd_pubsub.py index 2341d365..07e60a8e 100644 --- a/sat_frontends/jp/cmd_pubsub.py +++ b/sat_frontends/jp/cmd_pubsub.py @@ -1681,6 +1681,52 @@ class Reference(base.CommandBase): self.host.quit() +class SignatureCheck(base.CommandBase): + def __init__(self, host): + super().__init__( + host, + "check", + use_output=C.OUTPUT_DICT, + use_pubsub=True, + pubsub_flags={C.SERVICE, C.NODE, C.SINGLE_ITEM}, + help=_("check the validity of pubsub signature"), + ) + + def add_parser_options(self): + self.parser.add_argument( + "signature", + metavar="JSON", + help=_("signature data") + ) + + async def start(self): + try: + ret_s = await self.host.bridge.psSignatureCheck( + self.args.service, + self.args.node, + self.args.item, + self.args.signature, + self.profile, + ) + except Exception as e: + self.disp(f"can't check signature: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + else: + await self.output(data_format.deserialise((ret_s))) + self.host.quit() + + +class Signature(base.CommandBase): + subcommands = ( + SignatureCheck, + ) + + def __init__(self, host): + super().__init__( + host, "signature", use_profile=False, help=_("item signature") + ) + + class Search(base.CommandBase): """This command do a search without using MAM @@ -2898,6 +2944,7 @@ class Pubsub(base.CommandBase): Subscriptions, Affiliations, Reference, + Signature, Search, Transform, Attachments,