@@ -1037,4 +1037,88 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
10371037
10381038 }
10391039
1040+ describe(" The notRetired filter" ) {
1041+ val attestationRoot = TestAuthenticator .generateAttestationCaCertificate()
1042+ val rootCertBase64 = new ByteArray (attestationRoot._1.getEncoded).getBase64
1043+
1044+ val (goodCert, _) = TestAuthenticator .generateAttestationCertificate(
1045+ name = new X500Name (" CN=Good cert" ),
1046+ caCertAndKey = Some (attestationRoot),
1047+ )
1048+
1049+ val goodCertKeyIdentifier = new ByteArray (
1050+ CertificateParser .computeSubjectKeyIdentifier(goodCert)
1051+ ).getHex
1052+
1053+ val aaguidRetired =
1054+ new AAGUID (ByteArray .fromHex(" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
1055+
1056+ val blob : MetadataBLOBPayload =
1057+ JacksonCodecs .jsonWithDefaultEnums.readValue(
1058+ s """ {
1059+ "legalHeader" : "Kom ihåg att du aldrig får snyta dig i mattan!",
1060+ "nextUpdate" : "2022-12-01",
1061+ "no" : 0,
1062+ "entries": [
1063+ {
1064+ "aaguid": " ${aaguidRetired.asGuidString()}",
1065+ "attestationCertificateKeyIdentifiers": [" ${goodCertKeyIdentifier}"],
1066+ "metadataStatement": {
1067+ "aaguid": " ${aaguidRetired.asGuidString()}",
1068+ "attestationCertificateKeyIdentifiers": [" ${goodCertKeyIdentifier}"],
1069+ "authenticatorVersion": 1,
1070+ "attachmentHint" : ["internal"],
1071+ "attestationRootCertificates": [" ${rootCertBase64}"],
1072+ "attestationTypes" : ["basic_full"],
1073+ "authenticationAlgorithms" : ["secp256r1_ecdsa_sha256_raw"],
1074+ "description" : "Test authenticator",
1075+ "keyProtection" : ["software"],
1076+ "matcherProtection" : ["software"],
1077+ "protocolFamily" : "u2f",
1078+ "publicKeyAlgAndEncodings" : ["ecc_x962_raw"],
1079+ "schema" : 3,
1080+ "tcDisplay" : [],
1081+ "upv" : [{ "major" : 1, "minor" : 1 }],
1082+ "userVerificationDetails" : [[{ "userVerificationMethod" : "presence_internal" }]]
1083+ },
1084+ "statusReports": [
1085+ { "status": "RETIRED", "effectiveDate": "2022-02-01" }
1086+ ],
1087+ "timeOfLastStatusChange": "2022-02-15"
1088+ }
1089+ ]
1090+ } """ .stripMargin,
1091+ classOf [MetadataBLOBPayload ],
1092+ )
1093+
1094+ it(" is not enabled by default." ) {
1095+ val mds = FidoMetadataService .builder().useBlob(blob).build()
1096+
1097+ mds
1098+ .findTrustRoots(
1099+ List (goodCert).asJava,
1100+ Some (aaguidRetired.asBytes).toJava,
1101+ )
1102+ .getTrustRoots
1103+ .asScala should not be empty
1104+ }
1105+
1106+ it(" can be enabled explicitly as a prefilter." ) {
1107+ val mds = FidoMetadataService
1108+ .builder()
1109+ .useBlob(blob)
1110+ .prefilter(FidoMetadataService .Filters .notRetired())
1111+ .build()
1112+
1113+ mds
1114+ .findTrustRoots(
1115+ List (goodCert).asJava,
1116+ Some (aaguidRetired.asBytes).toJava,
1117+ )
1118+ .getTrustRoots
1119+ .asScala shouldBe empty
1120+ }
1121+
1122+ }
1123+
10401124}
0 commit comments