25
25
package com .yubico .webauthn .data ;
26
26
27
27
import com .fasterxml .jackson .annotation .JsonCreator ;
28
+ import com .fasterxml .jackson .annotation .JsonIgnore ;
28
29
import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
29
30
import com .fasterxml .jackson .annotation .JsonProperty ;
30
31
import com .yubico .webauthn .RelyingParty ;
@@ -60,15 +61,13 @@ public final class RegistrationExtensionInputs implements ExtensionInputs {
60
61
private final Extensions .Prf .PrfRegistrationInput prf ;
61
62
private final Boolean uvm ;
62
63
63
- @ JsonCreator
64
64
private RegistrationExtensionInputs (
65
- @ JsonProperty ("appidExclude" ) AppId appidExclude ,
66
- @ JsonProperty ("credProps" ) Boolean credProps ,
67
- @ JsonProperty ("credProtect" )
68
- Extensions .CredentialProtection .CredentialProtectionInput credProtect ,
69
- @ JsonProperty ("largeBlob" ) Extensions .LargeBlob .LargeBlobRegistrationInput largeBlob ,
70
- @ JsonProperty ("prf" ) Extensions .Prf .PrfRegistrationInput prf ,
71
- @ JsonProperty ("uvm" ) Boolean uvm ) {
65
+ AppId appidExclude ,
66
+ Boolean credProps ,
67
+ Extensions .CredentialProtection .CredentialProtectionInput credProtect ,
68
+ Extensions .LargeBlob .LargeBlobRegistrationInput largeBlob ,
69
+ Extensions .Prf .PrfRegistrationInput prf ,
70
+ Boolean uvm ) {
72
71
this .appidExclude = appidExclude ;
73
72
this .credProps = credProps ;
74
73
this .credProtect = credProtect ;
@@ -77,6 +76,32 @@ private RegistrationExtensionInputs(
77
76
this .uvm = uvm ;
78
77
}
79
78
79
+ @ JsonCreator
80
+ private RegistrationExtensionInputs (
81
+ @ JsonProperty ("appidExclude" ) AppId appidExclude ,
82
+ @ JsonProperty ("credProps" ) Boolean credProps ,
83
+ @ JsonProperty ("credentialProtectionPolicy" )
84
+ Extensions .CredentialProtection .CredentialProtectionPolicy credProtectPolicy ,
85
+ @ JsonProperty ("enforceCredentialProtectionPolicy" ) Boolean enforceCredProtectPolicy ,
86
+ @ JsonProperty ("largeBlob" ) Extensions .LargeBlob .LargeBlobRegistrationInput largeBlob ,
87
+ @ JsonProperty ("prf" ) Extensions .Prf .PrfRegistrationInput prf ,
88
+ @ JsonProperty ("uvm" ) Boolean uvm ) {
89
+ this (
90
+ appidExclude ,
91
+ credProps ,
92
+ Optional .ofNullable (credProtectPolicy )
93
+ .map (
94
+ policy -> {
95
+ return enforceCredProtectPolicy != null && enforceCredProtectPolicy
96
+ ? Extensions .CredentialProtection .CredentialProtectionInput .require (policy )
97
+ : Extensions .CredentialProtection .CredentialProtectionInput .prefer (policy );
98
+ })
99
+ .orElse (null ),
100
+ largeBlob ,
101
+ prf ,
102
+ uvm );
103
+ }
104
+
80
105
/**
81
106
* Merge <code>other</code> into <code>this</code>. Non-null field values from <code>this</code>
82
107
* take precedence.
@@ -133,10 +158,36 @@ private Boolean getCredPropsJson() {
133
158
* href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4.
134
159
* Credential Properties Extension (credProps)</a>
135
160
*/
161
+ @ JsonIgnore
136
162
public Optional <Extensions .CredentialProtection .CredentialProtectionInput > getCredProtect () {
137
163
return Optional .ofNullable (credProtect );
138
164
}
139
165
166
+ /**
167
+ * For JSON serialization, because credProtect does not group all inputs under the "credProtect"
168
+ * key.
169
+ */
170
+ @ JsonProperty ("credentialProtectionPolicy" )
171
+ private Optional <Extensions .CredentialProtection .CredentialProtectionPolicy >
172
+ getCredProtectPolicy () {
173
+ return getCredProtect ()
174
+ .map (
175
+ Extensions .CredentialProtection .CredentialProtectionInput
176
+ ::getCredentialProtectionPolicy );
177
+ }
178
+
179
+ /**
180
+ * For JSON serialization, because credProtect does not group all inputs under the "credProtect"
181
+ * key.
182
+ */
183
+ @ JsonProperty ("enforceCredentialProtectionPolicy" )
184
+ private Optional <Boolean > getEnforceCredProtectPolicy () {
185
+ return getCredProtect ()
186
+ .map (
187
+ Extensions .CredentialProtection .CredentialProtectionInput
188
+ ::isEnforceCredentialProtectionPolicy );
189
+ }
190
+
140
191
/**
141
192
* @return The value of the Large blob storage extension (<code>largeBlob</code>) input if
142
193
* configured, empty otherwise.
0 commit comments