qualia_core_db/net/qdnf/authority/
decoded.rs1use crate::net::qdnf::errors::QdnfError;
4use crate::net::qdnf::types::StrongDigest;
5
6use super::policy::PolicyOutcome;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct DecodedClaim {
11 pub asserted_principal: StrongDigest,
12 pub asserted_recipient: StrongDigest,
13 pub asserted_purpose: StrongDigest,
14 pub asserted_outcome: PolicyOutcome,
15 pub signed_flag: bool,
16 pub supported_flag: bool,
17}
18
19impl DecodedClaim {
20 pub const fn empty() -> Self {
22 Self {
23 asserted_principal: StrongDigest::ZERO,
24 asserted_recipient: StrongDigest::ZERO,
25 asserted_purpose: StrongDigest::ZERO,
26 asserted_outcome: PolicyOutcome::Incomplete,
27 signed_flag: false,
28 supported_flag: false,
29 }
30 }
31
32 pub fn admit_service(&self) -> Result<(), QdnfError> {
34 let _ = (self.signed_flag, self.supported_flag, self.asserted_outcome);
35 Err(QdnfError::Unauthorized)
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn allow_boolean_cannot_admit() {
45 let mut claim = DecodedClaim::empty();
46 claim.asserted_outcome = PolicyOutcome::Allow;
47 claim.signed_flag = true;
48 claim.supported_flag = true;
49 assert_eq!(claim.admit_service(), Err(QdnfError::Unauthorized));
50 }
51}