@@ -145,9 +145,8 @@ public class RelyingParty {
145
145
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
146
146
* (appid)</a>
147
147
*/
148
- @ Builder .Default
149
148
@ NonNull
150
- private final Optional <AppId > appId = Optional . empty () ;
149
+ private final Optional <AppId > appId ;
151
150
152
151
/**
153
152
* The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
@@ -165,9 +164,8 @@ public class RelyingParty {
165
164
* @see PublicKeyCredentialCreationOptions#getAttestation()
166
165
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
167
166
*/
168
- @ Builder .Default
169
167
@ NonNull
170
- private final Optional <AttestationConveyancePreference > attestationConveyancePreference = Optional . empty () ;
168
+ private final Optional <AttestationConveyancePreference > attestationConveyancePreference ;
171
169
172
170
/**
173
171
* A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
@@ -180,9 +178,8 @@ public class RelyingParty {
180
178
* @see PublicKeyCredentialCreationOptions#getAttestation()
181
179
* @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
182
180
*/
183
- @ Builder .Default
184
181
@ NonNull
185
- private final Optional <MetadataService > metadataService = Optional . empty () ;
182
+ private final Optional <MetadataService > metadataService ;
186
183
187
184
/**
188
185
* The argument for the {@link PublicKeyCredentialCreationOptions#getPubKeyCredParams() pubKeyCredParams} parameter
@@ -291,7 +288,7 @@ public PublicKeyCredentialCreationOptions startRegistration(StartRegistrationOpt
291
288
.challenge (generateChallenge ())
292
289
.pubKeyCredParams (preferredPubkeyParams )
293
290
.excludeCredentials (
294
- Optional . of ( credentialRepository .getCredentialIdsForUsername (startRegistrationOptions .getUser ().getName () ))
291
+ credentialRepository .getCredentialIdsForUsername (startRegistrationOptions .getUser ().getName ())
295
292
)
296
293
.authenticatorSelection (startRegistrationOptions .getAuthenticatorSelection ())
297
294
.extensions (startRegistrationOptions .getExtensions ())
@@ -336,7 +333,7 @@ FinishRegistrationSteps _finishRegistration(
336
333
public AssertionRequest startAssertion (StartAssertionOptions startAssertionOptions ) {
337
334
PublicKeyCredentialRequestOptionsBuilder pkcro = PublicKeyCredentialRequestOptions .builder ()
338
335
.challenge (generateChallenge ())
339
- .rpId (Optional . of ( identity .getId () ))
336
+ .rpId (identity .getId ())
340
337
.allowCredentials (
341
338
startAssertionOptions .getUsername ().map (un ->
342
339
new ArrayList <>(credentialRepository .getCredentialIdsForUsername (un )))
@@ -404,6 +401,10 @@ public static RelyingPartyBuilder.MandatoryStages builder() {
404
401
}
405
402
406
403
public static class RelyingPartyBuilder {
404
+ private @ NonNull Optional <AppId > appId = Optional .empty ();
405
+ private @ NonNull Optional <AttestationConveyancePreference > attestationConveyancePreference = Optional .empty ();
406
+ private @ NonNull Optional <MetadataService > metadataService = Optional .empty ();
407
+
407
408
public static class MandatoryStages {
408
409
private final RelyingPartyBuilder builder = new RelyingPartyBuilder ();
409
410
@@ -429,5 +430,120 @@ public RelyingPartyBuilder credentialRepository(CredentialRepository credentialR
429
430
}
430
431
}
431
432
}
433
+
434
+ /**
435
+ * The extension input to set for the <code>appid</code> extension when initiating authentication operations.
436
+ *
437
+ * <p>
438
+ * If this member is set, {@link #startAssertion(StartAssertionOptions) startAssertion} will automatically set the
439
+ * <code>appid</code> extension input, and {@link #finishAssertion(FinishAssertionOptions) finishAssertion} will
440
+ * adjust its verification logic to also accept this AppID as an alternative to the RP ID.
441
+ * </p>
442
+ *
443
+ * <p>
444
+ * By default, this is not set.
445
+ * </p>
446
+ *
447
+ * @see AssertionExtensionInputs#getAppid()
448
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
449
+ * (appid)</a>
450
+ */
451
+ public RelyingPartyBuilder appId (@ NonNull Optional <AppId > appId ) {
452
+ this .appId = appId ;
453
+ return this ;
454
+ }
455
+
456
+ /**
457
+ * The extension input to set for the <code>appid</code> extension when initiating authentication operations.
458
+ *
459
+ * <p>
460
+ * If this member is set, {@link #startAssertion(StartAssertionOptions) startAssertion} will automatically set the
461
+ * <code>appid</code> extension input, and {@link #finishAssertion(FinishAssertionOptions) finishAssertion} will
462
+ * adjust its verification logic to also accept this AppID as an alternative to the RP ID.
463
+ * </p>
464
+ *
465
+ * <p>
466
+ * By default, this is not set.
467
+ * </p>
468
+ *
469
+ * @see AssertionExtensionInputs#getAppid()
470
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-appid-extension">§10.1. FIDO AppID Extension
471
+ * (appid)</a>
472
+ */
473
+ public RelyingPartyBuilder appId (@ NonNull AppId appId ) {
474
+ return this .appId (Optional .of (appId ));
475
+ }
476
+
477
+ /**
478
+ * The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
479
+ * registration operations.
480
+ *
481
+ * <p>
482
+ * Unless your application has a concrete policy for authenticator attestation, it is recommended to leave this
483
+ * parameter undefined.
484
+ * </p>
485
+ *
486
+ * <p>
487
+ * By default, this is not set.
488
+ * </p>
489
+ *
490
+ * @see PublicKeyCredentialCreationOptions#getAttestation()
491
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
492
+ */
493
+ public RelyingPartyBuilder attestationConveyancePreference (@ NonNull Optional <AttestationConveyancePreference > attestationConveyancePreference ) {
494
+ this .attestationConveyancePreference = attestationConveyancePreference ;
495
+ return this ;
496
+ }
497
+
498
+ /**
499
+ * The argument for the {@link PublicKeyCredentialCreationOptions#getAttestation() attestation} parameter in
500
+ * registration operations.
501
+ *
502
+ * <p>
503
+ * Unless your application has a concrete policy for authenticator attestation, it is recommended to leave this
504
+ * parameter undefined.
505
+ * </p>
506
+ *
507
+ * <p>
508
+ * By default, this is not set.
509
+ * </p>
510
+ *
511
+ * @see PublicKeyCredentialCreationOptions#getAttestation()
512
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
513
+ */
514
+ public RelyingPartyBuilder attestationConveyancePreference (@ NonNull AttestationConveyancePreference attestationConveyancePreference ) {
515
+ return this .attestationConveyancePreference (Optional .of (attestationConveyancePreference ));
516
+ }
517
+
518
+ /**
519
+ * A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
520
+ * #getAttestationConveyancePreference()} is non-empty and not set to {@link AttestationConveyancePreference#NONE}.
521
+ *
522
+ * <p>
523
+ * By default, this is not set.
524
+ * </p>
525
+ *
526
+ * @see PublicKeyCredentialCreationOptions#getAttestation()
527
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
528
+ */
529
+ public RelyingPartyBuilder metadataService (@ NonNull Optional <MetadataService > metadataService ) {
530
+ this .metadataService = metadataService ;
531
+ return this ;
532
+ }
533
+
534
+ /**
535
+ * A {@link MetadataService} instance to use for looking up device attestation metadata. This matters only if {@link
536
+ * #getAttestationConveyancePreference()} is non-empty and not set to {@link AttestationConveyancePreference#NONE}.
537
+ *
538
+ * <p>
539
+ * By default, this is not set.
540
+ * </p>
541
+ *
542
+ * @see PublicKeyCredentialCreationOptions#getAttestation()
543
+ * @see <a href="https://www.w3.org/TR/2019/PR-webauthn-20190117/#sctn-attestation">§6.4. Attestation</a>
544
+ */
545
+ public RelyingPartyBuilder metadataService (@ NonNull MetadataService metadataService ) {
546
+ return this .metadataService (Optional .of (metadataService ));
547
+ }
432
548
}
433
549
}
0 commit comments