fn is_transaction_allowed(
        identity_source: &dyn IdentitySource,
        transactions: &[Transaction],
        default_policy: Option<&str>,
    ) -> Result<bool, IdentityError> {
        let general_txn_policy_name = identity_source
            .get_role(ROLE_TXN_TRANSACTOR)
            .and_then(|found| {
                if found.is_some() {
                    Ok(found)
                } else {
                    identity_source.get_role(ROLE_TRANSACTOR)
                }
            })?
            .map(|role| role.policy_name().to_string())
            .or_else(|| default_policy.map(ToString::to_string));

        let txn_headers = match transactions
            .iter()
            .cloned()
            .map(|txn| txn.into_pair().map(|txn_pair| txn_pair.take().1))
            .collect::<Result<Vec<_>, _>>()
        {
            Ok(txn_headers) => txn_headers,
            Err(err) => {
                debug!("Unable to deserialize transaction header: {}", err);
                return Ok(false);
            }
        };

        for txn_header in txn_headers {
            let policy_name = identity_source
                .get_role(&format!(
                    "{}.{}",
                    ROLE_TXN_TRANSACTOR,
                    txn_header.family_name()
                ))?
                .map(|role| role.policy_name().to_string());

            let policy = if let Some(name) = policy_name
                .as_ref()
                .or_else(|| general_txn_policy_name.as_ref())
            {
                identity_source.get_policy_by_name(name)?
            } else {
                None
            };

            if let Some(policy) = policy {
                if !Self::is_allowed(txn_header.signer_public_key(), &policy) {
                    debug!(
                        "Transaction Signer: {} is not permitted.",
                        hex::encode(txn_header.signer_public_key())
                    );
                    return Ok(false);
                }
            }
        }
        Ok(true)
    }
/// Check the transaction signing key against the allowed transactor
/// permissions. The roles being checked are the following, from first
/// to last:
///     "transactor.transaction_signer.<TP_Name>"
///     "transactor.transaction_signer"
///     "transactor"
///
/// If a default is supplied, that is used.
///
/// The first role that is set will be the one used to enforce if the
/// transaction signer is allowed.
Check the transaction signing key against the allowed transactor
permissions.

If a default is supplied, that is used.

The first role that is set will be the one used to enforce if the
transaction signer is allowed.
Check the transaction signing key against the allowed transactor permissions . If a default is supplied that is used . The first role that is set will be the one used to enforce if the transaction signer is allowed .
fn is_transaction_allowed(
        identity_source: &dyn IdentitySource,
        transactions: &[Transaction],
        default_policy: Option<&str>,
    ) -> Result<bool, IdentityError> {
        let general_txn_policy_name = identity_source
            .get_role(ROLE_TXN_TRANSACTOR)
            .and_then(|found| {
                if found.is_some() {
                    Ok(found)
                } else {
                    identity_source.get_role(ROLE_TRANSACTOR)
                }
            })?
            .map(|role| role.policy_name().to_string())
            .or_else(|| default_policy.map(ToString::to_string));
        let txn_headers = match transactions
            .iter()
            .cloned()
            .map(|txn| txn.into_pair().map(|txn_pair| txn_pair.take().1))
            .collect::<Result<Vec<_>, _>>()
        {
            Ok(txn_headers) => txn_headers,
            Err(err) => {
                debug!("Unable to deserialize transaction header: {}", err);
                return Ok(false);
            }
        };
        for txn_header in txn_headers {
            let policy_name = identity_source
                .get_role(&format!(
                    "{}.{}",
                    ROLE_TXN_TRANSACTOR,
                    txn_header.family_name()
                ))?
                .map(|role| role.policy_name().to_string());
            let policy = if let Some(name) = policy_name
                .as_ref()
                .or_else(|| general_txn_policy_name.as_ref())
            {
                identity_source.get_policy_by_name(name)?
            } else {
                None
            };
            if let Some(policy) = policy {
                if !Self::is_allowed(txn_header.signer_public_key(), &policy) {
                    debug!(
                        "Transaction Signer: {} is not permitted.",
                        hex::encode(txn_header.signer_public_key())
                    );
                    return Ok(false);
                }
            }
        }
        Ok(true)
    }
fn is_transaction_allowed ( identity_source : & dyn IdentitySource , transactions : & [ Transaction ] , default_policy : Option < & str > , ) -> Result < bool , IdentityError > { let general_txn_policy_name = identity_source . get_role ( ROLE_TXN_TRANSACTOR ) . and_then ( | found | { if found . is_some ( ) { Ok ( found ) } else { identity_source . get_role ( ROLE_TRANSACTOR ) } } ) ? . map ( | role | role . policy_name ( ) . to_string ( ) ) . or_else ( | | default_policy . map ( ToString :: to_string ) ) ; let txn_headers = match transactions . iter ( ) . cloned ( ) . map ( | txn | txn . into_pair ( ) . map ( | txn_pair | txn_pair . take ( ) . 1 ) ) . collect :: < Result < Vec < _ > , _ > > ( ) { Ok ( txn_headers ) => txn_headers , Err ( err ) => { debug ! ( " " err ) ; return Ok ( false ) ; } } ; for txn_header in txn_headers { let policy_name = identity_source . get_role ( & format ! ( " " ROLE_TXN_TRANSACTOR txn_header family_name ( ) ) ) ? . map ( | role | role . policy_name ( ) . to_string ( ) ) ; let policy = if let Some ( name ) = policy_name . as_ref ( ) . or_else ( | | general_txn_policy_name . as_ref ( ) ) { identity_source . get_policy_by_name ( name ) ? } else { None } ; if let Some ( policy ) = policy { if ! Self :: is_allowed ( txn_header . signer_public_key ( ) , & policy ) { debug ! ( " " hex encode ( txn_header signer_public_key ( ) ) ) ; return Ok ( false ) ; } } } Ok ( true ) }
Check the transaction signing key against the allowed transactor
permissions.
Check the transaction signing key against the allowed transactor permissions .
identity_source
&dyn IdentitySource
transactions
&[Transaction]
default_policy
Option<&str>
identity_source
&dyn IdentitySource
transactions
&[Transaction]
default_policy
Option<&str>