1 | // Copyright (c) 2018, Yubico AB | |
2 | // All rights reserved. | |
3 | // | |
4 | // Redistribution and use in source and binary forms, with or without | |
5 | // modification, are permitted provided that the following conditions are met: | |
6 | // | |
7 | // 1. Redistributions of source code must retain the above copyright notice, this | |
8 | // list of conditions and the following disclaimer. | |
9 | // | |
10 | // 2. Redistributions in binary form must reproduce the above copyright notice, | |
11 | // this list of conditions and the following disclaimer in the documentation | |
12 | // and/or other materials provided with the distribution. | |
13 | // | |
14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
17 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
18 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
19 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
20 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
21 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
22 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | ||
25 | package com.yubico.webauthn.data; | |
26 | ||
27 | import com.fasterxml.jackson.annotation.JsonCreator; | |
28 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
29 | import com.fasterxml.jackson.annotation.JsonProperty; | |
30 | import com.yubico.webauthn.RelyingParty; | |
31 | import com.yubico.webauthn.StartRegistrationOptions; | |
32 | import com.yubico.webauthn.extension.appid.AppId; | |
33 | import java.util.Collections; | |
34 | import java.util.HashSet; | |
35 | import java.util.Optional; | |
36 | import java.util.Set; | |
37 | import lombok.Builder; | |
38 | import lombok.Value; | |
39 | ||
40 | /** | |
41 | * Contains <a | |
42 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-extension-input">client | |
43 | * extension inputs</a> to a <code>navigator.credentials.create()</code> operation. All members are | |
44 | * optional. | |
45 | * | |
46 | * <p>The authenticator extension inputs are derived from these client extension inputs. | |
47 | * | |
48 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-extensions">§9. WebAuthn | |
49 | * Extensions</a> | |
50 | */ | |
51 | @Value | |
52 | @Builder(toBuilder = true) | |
53 | @JsonIgnoreProperties(ignoreUnknown = true) | |
54 | public final class RegistrationExtensionInputs implements ExtensionInputs { | |
55 | ||
56 | private final AppId appidExclude; | |
57 | private final Boolean credProps; | |
58 | private final Extensions.LargeBlob.LargeBlobRegistrationInput largeBlob; | |
59 | private final Boolean uvm; | |
60 | ||
61 | @JsonCreator | |
62 | private RegistrationExtensionInputs( | |
63 | @JsonProperty("appidExclude") AppId appidExclude, | |
64 | @JsonProperty("credProps") Boolean credProps, | |
65 | @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobRegistrationInput largeBlob, | |
66 | @JsonProperty("uvm") Boolean uvm) { | |
67 | this.appidExclude = appidExclude; | |
68 | this.credProps = credProps; | |
69 | this.largeBlob = largeBlob; | |
70 | this.uvm = uvm; | |
71 | } | |
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 |
1
1. merge : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs::merge → KILLED |
return new RegistrationExtensionInputs( |
82 |
1
1. merge : negated conditional → KILLED |
this.appidExclude != null ? this.appidExclude : other.appidExclude, |
83 |
1
1. merge : negated conditional → KILLED |
this.credProps != null ? this.credProps : other.credProps, |
84 |
1
1. merge : negated conditional → SURVIVED |
this.largeBlob != null ? this.largeBlob : other.largeBlob, |
85 |
1
1. merge : negated conditional → KILLED |
this.uvm != null ? this.uvm : other.uvm); |
86 | } | |
87 | ||
88 | /** | |
89 | * @return The value of the FIDO AppID Exclusion Extension (<code>appidExclude</code>) input if | |
90 | * configured, empty otherwise. | |
91 | * @see RegistrationExtensionInputsBuilder#appidExclude(AppId) | |
92 | * @see <a | |
93 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2. | |
94 | * FIDO AppID Exclusion Extension (appidExclude)</a> | |
95 | */ | |
96 | public Optional<AppId> getAppidExclude() { | |
97 |
1
1. getAppidExclude : replaced return value with Optional.empty for com/yubico/webauthn/data/RegistrationExtensionInputs::getAppidExclude → KILLED |
return Optional.ofNullable(appidExclude); |
98 | } | |
99 | ||
100 | /** | |
101 | * @return <code>true</code> if the Credential Properties Extension (<code>credProps</code>) is | |
102 | * enabled, <code>false</code> otherwise. | |
103 | * @see RegistrationExtensionInputsBuilder#credProps() | |
104 | * @see <a | |
105 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4. | |
106 | * Credential Properties Extension (credProps)</a> | |
107 | */ | |
108 | public boolean getCredProps() { | |
109 |
3
1. getCredProps : negated conditional → KILLED 2. getCredProps : replaced boolean return with true for com/yubico/webauthn/data/RegistrationExtensionInputs::getCredProps → KILLED 3. getCredProps : negated conditional → KILLED |
return credProps != null && credProps; |
110 | } | |
111 | ||
112 | /** For JSON serialization, to omit false values. */ | |
113 | @JsonProperty("credProps") | |
114 | private Boolean getCredPropsJson() { | |
115 |
3
1. getCredPropsJson : negated conditional → KILLED 2. getCredPropsJson : replaced Boolean return with False for com/yubico/webauthn/data/RegistrationExtensionInputs::getCredPropsJson → KILLED 3. getCredPropsJson : replaced Boolean return with True for com/yubico/webauthn/data/RegistrationExtensionInputs::getCredPropsJson → KILLED |
return getCredProps() ? true : null; |
116 | } | |
117 | ||
118 | /** | |
119 | * @return The value of the Large blob storage extension (<code>largeBlob</code>) input if | |
120 | * configured, empty otherwise. | |
121 | * @see | |
122 | * RegistrationExtensionInputsBuilder#largeBlob(Extensions.LargeBlob.LargeBlobRegistrationInput) | |
123 | * @see | |
124 | * RegistrationExtensionInputsBuilder#largeBlob(Extensions.LargeBlob.LargeBlobRegistrationInput.LargeBlobSupport) | |
125 | * @see <a | |
126 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5. | |
127 | * Large blob storage extension (largeBlob)</a> | |
128 | */ | |
129 | public Optional<Extensions.LargeBlob.LargeBlobRegistrationInput> getLargeBlob() { | |
130 |
1
1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/RegistrationExtensionInputs::getLargeBlob → KILLED |
return Optional.ofNullable(largeBlob); |
131 | } | |
132 | ||
133 | /** | |
134 | * @return <code>true</code> if the User Verification Method Extension (<code>uvm</code>) is | |
135 | * enabled, <code>false</code> otherwise. | |
136 | * @see RegistrationExtensionInputsBuilder#uvm() | |
137 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-uvm-extension">§10.3. | |
138 | * User Verification Method Extension (uvm)</a> | |
139 | */ | |
140 | public boolean getUvm() { | |
141 |
3
1. getUvm : negated conditional → KILLED 2. getUvm : negated conditional → KILLED 3. getUvm : replaced boolean return with true for com/yubico/webauthn/data/RegistrationExtensionInputs::getUvm → KILLED |
return uvm != null && uvm; |
142 | } | |
143 | ||
144 | /** For JSON serialization, to omit false values. */ | |
145 | @JsonProperty("uvm") | |
146 | private Boolean getUvmJson() { | |
147 |
3
1. getUvmJson : replaced Boolean return with False for com/yubico/webauthn/data/RegistrationExtensionInputs::getUvmJson → KILLED 2. getUvmJson : replaced Boolean return with True for com/yubico/webauthn/data/RegistrationExtensionInputs::getUvmJson → KILLED 3. getUvmJson : negated conditional → KILLED |
return getUvm() ? true : null; |
148 | } | |
149 | ||
150 | /** | |
151 | * @return The extension identifiers of all extensions configured. | |
152 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-extension-id">§9.1. | |
153 | * Extension Identifiers</a> | |
154 | */ | |
155 | @Override | |
156 | public Set<String> getExtensionIds() { | |
157 | Set<String> ids = new HashSet<>(); | |
158 |
1
1. getExtensionIds : negated conditional → KILLED |
if (appidExclude != null) { |
159 | ids.add(Extensions.AppidExclude.EXTENSION_ID); | |
160 | } | |
161 |
1
1. getExtensionIds : negated conditional → KILLED |
if (getCredProps()) { |
162 | ids.add(Extensions.CredentialProperties.EXTENSION_ID); | |
163 | } | |
164 |
1
1. getExtensionIds : negated conditional → KILLED |
if (largeBlob != null) { |
165 | ids.add(Extensions.LargeBlob.EXTENSION_ID); | |
166 | } | |
167 |
1
1. getExtensionIds : negated conditional → KILLED |
if (getUvm()) { |
168 | ids.add(Extensions.Uvm.EXTENSION_ID); | |
169 | } | |
170 |
1
1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/RegistrationExtensionInputs::getExtensionIds → KILLED |
return Collections.unmodifiableSet(ids); |
171 | } | |
172 | ||
173 | public static class RegistrationExtensionInputsBuilder { | |
174 | /** | |
175 | * Enable or disable the FIDO AppID Exclusion Extension (<code>appidExclude</code>). | |
176 | * | |
177 | * <p>You usually do not need to call this method explicitly; if {@link RelyingParty#getAppId()} | |
178 | * is present, then {@link RelyingParty#startRegistration(StartRegistrationOptions)} will enable | |
179 | * this extension automatically. | |
180 | * | |
181 | * <p>If this is set to empty, then {@link | |
182 | * RelyingParty#startRegistration(StartRegistrationOptions)} may overwrite it. | |
183 | * | |
184 | * @see RelyingParty#startRegistration(StartRegistrationOptions) | |
185 | * @see <a | |
186 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2. | |
187 | * FIDO AppID Exclusion Extension (appidExclude)</a> | |
188 | */ | |
189 | public RegistrationExtensionInputsBuilder appidExclude(Optional<AppId> appidExclude) { | |
190 | this.appidExclude = appidExclude.orElse(null); | |
191 |
1
1. appidExclude : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::appidExclude → KILLED |
return this; |
192 | } | |
193 | ||
194 | /** | |
195 | * Enable the FIDO AppID Exclusion Extension (<code>appidExclude</code>). | |
196 | * | |
197 | * <p>You usually do not need to call this method explicitly; if {@link RelyingParty#getAppId()} | |
198 | * is present, then {@link RelyingParty#startRegistration(StartRegistrationOptions)} will enable | |
199 | * this extension automatically. | |
200 | * | |
201 | * <p>If this is set to null, then {@link | |
202 | * RelyingParty#startRegistration(StartRegistrationOptions)} may overwrite it. | |
203 | * | |
204 | * @see RelyingParty#startRegistration(StartRegistrationOptions) | |
205 | * @see <a | |
206 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2. | |
207 | * FIDO AppID Exclusion Extension (appidExclude)</a> | |
208 | */ | |
209 | public RegistrationExtensionInputsBuilder appidExclude(AppId appidExclude) { | |
210 | this.appidExclude = appidExclude; | |
211 |
1
1. appidExclude : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::appidExclude → KILLED |
return this; |
212 | } | |
213 | ||
214 | /** | |
215 | * Enable the Credential Properties (<code>credProps</code>) Extension. | |
216 | * | |
217 | * @see <a | |
218 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4. | |
219 | * Credential Properties Extension (credProps)</a> | |
220 | */ | |
221 | public RegistrationExtensionInputsBuilder credProps() { | |
222 | this.credProps = true; | |
223 |
1
1. credProps : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::credProps → KILLED |
return this; |
224 | } | |
225 | ||
226 | /** | |
227 | * Enable or disable the Credential Properties (<code>credProps</code>) Extension. | |
228 | * | |
229 | * <p>A <code>true</code> argument enables the extension. A <code>false</code> argument disables | |
230 | * the extension, and will not be overwritten by {@link | |
231 | * RelyingParty#startRegistration(StartRegistrationOptions)}. A null argument disables the | |
232 | * extension, and will be overwritten by {@link | |
233 | * RelyingParty#startRegistration(StartRegistrationOptions)}. | |
234 | * | |
235 | * @see RelyingParty#startRegistration(StartRegistrationOptions) | |
236 | * @see <a | |
237 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4. | |
238 | * Credential Properties Extension (credProps)</a> | |
239 | */ | |
240 | public RegistrationExtensionInputsBuilder credProps(Boolean credProps) { | |
241 | this.credProps = credProps; | |
242 |
1
1. credProps : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::credProps → KILLED |
return this; |
243 | } | |
244 | ||
245 | /** | |
246 | * Enable the Large blob storage extension (<code>largeBlob</code>). | |
247 | * | |
248 | * <p>Alias of <code>largeBlob(new Extensions.LargeBlob.LargeBlobRegistrationInput(support)) | |
249 | * </code>. | |
250 | * | |
251 | * @param support an {@link | |
252 | * com.yubico.webauthn.data.Extensions.LargeBlob.LargeBlobRegistrationInput.LargeBlobSupport} | |
253 | * value to set as the <code>support</code> attribute of the <code>largeBlob</code> | |
254 | * extension input. | |
255 | * @see #largeBlob(Extensions.LargeBlob.LargeBlobRegistrationInput) | |
256 | * @see <a | |
257 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5. | |
258 | * Large blob storage extension (largeBlob)</a> | |
259 | */ | |
260 | public RegistrationExtensionInputsBuilder largeBlob( | |
261 | Extensions.LargeBlob.LargeBlobRegistrationInput.LargeBlobSupport support) { | |
262 | this.largeBlob = new Extensions.LargeBlob.LargeBlobRegistrationInput(support); | |
263 |
1
1. largeBlob : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::largeBlob → KILLED |
return this; |
264 | } | |
265 | ||
266 | /** | |
267 | * Enable the Large blob storage extension (<code>largeBlob</code>). | |
268 | * | |
269 | * @see #largeBlob(Extensions.LargeBlob.LargeBlobRegistrationInput.LargeBlobSupport) | |
270 | * @see <a | |
271 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5. | |
272 | * Large blob storage extension (largeBlob)</a> | |
273 | */ | |
274 | public RegistrationExtensionInputsBuilder largeBlob( | |
275 | Extensions.LargeBlob.LargeBlobRegistrationInput largeBlob) { | |
276 | this.largeBlob = largeBlob; | |
277 |
1
1. largeBlob : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::largeBlob → KILLED |
return this; |
278 | } | |
279 | ||
280 | /** | |
281 | * Enable the User Verification Method Extension (<code>uvm</code>). | |
282 | * | |
283 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-uvm-extension">§10.3. | |
284 | * User Verification Method Extension (uvm)</a> | |
285 | */ | |
286 | public RegistrationExtensionInputsBuilder uvm() { | |
287 | this.uvm = true; | |
288 |
1
1. uvm : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::uvm → KILLED |
return this; |
289 | } | |
290 | ||
291 | /** For compatibility with {@link Builder}(toBuilder = true) */ | |
292 | private RegistrationExtensionInputsBuilder uvm(Boolean uvm) { | |
293 | this.uvm = uvm; | |
294 |
1
1. uvm : replaced return value with null for com/yubico/webauthn/data/RegistrationExtensionInputs$RegistrationExtensionInputsBuilder::uvm → KILLED |
return this; |
295 | } | |
296 | } | |
297 | } | |
Mutations | ||
81 |
1.1 |
|
82 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
85 |
1.1 |
|
97 |
1.1 |
|
109 |
1.1 2.2 3.3 |
|
115 |
1.1 2.2 3.3 |
|
130 |
1.1 |
|
141 |
1.1 2.2 3.3 |
|
147 |
1.1 2.2 3.3 |
|
158 |
1.1 |
|
161 |
1.1 |
|
164 |
1.1 |
|
167 |
1.1 |
|
170 |
1.1 |
|
191 |
1.1 |
|
211 |
1.1 |
|
223 |
1.1 |
|
242 |
1.1 |
|
263 |
1.1 |
|
277 |
1.1 |
|
288 |
1.1 |
|
294 |
1.1 |