| 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.StartAssertionOptions; | |
| 32 | import com.yubico.webauthn.extension.appid.AppId; | |
| 33 | import java.util.HashSet; | |
| 34 | import java.util.Map; | |
| 35 | import java.util.Optional; | |
| 36 | import java.util.Set; | |
| 37 | import lombok.Builder; | |
| 38 | import lombok.NonNull; | |
| 39 | import lombok.Value; | |
| 40 | ||
| 41 | /** | |
| 42 | * Contains <a | |
| 43 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-extension-input">client | |
| 44 | * extension inputs</a> to a <code>navigator.credentials.get()</code> operation. All members are | |
| 45 | * optional. | |
| 46 | * | |
| 47 | * <p>The authenticator extension inputs are derived from these client extension inputs. | |
| 48 | * | |
| 49 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-extensions">§9. WebAuthn | |
| 50 | * Extensions</a> | |
| 51 | */ | |
| 52 | @Value | |
| 53 | @Builder(toBuilder = true) | |
| 54 | @JsonIgnoreProperties(ignoreUnknown = true) | |
| 55 | public class AssertionExtensionInputs implements ExtensionInputs { | |
| 56 | ||
| 57 | private final AppId appid; | |
| 58 | private final Extensions.LargeBlob.LargeBlobAuthenticationInput largeBlob; | |
| 59 | private final Extensions.Prf.PrfAuthenticationInput prf; | |
| 60 | private final Boolean uvm; | |
| 61 | ||
| 62 | @JsonCreator | |
| 63 | private AssertionExtensionInputs( | |
| 64 | @JsonProperty("appid") AppId appid, | |
| 65 | @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobAuthenticationInput largeBlob, | |
| 66 | @JsonProperty("prf") Extensions.Prf.PrfAuthenticationInput prf, | |
| 67 | @JsonProperty("uvm") Boolean uvm) { | |
| 68 | this.appid = appid; | |
| 69 | this.largeBlob = largeBlob; | |
| 70 | this.prf = prf; | |
| 71 |
2
1. <init> : negated conditional → KILLED 2. <init> : negated conditional → KILLED |
this.uvm = (uvm != null && uvm) ? true : null; |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * Merge <code>other</code> into <code>this</code>. Non-null field values from <code>this</code> | |
| 76 | * take precedence. | |
| 77 | * | |
| 78 | * @return a new {@link AssertionExtensionInputs} instance with the settings from both <code>this | |
| 79 | * </code> and <code>other</code>. | |
| 80 | */ | |
| 81 | public AssertionExtensionInputs merge(AssertionExtensionInputs other) { | |
| 82 |
1
1. merge : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs::merge → KILLED |
return new AssertionExtensionInputs( |
| 83 |
1
1. merge : negated conditional → KILLED |
this.appid != null ? this.appid : other.appid, |
| 84 |
1
1. merge : negated conditional → SURVIVED |
this.largeBlob != null ? this.largeBlob : other.largeBlob, |
| 85 |
1
1. merge : negated conditional → SURVIVED |
this.prf != null ? this.prf : other.prf, |
| 86 |
1
1. merge : negated conditional → SURVIVED |
this.uvm != null ? this.uvm : other.uvm); |
| 87 | } | |
| 88 | ||
| 89 | /** | |
| 90 | * @return The extension identifiers of all extensions configured. | |
| 91 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-extension-id">§9.1. | |
| 92 | * Extension Identifiers</a> | |
| 93 | */ | |
| 94 | @Override | |
| 95 | public Set<String> getExtensionIds() { | |
| 96 | Set<String> ids = new HashSet<>(); | |
| 97 |
1
1. getExtensionIds : negated conditional → KILLED |
if (appid != null) { |
| 98 | ids.add(Extensions.Appid.EXTENSION_ID); | |
| 99 | } | |
| 100 |
1
1. getExtensionIds : negated conditional → KILLED |
if (largeBlob != null) { |
| 101 | ids.add(Extensions.LargeBlob.EXTENSION_ID); | |
| 102 | } | |
| 103 |
1
1. getExtensionIds : negated conditional → KILLED |
if (prf != null) { |
| 104 | ids.add(Extensions.Prf.EXTENSION_ID); | |
| 105 | } | |
| 106 |
1
1. getExtensionIds : negated conditional → KILLED |
if (getUvm()) { |
| 107 | ids.add(Extensions.Uvm.EXTENSION_ID); | |
| 108 | } | |
| 109 |
1
1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/AssertionExtensionInputs::getExtensionIds → KILLED |
return ids; |
| 110 | } | |
| 111 | ||
| 112 | public static class AssertionExtensionInputsBuilder { | |
| 113 | /** | |
| 114 | * The input to the FIDO AppID Extension (<code>appid</code>). | |
| 115 | * | |
| 116 | * <p>You usually do not need to call this method explicitly; if {@link RelyingParty#getAppId()} | |
| 117 | * is present, then {@link RelyingParty#startAssertion(StartAssertionOptions)} will enable this | |
| 118 | * extension automatically. | |
| 119 | * | |
| 120 | * <p>This extension allows WebAuthn Relying Parties that have previously registered a | |
| 121 | * credential using the legacy FIDO JavaScript APIs to request an assertion. The FIDO APIs use | |
| 122 | * an alternative identifier for Relying Parties called an <a | |
| 123 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-appid-and-facets-v2.0-id-20180227.html">AppID</a>, | |
| 124 | * and any credentials created using those APIs will be scoped to that identifier. Without this | |
| 125 | * extension, they would need to be re-registered in order to be scoped to an RP ID. | |
| 126 | * | |
| 127 | * <p>This extension does not allow FIDO-compatible credentials to be created. Thus, credentials | |
| 128 | * created with WebAuthn are not backwards compatible with the FIDO JavaScript APIs. | |
| 129 | * | |
| 130 | * @see <a | |
| 131 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
| 132 | * FIDO AppID Extension (appid)</a> | |
| 133 | */ | |
| 134 |
1
1. appid : negated conditional → KILLED |
public AssertionExtensionInputsBuilder appid(@NonNull Optional<AppId> appid) { |
| 135 |
1
1. appid : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::appid → KILLED |
return this.appid(appid.orElse(null)); |
| 136 | } | |
| 137 | ||
| 138 | /** | |
| 139 | * The input to the FIDO AppID Extension (<code>appid</code>). | |
| 140 | * | |
| 141 | * <p>You usually do not need to call this method explicitly; if {@link RelyingParty#getAppId()} | |
| 142 | * is present, then {@link RelyingParty#startAssertion(StartAssertionOptions)} will enable this | |
| 143 | * extension automatically. | |
| 144 | * | |
| 145 | * <p>This extension allows WebAuthn Relying Parties that have previously registered a | |
| 146 | * credential using the legacy FIDO JavaScript APIs to request an assertion. The FIDO APIs use | |
| 147 | * an alternative identifier for Relying Parties called an <a | |
| 148 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-appid-and-facets-v2.0-id-20180227.html">AppID</a>, | |
| 149 | * and any credentials created using those APIs will be scoped to that identifier. Without this | |
| 150 | * extension, they would need to be re-registered in order to be scoped to an RP ID. | |
| 151 | * | |
| 152 | * <p>This extension does not allow FIDO-compatible credentials to be created. Thus, credentials | |
| 153 | * created with WebAuthn are not backwards compatible with the FIDO JavaScript APIs. | |
| 154 | * | |
| 155 | * @see <a | |
| 156 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
| 157 | * FIDO AppID Extension (appid)</a> | |
| 158 | */ | |
| 159 | public AssertionExtensionInputsBuilder appid(AppId appid) { | |
| 160 | this.appid = appid; | |
| 161 |
1
1. appid : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::appid → KILLED |
return this; |
| 162 | } | |
| 163 | ||
| 164 | /** | |
| 165 | * Enable the Large blob storage extension (<code>largeBlob</code>). | |
| 166 | * | |
| 167 | * <p>Suitable arguments can be obtained using {@link | |
| 168 | * Extensions.LargeBlob.LargeBlobAuthenticationInput#read()} or {@link | |
| 169 | * Extensions.LargeBlob.LargeBlobAuthenticationInput#write(ByteArray)}. | |
| 170 | * | |
| 171 | * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#read() | |
| 172 | * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#write(ByteArray) | |
| 173 | * @see <a | |
| 174 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5. | |
| 175 | * Large blob storage extension (largeBlob)</a> | |
| 176 | */ | |
| 177 | public AssertionExtensionInputsBuilder largeBlob( | |
| 178 | Extensions.LargeBlob.LargeBlobAuthenticationInput largeBlob) { | |
| 179 | this.largeBlob = largeBlob; | |
| 180 |
1
1. largeBlob : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::largeBlob → KILLED |
return this; |
| 181 | } | |
| 182 | ||
| 183 | /** | |
| 184 | * Enable the Pseudo-random function extension (<code>prf</code>). | |
| 185 | * | |
| 186 | * <p>This extension allows a Relying Party to evaluate outputs from a pseudo-random function | |
| 187 | * (PRF) associated with a credential. | |
| 188 | * | |
| 189 | * <p>Use the {@link com.yubico.webauthn.data.Extensions.Prf.PrfAuthenticationInput} factory | |
| 190 | * functions to construct the argument: | |
| 191 | * | |
| 192 | * <ul> | |
| 193 | * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues)} to use | |
| 194 | * the same PRF input for all credentials. | |
| 195 | * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map)} to use | |
| 196 | * different PRF inputs for different credentials. | |
| 197 | * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map, | |
| 198 | * Extensions.Prf.PrfValues)} to use different PRF inputs for different credentials, but | |
| 199 | * with a "fallback" input for credentials without their own input. | |
| 200 | * </ul> | |
| 201 | * | |
| 202 | * @since 2.7.0 | |
| 203 | * @see Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues) | |
| 204 | * @see Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map) | |
| 205 | * @see Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map, | |
| 206 | * Extensions.Prf.PrfValues) | |
| 207 | * @see <a href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">§10.1.4. | |
| 208 | * Pseudo-random function extension (prf)</a> | |
| 209 | */ | |
| 210 | public AssertionExtensionInputsBuilder prf(Extensions.Prf.PrfAuthenticationInput prf) { | |
| 211 | this.prf = prf; | |
| 212 |
1
1. prf : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::prf → KILLED |
return this; |
| 213 | } | |
| 214 | ||
| 215 | /** | |
| 216 | * Enable the User Verification Method Extension (<code>uvm</code>). | |
| 217 | * | |
| 218 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-uvm-extension">§10.3. | |
| 219 | * User Verification Method Extension (uvm)</a> | |
| 220 | */ | |
| 221 | public AssertionExtensionInputsBuilder uvm() { | |
| 222 | this.uvm = true; | |
| 223 |
1
1. uvm : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::uvm → KILLED |
return this; |
| 224 | } | |
| 225 | ||
| 226 | /** For compatibility with {@link Builder}(toBuilder = true) */ | |
| 227 | private AssertionExtensionInputsBuilder uvm(Boolean uvm) { | |
| 228 | this.uvm = uvm; | |
| 229 |
1
1. uvm : replaced return value with null for com/yubico/webauthn/data/AssertionExtensionInputs$AssertionExtensionInputsBuilder::uvm → KILLED |
return this; |
| 230 | } | |
| 231 | } | |
| 232 | ||
| 233 | /** | |
| 234 | * The input to the FIDO AppID Extension (<code>appid</code>). | |
| 235 | * | |
| 236 | * <p>This extension allows WebAuthn Relying Parties that have previously registered a credential | |
| 237 | * using the legacy FIDO JavaScript APIs to request an assertion. The FIDO APIs use an alternative | |
| 238 | * identifier for Relying Parties called an <a | |
| 239 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-appid-and-facets-v2.0-id-20180227.html">AppID</a>, | |
| 240 | * and any credentials created using those APIs will be scoped to that identifier. Without this | |
| 241 | * extension, they would need to be re-registered in order to be scoped to an RP ID. | |
| 242 | * | |
| 243 | * <p>This extension does not allow FIDO-compatible credentials to be created. Thus, credentials | |
| 244 | * created with WebAuthn are not backwards compatible with the FIDO JavaScript APIs. | |
| 245 | * | |
| 246 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
| 247 | * FIDO AppID Extension (appid)</a> | |
| 248 | */ | |
| 249 | public Optional<AppId> getAppid() { | |
| 250 |
1
1. getAppid : replaced return value with Optional.empty for com/yubico/webauthn/data/AssertionExtensionInputs::getAppid → KILLED |
return Optional.ofNullable(appid); |
| 251 | } | |
| 252 | ||
| 253 | /** | |
| 254 | * The input to the Large blob storage extension (<code>largeBlob</code>). | |
| 255 | * | |
| 256 | * <p>This extension allows a Relying Party to store opaque data associated with a credential. | |
| 257 | * | |
| 258 | * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#read() | |
| 259 | * @see Extensions.LargeBlob.LargeBlobAuthenticationInput#write(ByteArray) | |
| 260 | * @see <a | |
| 261 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5. | |
| 262 | * Large blob storage extension (largeBlob)</a> | |
| 263 | */ | |
| 264 | public Optional<Extensions.LargeBlob.LargeBlobAuthenticationInput> getLargeBlob() { | |
| 265 |
1
1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/AssertionExtensionInputs::getLargeBlob → KILLED |
return Optional.ofNullable(largeBlob); |
| 266 | } | |
| 267 | ||
| 268 | /** For JSON serialization, to omit false and null values. */ | |
| 269 | @JsonProperty("largeBlob") | |
| 270 | private Extensions.LargeBlob.LargeBlobAuthenticationInput getLargeBlobJson() { | |
| 271 |
3
1. getLargeBlobJson : negated conditional → KILLED 2. getLargeBlobJson : negated conditional → KILLED 3. getLargeBlobJson : negated conditional → KILLED |
return largeBlob != null && (largeBlob.getRead() || largeBlob.getWrite().isPresent()) |
| 272 | ? largeBlob | |
| 273 | : null; | |
| 274 | } | |
| 275 | ||
| 276 | /** | |
| 277 | * The input to the Pseudo-random function extension (<code>prf</code>), if any. | |
| 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 | * @since 2.7.0 | |
| 283 | * @see Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues) | |
| 284 | * @see Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map) | |
| 285 | * @see Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map, | |
| 286 | * Extensions.Prf.PrfValues) | |
| 287 | * @see <a href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">§10.1.4. | |
| 288 | * Pseudo-random function extension (prf)</a> | |
| 289 | */ | |
| 290 | public Optional<Extensions.Prf.PrfAuthenticationInput> getPrf() { | |
| 291 |
1
1. getPrf : replaced return value with Optional.empty for com/yubico/webauthn/data/AssertionExtensionInputs::getPrf → KILLED |
return Optional.ofNullable(prf); |
| 292 | } | |
| 293 | ||
| 294 | /** For JSON serialization, to omit false and null values. */ | |
| 295 | @JsonProperty("prf") | |
| 296 | private Extensions.Prf.PrfAuthenticationInput getPrfJson() { | |
| 297 |
3
1. getPrfJson : negated conditional → NO_COVERAGE 2. getPrfJson : negated conditional → SURVIVED 3. getPrfJson : negated conditional → KILLED |
return prf != null && (prf.getEval().isPresent() || prf.getEvalByCredential().isPresent()) |
| 298 | ? prf | |
| 299 | : null; | |
| 300 | } | |
| 301 | ||
| 302 | /** | |
| 303 | * @return <code>true</code> if the User Verification Method Extension (<code>uvm</code>) is | |
| 304 | * enabled, <code>false</code> otherwise. | |
| 305 | * @see AssertionExtensionInputsBuilder#uvm() | |
| 306 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-uvm-extension">§10.3. | |
| 307 | * User Verification Method Extension (uvm)</a> | |
| 308 | */ | |
| 309 | public boolean getUvm() { | |
| 310 |
3
1. getUvm : replaced boolean return with true for com/yubico/webauthn/data/AssertionExtensionInputs::getUvm → KILLED 2. getUvm : negated conditional → KILLED 3. getUvm : negated conditional → KILLED |
return uvm != null && uvm; |
| 311 | } | |
| 312 | ||
| 313 | /** For JSON serialization, to omit false values. */ | |
| 314 | @JsonProperty("uvm") | |
| 315 | private Boolean getUvmJson() { | |
| 316 |
3
1. getUvmJson : replaced Boolean return with True for com/yubico/webauthn/data/AssertionExtensionInputs::getUvmJson → KILLED 2. getUvmJson : replaced Boolean return with False for com/yubico/webauthn/data/AssertionExtensionInputs::getUvmJson → KILLED 3. getUvmJson : negated conditional → KILLED |
return getUvm() ? true : null; |
| 317 | } | |
| 318 | } | |
Mutations | ||
| 71 |
1.1 2.2 |
|
| 82 |
1.1 |
|
| 83 |
1.1 |
|
| 84 |
1.1 |
|
| 85 |
1.1 |
|
| 86 |
1.1 |
|
| 97 |
1.1 |
|
| 100 |
1.1 |
|
| 103 |
1.1 |
|
| 106 |
1.1 |
|
| 109 |
1.1 |
|
| 134 |
1.1 |
|
| 135 |
1.1 |
|
| 161 |
1.1 |
|
| 180 |
1.1 |
|
| 212 |
1.1 |
|
| 223 |
1.1 |
|
| 229 |
1.1 |
|
| 250 |
1.1 |
|
| 265 |
1.1 |
|
| 271 |
1.1 2.2 3.3 |
|
| 291 |
1.1 |
|
| 297 |
1.1 2.2 3.3 |
|
| 310 |
1.1 2.2 3.3 |
|
| 316 |
1.1 2.2 3.3 |