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 java.util.HashSet; | |
31 | import java.util.Optional; | |
32 | import java.util.Set; | |
33 | import lombok.Builder; | |
34 | import lombok.EqualsAndHashCode; | |
35 | import lombok.Value; | |
36 | ||
37 | /** | |
38 | * Contains <a | |
39 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-extension-output">client | |
40 | * extension outputs</a> from a <code>navigator.credentials.create()</code> operation. | |
41 | * | |
42 | * <p>Note that there is no guarantee that any extension input present in {@link | |
43 | * AssertionExtensionInputs} will have a corresponding output present here. | |
44 | * | |
45 | * <p>The authenticator extension outputs are contained in the {@link AuthenticatorData} structure. | |
46 | * | |
47 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-extensions">§9. WebAuthn | |
48 | * Extensions</a> | |
49 | */ | |
50 | @Value | |
51 | @Builder(toBuilder = true) | |
52 | @JsonIgnoreProperties(ignoreUnknown = true) | |
53 | public class ClientRegistrationExtensionOutputs implements ClientExtensionOutputs { | |
54 | ||
55 | private final Boolean appidExclude; | |
56 | ||
57 | private final Extensions.CredentialProperties.CredentialPropertiesOutput credProps; | |
58 | ||
59 | private final Extensions.LargeBlob.LargeBlobRegistrationOutput largeBlob; | |
60 | ||
61 | private final Extensions.Prf.PrfRegistrationOutput prf; | |
62 | ||
63 | @JsonCreator | |
64 | private ClientRegistrationExtensionOutputs( | |
65 | @JsonProperty("appidExclude") Boolean appidExclude, | |
66 | @JsonProperty("credProps") | |
67 | Extensions.CredentialProperties.CredentialPropertiesOutput credProps, | |
68 | @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobRegistrationOutput largeBlob, | |
69 | @JsonProperty("prf") Extensions.Prf.PrfRegistrationOutput prf) { | |
70 | this.appidExclude = appidExclude; | |
71 | this.credProps = credProps; | |
72 | this.largeBlob = largeBlob; | |
73 | this.prf = prf; | |
74 | } | |
75 | ||
76 | @Override | |
77 | @EqualsAndHashCode.Include | |
78 | public Set<String> getExtensionIds() { | |
79 | HashSet<String> ids = new HashSet<>(); | |
80 |
1
1. getExtensionIds : negated conditional → KILLED |
if (appidExclude != null) { |
81 | ids.add(Extensions.AppidExclude.EXTENSION_ID); | |
82 | } | |
83 |
1
1. getExtensionIds : negated conditional → KILLED |
if (credProps != null) { |
84 | ids.add(Extensions.CredentialProperties.EXTENSION_ID); | |
85 | } | |
86 |
1
1. getExtensionIds : negated conditional → KILLED |
if (largeBlob != null) { |
87 | ids.add(Extensions.LargeBlob.EXTENSION_ID); | |
88 | } | |
89 |
1
1. getExtensionIds : negated conditional → KILLED |
if (prf != null) { |
90 | ids.add(Extensions.Prf.EXTENSION_ID); | |
91 | } | |
92 |
1
1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getExtensionIds → KILLED |
return ids; |
93 | } | |
94 | ||
95 | /** | |
96 | * The extension output for the <a | |
97 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">FIDO | |
98 | * AppID Exclusion (<code>appidExclude</code>) Extension</a>, if any. | |
99 | * | |
100 | * <p>This value is generally not useful, as it only communicates whether the client supports the | |
101 | * extension. | |
102 | * | |
103 | * @see <a | |
104 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2.FIDO | |
105 | * AppID Exclusion Extension (appidExclude)</a> | |
106 | */ | |
107 | public Optional<Boolean> getAppidExclude() { | |
108 |
1
1. getAppidExclude : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getAppidExclude → KILLED |
return Optional.ofNullable(appidExclude); |
109 | } | |
110 | ||
111 | /** | |
112 | * The extension output for the Credential Properties Extension (<code>credProps</code>), if any. | |
113 | * | |
114 | * <p>This value MAY be present but have all members empty if the extension was successfully | |
115 | * processed but no credential properties could be determined. | |
116 | * | |
117 | * @see com.yubico.webauthn.data.Extensions.CredentialProperties.CredentialPropertiesOutput | |
118 | * @see <a | |
119 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4. | |
120 | * Credential Properties Extension (credProps)</a> | |
121 | */ | |
122 | public Optional<Extensions.CredentialProperties.CredentialPropertiesOutput> getCredProps() { | |
123 |
1
1. getCredProps : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getCredProps → KILLED |
return Optional.ofNullable(credProps); |
124 | } | |
125 | ||
126 | /** | |
127 | * The extension output for the Large blob storage extension (<code>largeBlob</code>), if any. | |
128 | * | |
129 | * @see com.yubico.webauthn.data.Extensions.LargeBlob.LargeBlobRegistrationOutput | |
130 | * @see <a | |
131 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.Large | |
132 | * blob storage extension (largeBlob)</a> | |
133 | */ | |
134 | public Optional<Extensions.LargeBlob.LargeBlobRegistrationOutput> getLargeBlob() { | |
135 |
1
1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getLargeBlob → KILLED |
return Optional.ofNullable(largeBlob); |
136 | } | |
137 | ||
138 | /** | |
139 | * The extension output for the <a | |
140 | * href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">Pseudo-random function | |
141 | * (<code>prf</code>) extension</a>, if any. | |
142 | * | |
143 | * @since 2.7.0 | |
144 | * @see com.yubico.webauthn.data.Extensions.Prf.PrfRegistrationOutput | |
145 | * @see <a href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">§10.1.4. | |
146 | * Pseudo-random function extension (prf)</a> | |
147 | */ | |
148 | public Optional<Extensions.Prf.PrfRegistrationOutput> getPrf() { | |
149 |
1
1. getPrf : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getPrf → KILLED |
return Optional.ofNullable(prf); |
150 | } | |
151 | } | |
Mutations | ||
80 |
1.1 |
|
83 |
1.1 |
|
86 |
1.1 |
|
89 |
1.1 |
|
92 |
1.1 |
|
108 |
1.1 |
|
123 |
1.1 |
|
135 |
1.1 |
|
149 |
1.1 |