1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::ProfileIdentifier;
use ockam_core::Result;
mod identifier_trust_policy;
pub use identifier_trust_policy::*;
mod all_trust_policy;
pub use all_trust_policy::*;
mod any_trust_policy;
pub use any_trust_policy::*;
mod no_op_trust_policy;
pub use no_op_trust_policy::*;
pub struct SecureChannelTrustInfo {
their_profile_id: ProfileIdentifier,
}
impl SecureChannelTrustInfo {
pub fn their_profile_id(&self) -> &ProfileIdentifier {
&self.their_profile_id
}
}
impl SecureChannelTrustInfo {
pub fn new(their_profile_id: ProfileIdentifier) -> Self {
Self { their_profile_id }
}
}
pub trait TrustPolicy: Clone + Send + 'static {
fn check(&self, trust_info: &SecureChannelTrustInfo) -> Result<bool>;
}
pub trait ConjunctionTrustPolicy: TrustPolicy {
fn and<O: TrustPolicy>(self, other: O) -> AllTrustPolicy<Self, O> {
AllTrustPolicy::new(self, other)
}
}
impl<T> ConjunctionTrustPolicy for T where T: TrustPolicy {}
pub trait DisjunctionTrustPolicy: TrustPolicy {
fn or<O: TrustPolicy>(self, other: O) -> AnyTrustPolicy<Self, O> {
AnyTrustPolicy::new(self, other)
}
}
impl<T> DisjunctionTrustPolicy for T where T: TrustPolicy {}