3030import com .yubico .webauthn .RelyingParty ;
3131import com .yubico .webauthn .StartAssertionOptions ;
3232import com .yubico .webauthn .extension .appid .AppId ;
33+ import java .util .HashMap ;
3334import java .util .HashSet ;
3435import java .util .Optional ;
3536import java .util .Set ;
@@ -55,15 +56,18 @@ public class AssertionExtensionInputs implements ExtensionInputs {
5556
5657 private final AppId appid ;
5758 private final Extensions .LargeBlob .LargeBlobAuthenticationInput largeBlob ;
59+ private final Extensions .Prf .PrfAuthenticationInput prf ;
5860 private final Boolean uvm ;
5961
6062 @ JsonCreator
6163 private AssertionExtensionInputs (
6264 @ JsonProperty ("appid" ) AppId appid ,
6365 @ JsonProperty ("largeBlob" ) Extensions .LargeBlob .LargeBlobAuthenticationInput largeBlob ,
66+ @ JsonProperty ("prf" ) Extensions .Prf .PrfAuthenticationInput prf ,
6467 @ JsonProperty ("uvm" ) Boolean uvm ) {
6568 this .appid = appid ;
6669 this .largeBlob = largeBlob ;
70+ this .prf = prf ;
6771 this .uvm = (uvm != null && uvm ) ? true : null ;
6872 }
6973
@@ -78,6 +82,7 @@ public AssertionExtensionInputs merge(AssertionExtensionInputs other) {
7882 return new AssertionExtensionInputs (
7983 this .appid != null ? this .appid : other .appid ,
8084 this .largeBlob != null ? this .largeBlob : other .largeBlob ,
85+ this .prf != null ? this .prf : other .prf ,
8186 this .uvm != null ? this .uvm : other .uvm );
8287 }
8388
@@ -95,6 +100,9 @@ public Set<String> getExtensionIds() {
95100 if (largeBlob != null ) {
96101 ids .add (Extensions .LargeBlob .EXTENSION_ID );
97102 }
103+ if (prf != null ) {
104+ ids .add (Extensions .Prf .EXTENSION_ID );
105+ }
98106 if (getUvm ()) {
99107 ids .add (Extensions .Uvm .EXTENSION_ID );
100108 }
@@ -172,6 +180,38 @@ public AssertionExtensionInputsBuilder largeBlob(
172180 return this ;
173181 }
174182
183+ /**
184+ * Enable the Pseudo-random function extension (<code>prf</code>).
185+ *
186+ * <p>Alias of <code>prf(new Extensions.Prf.PrfRegistrationInput(eval))
187+ * </code>.
188+ *
189+ * @param eval an {@link Extensions.Prf.PrfValues} value to set as the <code>eval</code>
190+ * attribute of the <code>prf</code> extension input.
191+ * @see #prf(Extensions.Prf.PrfRegistrationInput)
192+ * @see <a
193+ * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.
194+ * Large blob storage extension (largeBlob)</a>
195+ */
196+ public AssertionExtensionInputsBuilder prf (
197+ Extensions .Prf .PrfValues eval ,
198+ HashMap <PublicKeyCredentialDescriptor , Extensions .Prf .PrfValues > evalByCredential ) {
199+ this .prf = new Extensions .Prf .PrfAuthenticationInput (eval , evalByCredential );
200+ return this ;
201+ }
202+
203+ /**
204+ * Enable the Pseudo-random function extension (<code>prf</code>).
205+ *
206+ * @see <a
207+ * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.
208+ * Large blob storage extension (largeBlob)</a>
209+ */
210+ public AssertionExtensionInputsBuilder prf (Extensions .Prf .PrfAuthenticationInput prf ) {
211+ this .prf = prf ;
212+ return this ;
213+ }
214+
175215 /**
176216 * Enable the User Verification Method Extension (<code>uvm</code>).
177217 *
@@ -233,6 +273,30 @@ private Extensions.LargeBlob.LargeBlobAuthenticationInput getLargeBlobJson() {
233273 : null ;
234274 }
235275
276+ /**
277+ * The input to the Pseudo-random function extension (<code>prf</code>).
278+ *
279+ * <p>This extension allows a Relying Party to evaluate outputs from a pseudo-random function
280+ * (PRF) associated with a credential.
281+ *
282+ * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#read()
283+ * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#write(ByteArray)
284+ * @see <a
285+ * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.
286+ * Large blob storage extension (largeBlob)</a>
287+ */
288+ public Optional <Extensions .Prf .PrfAuthenticationInput > getPrf () {
289+ return Optional .ofNullable (prf );
290+ }
291+
292+ /** For JSON serialization, to omit false and null values. */
293+ @ JsonProperty ("prf" )
294+ private Extensions .Prf .PrfAuthenticationInput getPrfJson () {
295+ return prf != null && (prf .getEval ().isPresent () || prf .getEvalByCredential ().isPresent ())
296+ ? prf
297+ : null ;
298+ }
299+
236300 /**
237301 * @return <code>true</code> if the User Verification Method Extension (<code>uvm</code>) is
238302 * enabled, <code>false</code> otherwise.
0 commit comments