@@ -6,8 +6,13 @@ import com.yubico.fido.metadata.AttachmentHint.ATTACHMENT_HINT_NFC
6
6
import com .yubico .fido .metadata .AttachmentHint .ATTACHMENT_HINT_WIRED
7
7
import com .yubico .fido .metadata .AttachmentHint .ATTACHMENT_HINT_WIRELESS
8
8
import com .yubico .internal .util .CertificateParser
9
+ import com .yubico .webauthn .FinishRegistrationOptions
10
+ import com .yubico .webauthn .RelyingParty
11
+ import com .yubico .webauthn .TestWithEachProvider
9
12
import com .yubico .webauthn .data .AttestationObject
13
+ import com .yubico .webauthn .test .Helpers
10
14
import com .yubico .webauthn .test .RealExamples
15
+ import org .bouncycastle .jce .provider .BouncyCastleProvider
11
16
import org .junit .runner .RunWith
12
17
import org .scalatest .BeforeAndAfter
13
18
import org .scalatest .funspec .AnyFunSpec
@@ -18,11 +23,13 @@ import org.scalatestplus.junit.JUnitRunner
18
23
19
24
import java .io .IOException
20
25
import java .security .cert .X509Certificate
26
+ import java .time .Clock
27
+ import java .time .ZoneOffset
21
28
import java .util
22
29
import java .util .Optional
23
30
import scala .jdk .CollectionConverters .IteratorHasAsScala
31
+ import scala .jdk .CollectionConverters .SetHasAsJava
24
32
import scala .jdk .CollectionConverters .SetHasAsScala
25
- import scala .jdk .OptionConverters .RichOption
26
33
import scala .jdk .OptionConverters .RichOptional
27
34
import scala .util .Try
28
35
@@ -32,7 +39,8 @@ import scala.util.Try
32
39
class FidoMetadataServiceIntegrationTest
33
40
extends AnyFunSpec
34
41
with Matchers
35
- with BeforeAndAfter {
42
+ with BeforeAndAfter
43
+ with TestWithEachProvider {
36
44
37
45
describe(" FidoMetadataService" ) {
38
46
@@ -60,7 +68,7 @@ class FidoMetadataServiceIntegrationTest
60
68
val attachmentHintsNfc =
61
69
attachmentHintsUsb ++ Set (ATTACHMENT_HINT_WIRELESS , ATTACHMENT_HINT_NFC )
62
70
63
- describe(" correctly identifies" ) {
71
+ describe(" correctly identifies and trusts " ) {
64
72
def check (
65
73
expectedDescriptionRegex : String ,
66
74
testData : RealExamples .Example ,
@@ -101,17 +109,38 @@ class FidoMetadataServiceIntegrationTest
101
109
def getX5cArray (attestationObject : AttestationObject ): JsonNode =
102
110
attestationObject.getAttestationStatement.get(" x5c" )
103
111
104
- val entries = fidoMds.get
105
- .findEntries(
106
- getAttestationTrustPath(
107
- testData.attestation.attestationObject
108
- ).get,
109
- Some (
110
- new AAGUID (
111
- testData.attestation.attestationObject.getAuthenticatorData.getAttestedCredentialData.get.getAaguid
112
- )
113
- ).toJava,
112
+ val rp = RelyingParty
113
+ .builder()
114
+ .identity(testData.rp)
115
+ .credentialRepository(Helpers .CredentialRepository .empty)
116
+ .origins(
117
+ Set (testData.attestation.collectedClientData.getOrigin).asJava
114
118
)
119
+ .allowUntrustedAttestation(false )
120
+ .attestationTrustSource(fidoMds.get)
121
+ .clock(
122
+ Clock .fixed(
123
+ CertificateParser
124
+ .parseDer(testData.attestationCert.getBytes)
125
+ .getNotBefore
126
+ .toInstant,
127
+ ZoneOffset .UTC ,
128
+ )
129
+ )
130
+ .build()
131
+
132
+ val registrationResult = rp.finishRegistration(
133
+ FinishRegistrationOptions
134
+ .builder()
135
+ .request(testData.asRegistrationTestData.request)
136
+ .response(testData.attestation.credential)
137
+ .build()
138
+ )
139
+
140
+ registrationResult.isAttestationTrusted should be(true )
141
+
142
+ val entries = fidoMds.get
143
+ .findEntries(registrationResult)
115
144
.asScala
116
145
entries should not be empty
117
146
val metadataStatements =
@@ -214,11 +243,13 @@ class FidoMetadataServiceIntegrationTest
214
243
}
215
244
216
245
it(" a YubiKey 5.4 NFC FIPS." ) {
217
- check(
218
- " YubiKey 5 FIPS Series with NFC" ,
219
- RealExamples .YubikeyFips5Nfc ,
220
- attachmentHintsNfc,
221
- )
246
+ withProviderContext(List (new BouncyCastleProvider )) { // Needed for JDK<14 because this example uses EdDSA
247
+ check(
248
+ " YubiKey 5 FIPS Series with NFC" ,
249
+ RealExamples .YubikeyFips5Nfc ,
250
+ attachmentHintsNfc,
251
+ )
252
+ }
222
253
}
223
254
224
255
it(" a YubiKey 5.4 Ci FIPS." ) {
0 commit comments