Debian Codegraph @

src/commands/pki.rs

raw
1 use clap::ArgMatches;
2
3 use sequoia_openpgp as openpgp;
4 use openpgp::Result;
5
6 pub mod link;
7 pub mod path;
8 pub mod vouch;
9
10 use crate::cli;
11
12 use crate::Sq;
13 use crate::common::pki::authenticate;
14 use crate::commands::pki::authenticate::AuthenticateContext;
15 use crate::commands::pki::authenticate::Query;
16
17 pub fn dispatch(sq: Sq, cli: cli::pki::Command, matches: &ArgMatches)
18 -> Result<()>
19 {
20 tracer!(TRACE, "pki::dispatch");
21
22 let matches = matches.subcommand().unwrap().1;
23 use cli::pki::*;
24 match cli.subcommand {
25 // Authenticate a given binding.
26 Subcommands::Authenticate(authenticate::Command {
27 userid, gossip, unusable, certification_network,
28 trust_amount, cert, show_paths,
29 }) => {
30 assert_eq!(cert.len(), 1);
31 assert_eq!(userid.len(), 1);
32
33 authenticate(
34 &mut std::io::stdout(),
35 &sq,
36 AuthenticateContext::PKI,
37 Query::for_binding(cert, userid),
38 *gossip,
39 *unusable,
40 *certification_network,
41 *trust_amount,
42 *show_paths,
43 )?
44 }
45
46 // Find all authenticated bindings for a given User ID, list
47 // the certificates.
48 Subcommands::Lookup(lookup::Command {
49 gossip, unusable, certification_network, trust_amount,
50 userid, show_paths,
51 }) => {
52 assert_eq!(userid.len(), 1);
53
54 authenticate(
55 &mut std::io::stdout(),
56 &sq,
57 AuthenticateContext::PKI,
58 userid.into(),
59 *gossip,
60 *unusable,
61 *certification_network,
62 *trust_amount,
63 *show_paths)?;
64 }
65
66 // Find and list all authenticated bindings for a given
67 // certificate.
68 Subcommands::Identify(identify::Command {
69 gossip, unusable, certification_network, trust_amount,
70 cert, show_paths,
71 }) => {
72 assert_eq!(cert.len(), 1);
73
74 authenticate(
75 &mut std::io::stdout(),
76 &sq,
77 AuthenticateContext::PKI,
78 cert.into(),
79 *gossip,
80 *unusable,
81 *certification_network,
82 *trust_amount,
83 *show_paths)?;
84 }
85
86 // Authenticates a given path.
87 Subcommands::Path(command) =>
88 self::path::path(sq, command)?,
89
90 Subcommands::Vouch(command) =>
91 self::vouch::vouch(sq, command, matches)?,
92
93 Subcommands::Link(command) =>
94 self::link::link(sq, command)?,
95 }
96
97 Ok(())
98 }