54
54
public final class RegistrationExtensionInputs implements ExtensionInputs {
55
55
56
56
private final AppId appidExclude ;
57
-
58
- private final boolean credProps ;
57
+ private final Boolean credProps ;
59
58
private final Extensions .LargeBlob .LargeBlobRegistrationInput largeBlob ;
60
- private final boolean uvm ;
59
+ private final Boolean uvm ;
61
60
62
61
@ JsonCreator
63
62
private RegistrationExtensionInputs (
64
63
@ JsonProperty ("appidExclude" ) AppId appidExclude ,
65
- @ JsonProperty ("credProps" ) boolean credProps ,
64
+ @ JsonProperty ("credProps" ) Boolean credProps ,
66
65
@ JsonProperty ("largeBlob" ) Extensions .LargeBlob .LargeBlobRegistrationInput largeBlob ,
67
- @ JsonProperty ("uvm" ) boolean uvm ) {
66
+ @ JsonProperty ("uvm" ) Boolean uvm ) {
68
67
this .appidExclude = appidExclude ;
69
68
this .credProps = credProps ;
70
69
this .largeBlob = largeBlob ;
71
70
this .uvm = uvm ;
72
71
}
73
72
73
+ /**
74
+ * Merge <code>other</code> into <code>this</code>. Non-null field values from <code>this</code>
75
+ * take precedence.
76
+ *
77
+ * @return a new {@link RegistrationExtensionInputs} instance with the settings from both <code>
78
+ * this</code> and <code>other</code>.
79
+ */
80
+ public RegistrationExtensionInputs merge (RegistrationExtensionInputs other ) {
81
+ return new RegistrationExtensionInputs (
82
+ this .appidExclude != null ? this .appidExclude : other .appidExclude ,
83
+ this .credProps != null ? this .credProps : other .credProps ,
84
+ this .largeBlob != null ? this .largeBlob : other .largeBlob ,
85
+ this .uvm != null ? this .uvm : other .uvm );
86
+ }
87
+
74
88
/**
75
89
* @return The value of the FIDO AppID Exclusion Extension (<code>appidExclude</code>) input if
76
90
* configured, empty otherwise.
@@ -92,13 +106,13 @@ public Optional<AppId> getAppidExclude() {
92
106
* Credential Properties Extension (credProps)</a>
93
107
*/
94
108
public boolean getCredProps () {
95
- return credProps ;
109
+ return credProps != null && credProps ;
96
110
}
97
111
98
112
/** For JSON serialization, to omit false values. */
99
113
@ JsonProperty ("credProps" )
100
114
private Boolean getCredPropsJson () {
101
- return credProps ? true : null ;
115
+ return getCredProps () ? true : null ;
102
116
}
103
117
104
118
/**
@@ -124,13 +138,13 @@ public Optional<Extensions.LargeBlob.LargeBlobRegistrationInput> getLargeBlob()
124
138
* User Verification Method Extension (uvm)</a>
125
139
*/
126
140
public boolean getUvm () {
127
- return uvm ;
141
+ return uvm != null && uvm ;
128
142
}
129
143
130
144
/** For JSON serialization, to omit false values. */
131
145
@ JsonProperty ("uvm" )
132
146
private Boolean getUvmJson () {
133
- return uvm ? true : null ;
147
+ return getUvm () ? true : null ;
134
148
}
135
149
136
150
/**
@@ -144,13 +158,13 @@ public Set<String> getExtensionIds() {
144
158
if (appidExclude != null ) {
145
159
ids .add (Extensions .AppidExclude .EXTENSION_ID );
146
160
}
147
- if (credProps ) {
161
+ if (getCredProps () ) {
148
162
ids .add (Extensions .CredentialProperties .EXTENSION_ID );
149
163
}
150
164
if (largeBlob != null ) {
151
165
ids .add (Extensions .LargeBlob .EXTENSION_ID );
152
166
}
153
- if (uvm ) {
167
+ if (getUvm () ) {
154
168
ids .add (Extensions .Uvm .EXTENSION_ID );
155
169
}
156
170
return Collections .unmodifiableSet (ids );
@@ -164,6 +178,10 @@ public static class RegistrationExtensionInputsBuilder {
164
178
* is present, then {@link RelyingParty#startRegistration(StartRegistrationOptions)} will enable
165
179
* this extension automatically.
166
180
*
181
+ * <p>If this is set to empty, then {@link
182
+ * RelyingParty#startRegistration(StartRegistrationOptions)} may overwrite it.
183
+ *
184
+ * @see RelyingParty#startRegistration(StartRegistrationOptions)
167
185
* @see <a
168
186
* href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2.
169
187
* FIDO AppID Exclusion Extension (appidExclude)</a>
@@ -180,6 +198,10 @@ public RegistrationExtensionInputsBuilder appidExclude(Optional<AppId> appidExcl
180
198
* is present, then {@link RelyingParty#startRegistration(StartRegistrationOptions)} will enable
181
199
* this extension automatically.
182
200
*
201
+ * <p>If this is set to null, then {@link
202
+ * RelyingParty#startRegistration(StartRegistrationOptions)} may overwrite it.
203
+ *
204
+ * @see RelyingParty#startRegistration(StartRegistrationOptions)
183
205
* @see <a
184
206
* href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2.
185
207
* FIDO AppID Exclusion Extension (appidExclude)</a>
0 commit comments