| 1 |
use std::any::TypeId; |
| 2 |
|
| 3 |
use crate::response::rpki::{ |
| 4 |
Rpk1Aspa, Rpk1AspaSearchResults, Rpk1Roa, Rpk1RoaSearchResults, Rpk1RpkiType, |
| 5 |
Rpk1X509ResourceCert, Rpk1X509ResourceCertSearchResults, |
| 6 |
}; |
| 7 |
|
| 8 |
use super::{Check, CheckParams, Checks, GetChecks, GetGroupChecks, RdapStructure}; |
| 9 |
|
| 10 |
impl GetChecks for Rpk1Roa { |
| 11 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 12 |
let sub_checks = { |
| 13 |
let mut sub_checks: Vec<Checks> = vec![]; |
| 14 |
sub_checks.append(&mut GetGroupChecks::get_group_checks( |
| 15 |
&self.common, |
| 16 |
params.from_parent(TypeId::of::<Self>()), |
| 17 |
)); |
| 18 |
sub_checks.append( |
| 19 |
&mut self |
| 20 |
.object_common |
| 21 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())), |
| 22 |
); |
| 23 |
sub_checks |
| 24 |
}; |
| 25 |
|
| 26 |
let mut items = vec![]; |
| 27 |
|
| 28 |
if self.origin_autnum.is_none() { |
| 29 |
items.push(Check::Rpk1RoaOriginAutnumMissing.check_item()) |
| 30 |
} |
| 31 |
|
| 32 |
if self.roa_ips.as_ref().is_none_or(|v| v.is_empty()) { |
| 33 |
items.push(Check::Rpk1RoaIpsIsEmpty.check_item()) |
| 34 |
} |
| 35 |
|
| 36 |
if let Some(rpki_type) = &self.rpki_type { |
| 37 |
let valid = matches!( |
| 38 |
rpki_type, |
| 39 |
Rpk1RpkiType::Hosted | Rpk1RpkiType::Delegated | Rpk1RpkiType::Hybrid |
| 40 |
); |
| 41 |
if !valid { |
| 42 |
items.push(Check::Rpk1RpkiTypeInvalid.check_item()) |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
Checks { |
| 47 |
rdap_struct: RdapStructure::Rpk1Roa, |
| 48 |
index, |
| 49 |
items, |
| 50 |
sub_checks, |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
impl GetChecks for Rpk1Aspa { |
| 56 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 57 |
let sub_checks = { |
| 58 |
let mut sub_checks: Vec<Checks> = vec![]; |
| 59 |
sub_checks.append(&mut GetGroupChecks::get_group_checks( |
| 60 |
&self.common, |
| 61 |
params.from_parent(TypeId::of::<Self>()), |
| 62 |
)); |
| 63 |
sub_checks.append( |
| 64 |
&mut self |
| 65 |
.object_common |
| 66 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())), |
| 67 |
); |
| 68 |
sub_checks |
| 69 |
}; |
| 70 |
|
| 71 |
let mut items = vec![]; |
| 72 |
|
| 73 |
if self.customer_autnum.is_none() { |
| 74 |
items.push(Check::Rpk1AspaCustomerAutnumMissing.check_item()) |
| 75 |
} |
| 76 |
|
| 77 |
if self.provider_autnums.as_ref().is_none_or(|v| v.is_empty()) { |
| 78 |
items.push(Check::Rpk1AspaProviderAutnumsIsEmpty.check_item()) |
| 79 |
} |
| 80 |
|
| 81 |
if let Some(rpki_type) = &self.rpki_type { |
| 82 |
let valid = matches!( |
| 83 |
rpki_type, |
| 84 |
Rpk1RpkiType::Hosted | Rpk1RpkiType::Delegated | Rpk1RpkiType::Hybrid |
| 85 |
); |
| 86 |
if !valid { |
| 87 |
items.push(Check::Rpk1RpkiTypeInvalid.check_item()) |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
Checks { |
| 92 |
rdap_struct: RdapStructure::Rpk1Aspa, |
| 93 |
index, |
| 94 |
items, |
| 95 |
sub_checks, |
| 96 |
} |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
impl GetChecks for Rpk1X509ResourceCert { |
| 101 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 102 |
let sub_checks = { |
| 103 |
let mut sub_checks: Vec<Checks> = vec![]; |
| 104 |
sub_checks.append(&mut GetGroupChecks::get_group_checks( |
| 105 |
&self.common, |
| 106 |
params.from_parent(TypeId::of::<Self>()), |
| 107 |
)); |
| 108 |
sub_checks.append( |
| 109 |
&mut self |
| 110 |
.object_common |
| 111 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())), |
| 112 |
); |
| 113 |
sub_checks |
| 114 |
}; |
| 115 |
|
| 116 |
let mut items = vec![]; |
| 117 |
|
| 118 |
if self.serial_number.as_ref().is_none_or(|v| v.is_empty()) { |
| 119 |
items.push(Check::Rpk1X509SerialNumberMissing.check_item()) |
| 120 |
} |
| 121 |
|
| 122 |
if self.issuer.as_ref().is_none_or(|v| v.is_empty()) { |
| 123 |
items.push(Check::Rpk1X509IssuerMissing.check_item()) |
| 124 |
} |
| 125 |
|
| 126 |
if let Some(rpki_type) = &self.rpki_type { |
| 127 |
let valid = matches!( |
| 128 |
rpki_type, |
| 129 |
Rpk1RpkiType::Hosted | Rpk1RpkiType::Delegated | Rpk1RpkiType::Hybrid |
| 130 |
); |
| 131 |
if !valid { |
| 132 |
items.push(Check::Rpk1RpkiTypeInvalid.check_item()) |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
Checks { |
| 137 |
rdap_struct: RdapStructure::Rpk1X509ResourceCert, |
| 138 |
index, |
| 139 |
items, |
| 140 |
sub_checks, |
| 141 |
} |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
impl GetChecks for Rpk1RoaSearchResults { |
| 146 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 147 |
let mut sub_checks: Vec<Checks> = self |
| 148 |
.common |
| 149 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())); |
| 150 |
self.results.iter().enumerate().for_each(|(i, result)| { |
| 151 |
sub_checks.push(result.get_checks(Some(i), params.from_parent(TypeId::of::<Self>()))); |
| 152 |
}); |
| 153 |
Checks { |
| 154 |
rdap_struct: RdapStructure::Rpk1RoaSearchResults, |
| 155 |
index, |
| 156 |
items: vec![], |
| 157 |
sub_checks, |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
impl GetChecks for Rpk1AspaSearchResults { |
| 163 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 164 |
let mut sub_checks: Vec<Checks> = self |
| 165 |
.common |
| 166 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())); |
| 167 |
self.results.iter().enumerate().for_each(|(i, result)| { |
| 168 |
sub_checks.push(result.get_checks(Some(i), params.from_parent(TypeId::of::<Self>()))); |
| 169 |
}); |
| 170 |
Checks { |
| 171 |
rdap_struct: RdapStructure::Rpk1AspaSearchResults, |
| 172 |
index, |
| 173 |
items: vec![], |
| 174 |
sub_checks, |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
impl GetChecks for Rpk1X509ResourceCertSearchResults { |
| 180 |
fn get_checks(&self, index: Option<usize>, params: CheckParams) -> Checks { |
| 181 |
let mut sub_checks: Vec<Checks> = self |
| 182 |
.common |
| 183 |
.get_group_checks(params.from_parent(TypeId::of::<Self>())); |
| 184 |
self.results.iter().enumerate().for_each(|(i, result)| { |
| 185 |
sub_checks.push(result.get_checks(Some(i), params.from_parent(TypeId::of::<Self>()))); |
| 186 |
}); |
| 187 |
Checks { |
| 188 |
rdap_struct: RdapStructure::Rpk1X509ResourceCertSearchResults, |
| 189 |
index, |
| 190 |
items: vec![], |
| 191 |
sub_checks, |
| 192 |
} |
| 193 |
} |
| 194 |
} |