Simplify code.
- The policy and time were only used to reason over subkeys. Since we don't match on subkeys, we no longer need the specialized functions.
This commit is contained in:
parent
ee29f3c8f8
commit
9085ef8638
@ -9,7 +9,6 @@ use openpgp::Result;
|
||||
use crate::Sq;
|
||||
use crate::cli::key::revoke::Command;
|
||||
use crate::common::get_secret_signer;
|
||||
use crate::common::NULL_POLICY;
|
||||
use crate::common::RevocationOutput;
|
||||
use crate::parse_notations;
|
||||
|
||||
@ -88,10 +87,7 @@ pub fn certificate_revoke(
|
||||
command: Command,
|
||||
) -> Result<()> {
|
||||
let cert =
|
||||
sq.resolve_cert_with_policy(&command.cert,
|
||||
sequoia_wot::FULLY_TRUSTED,
|
||||
NULL_POLICY,
|
||||
sq.time)?.0;
|
||||
sq.resolve_cert(&command.cert, sequoia_wot::FULLY_TRUSTED)?.0;
|
||||
|
||||
let revoker = if command.revoker.is_empty() {
|
||||
None
|
||||
|
@ -114,10 +114,7 @@ pub fn dispatch(sq: Sq, command: crate::cli::key::subkey::revoke::Command)
|
||||
-> Result<()>
|
||||
{
|
||||
let (cert, cert_source) =
|
||||
sq.resolve_cert_with_policy(&command.cert,
|
||||
sequoia_wot::FULLY_TRUSTED,
|
||||
NULL_POLICY,
|
||||
sq.time)?;
|
||||
sq.resolve_cert(&command.cert, sequoia_wot::FULLY_TRUSTED)?;
|
||||
|
||||
let vc = Cert::with_policy(&cert, NULL_POLICY, sq.time)
|
||||
.with_context(|| {
|
||||
|
35
src/sq.rs
35
src/sq.rs
@ -1774,22 +1774,6 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
|
||||
trust_amount: usize,
|
||||
)
|
||||
-> Result<(Vec<Cert>, Vec<anyhow::Error>)>
|
||||
where
|
||||
Prefix: cert_designator::ArgumentPrefix
|
||||
{
|
||||
self.resolve_certs_with_policy(designators, trust_amount,
|
||||
self.policy, self.time)
|
||||
}
|
||||
|
||||
/// Like [`Sq::resolve_certs`] but with explicit policy.
|
||||
pub fn resolve_certs_with_policy<Arguments, Prefix, Options, Doc>(
|
||||
&self,
|
||||
designators: &CertDesignators<Arguments, Prefix, Options, Doc>,
|
||||
trust_amount: usize,
|
||||
_policy: &dyn Policy,
|
||||
_time: SystemTime,
|
||||
)
|
||||
-> Result<(Vec<Cert>, Vec<anyhow::Error>)>
|
||||
where
|
||||
Prefix: cert_designator::ArgumentPrefix,
|
||||
{
|
||||
@ -2243,22 +2227,6 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
|
||||
trust_amount: usize,
|
||||
)
|
||||
-> Result<(Cert, FileStdinOrKeyHandle)>
|
||||
where
|
||||
Prefix: cert_designator::ArgumentPrefix
|
||||
{
|
||||
self.resolve_cert_with_policy(designators, trust_amount,
|
||||
self.policy, self.time)
|
||||
}
|
||||
|
||||
/// Like [`Sq::resolve_cert`], but with explicit policy.
|
||||
pub fn resolve_cert_with_policy<Arguments, Prefix, Options, Doc>(
|
||||
&self,
|
||||
designators: &CertDesignators<Arguments, Prefix, Options, Doc>,
|
||||
trust_amount: usize,
|
||||
policy: &dyn Policy,
|
||||
time: SystemTime,
|
||||
)
|
||||
-> Result<(Cert, FileStdinOrKeyHandle)>
|
||||
where
|
||||
Prefix: cert_designator::ArgumentPrefix,
|
||||
{
|
||||
@ -2275,8 +2243,7 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
|
||||
}
|
||||
|
||||
let (certs, errors) =
|
||||
self.resolve_certs_with_policy(designators, trust_amount,
|
||||
policy, time)?;
|
||||
self.resolve_certs(designators, trust_amount)?;
|
||||
if certs.len() > 1 {
|
||||
wprintln!("{} is ambiguous. It resolves to multiple certificates.",
|
||||
designators.designators[0].argument::<Prefix>());
|
||||
|
Loading…
Reference in New Issue
Block a user