//! Implementation of the "Web of Trust" model.
//!
//! TODO: not implemented yet

use std::collections::HashSet;

use voa_config::openpgp::{
    DomainName,
    TrustAmountFlow,
    TrustAmountPartial,
    WebOfTrustMode,
    WebOfTrustRoot,
};

use crate::OpenpgpCert;

/// Signature verification object that uses the generic Web of Trust model.
#[derive(Debug)]
#[allow(dead_code)]
pub(crate) struct WebOfTrustModel<'a> {
    /// The required flow amount for authentication for a target identity.
    pub(crate) flow_amount: TrustAmountFlow,

    /// The numerical trust amount of a partially trusted introducer.
    pub(crate) partial_amount: TrustAmountPartial,

    /// The trust roots for the "Web of Trust".
    pub(crate) roots: &'a HashSet<WebOfTrustRoot>,

    /// Artifact verifiers are only considered if they contain a validly self-bound identity in
    /// one of these domain names, at the reference time.
    /// In addition, such identity must be sufficiently certified within the Web of Trust.
    pub(crate) artifact_verifier_identity_domain_matches: &'a HashSet<DomainName>,
}

impl<'a> WebOfTrustModel<'a> {
    pub(crate) fn new(
        config: &'a WebOfTrustMode,
        _artifact_verifiers: &'a [OpenpgpCert],
        _trust_anchors: &'a [OpenpgpCert],
    ) -> Self {
        WebOfTrustModel {
            flow_amount: config.flow_amount(),
            partial_amount: config.partial_amount(),
            roots: config.roots(),
            artifact_verifier_identity_domain_matches: config
                .artifact_verifier_identity_domain_matches(),
        }
    }
}
