/// Returns Ok(()) if the provided capability source can be routed to the
/// given target_moniker, else a descriptive PolicyError.
Returns Ok(()) if the provided capability source can be routed to the
given target_moniker, else a descriptive PolicyError.
Returns Ok (( )) if the provided capability source can be routed to the given target_moniker else a descriptive PolicyError .
pub fn can_route_capability<'a, C>(
        &self,
        capability_source: &'a CapabilitySourceInterface<C>,
        target_moniker: &'a AbsoluteMoniker,
    ) -> Result<(), PolicyError>
    where
        C: ComponentInstanceInterface,
    {
        let target_moniker = Self::strip_moniker_instance_id(&target_moniker);
        let policy_key = Self::get_policy_key(capability_source).map_err(|e| {
            error!("Security policy could not generate a policy key for `{}`", capability_source);
            e
        })?;
        match self.config.security_policy.capability_policy.get(&policy_key) {
            Some(allowed_monikers) => match allowed_monikers.get(&target_moniker) {
                Some(_) => Ok(()),
                None => {
                    warn!(
                        "Security policy prevented `{}` from `{}` being routed to `{}`.",
                        policy_key.source_name, policy_key.source_moniker, target_moniker
                    );
                    Err(PolicyError::capability_use_disallowed(
                        policy_key.source_name.str(),
                        &policy_key.source_moniker,
                        &target_moniker,
                    ))
                }
            },
            None => Ok(()),
        }
    }
pub fn can_route_capability < ' a , C > ( & self , capability_source : & ' a CapabilitySourceInterface < C > , target_moniker : & ' a AbsoluteMoniker , ) -> Result < ( ) , PolicyError > where C : ComponentInstanceInterface , { let target_moniker = Self :: strip_moniker_instance_id ( & target_moniker ) ; let policy_key = Self :: get_policy_key ( capability_source ) . map_err ( | e | { error ! ( " " capability_source ) ; e } ) ? ; match self . config . security_policy . capability_policy . get ( & policy_key ) { Some ( allowed_monikers ) => match allowed_monikers . get ( & target_moniker ) { Some ( _ ) => Ok ( ( ) ) , None => { warn ! ( " " policy_key source_name policy_key source_moniker target_moniker ) ; Err ( PolicyError :: capability_use_disallowed ( policy_key . source_name . str ( ) , & policy_key . source_moniker , & target_moniker , ) ) } } , None => Ok ( ( ) ) , } }
Returns Ok(()) if the provided capability source can be routed to the
given target_moniker, else a descriptive PolicyError.
Returns Ok (( )) if the provided capability source can be routed to the given target_moniker else a descriptive PolicyError .
&self
capability_source
&'a CapabilitySourceInterface<C>
target_moniker
&'a AbsoluteMoniker