pub struct SecurityPolicy {
pub require_signature: bool,
pub require_encryption: bool,
}Expand description
Message-level protections a profile layer requires.
§This is independent of InteropMode
Neither the interop-strict Cargo feature nor InteropMode::Strict
implies a strict security policy. Interop mode governs header handling and
ambiguity tolerance; SecurityPolicy governs whether messages must be signed
and encrypted. A profile can be InteropMode::Strict and still resolve to
require_encryption: false — the two axes never constrain each other.
What does constrain the security axis is the profile’s
security floor, which
ProfileStack::validate enforces against every resolved layer.
§Lattice ordering
A policy is stronger than another when it requires everything the other
requires and possibly more. Self::satisfies is that partial order,
Self::strengthen its join, and Self::weaken its meet. Both defaults
are true, so the fail-closed policy is also the strongest one.
use asx_rs::interop::{SecurityPolicy, SecurityRequirement};
let floor = SecurityPolicy::SIGN_AND_ENCRYPT;
let partner = SecurityPolicy::SIGN_ONLY;
assert!(!partner.satisfies(floor));
assert_eq!(floor.unmet_by(partner), vec![SecurityRequirement::Encryption]);Fields§
§require_signature: bool§require_encryption: boolImplementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub const SIGN_AND_ENCRYPT: Self
pub const SIGN_AND_ENCRYPT: Self
Sign and encrypt — the fail-closed policy, and what
Default::default yields.
Mandated by PEPPOL, CEF eDelivery and BDEW AS4-Profil v1.2 §2.2.6.2.2, so it is also the default security floor.
Sourcepub const ENCRYPT_ONLY: Self
pub const ENCRYPT_ONLY: Self
Encryption required, signature optional.
Sourcepub const UNCONSTRAINED: Self
pub const UNCONSTRAINED: Self
Neither protection required.
Only meaningful as a floor (meaning “impose nothing beyond the
per-layer checks”). As an effective policy it is rejected by
ProfileStack::validate with
ProfileValidationCode::NoCriticalSecurityInvariant.
Sourcepub fn requires(self, requirement: SecurityRequirement) -> bool
pub fn requires(self, requirement: SecurityRequirement) -> bool
Whether this policy requires requirement.
Sourcepub fn satisfies(self, floor: Self) -> bool
pub fn satisfies(self, floor: Self) -> bool
Whether this policy is at least as strong as floor.
Sourcepub fn unmet_by(self, candidate: Self) -> Vec<SecurityRequirement>
pub fn unmet_by(self, candidate: Self) -> Vec<SecurityRequirement>
Requirements that self (as a floor) demands but candidate does not
provide, in declaration order.
Empty exactly when candidate.satisfies(self).
Sourcepub fn relaxations_to(self, next: Self) -> Vec<SecurityRequirement>
pub fn relaxations_to(self, next: Self) -> Vec<SecurityRequirement>
Requirements that self demands but next drops — the monotonicity
violations of a self -> next transition, in declaration order.
Empty exactly when next is at least as strong as self.
Sourcepub fn strengthen(self, other: Self) -> Self
pub fn strengthen(self, other: Self) -> Self
Lattice join: require everything either policy requires.
Used to combine a BaseProfile::security_floor with a
deployment-imposed floor from ProfileValidationOptions — the
stricter of the two wins per requirement.
Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
Source§fn clone(&self) -> SecurityPolicy
fn clone(&self) -> SecurityPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SecurityPolicy
Source§impl Debug for SecurityPolicy
impl Debug for SecurityPolicy
Source§impl Default for SecurityPolicy
impl Default for SecurityPolicy
Source§impl<'de> Deserialize<'de> for SecurityPolicy
impl<'de> Deserialize<'de> for SecurityPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for SecurityPolicy
impl Display for SecurityPolicy
impl Eq for SecurityPolicy
Source§impl PartialEq for SecurityPolicy
impl PartialEq for SecurityPolicy
Source§impl Serialize for SecurityPolicy
impl Serialize for SecurityPolicy
impl StructuralPartialEq for SecurityPolicy
Auto Trait Implementations§
impl Freeze for SecurityPolicy
impl RefUnwindSafe for SecurityPolicy
impl Send for SecurityPolicy
impl Sync for SecurityPolicy
impl Unpin for SecurityPolicy
impl UnsafeUnpin for SecurityPolicy
impl UnwindSafe for SecurityPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more