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.NonNull; | |
36 | import lombok.Value; | |
37 | ||
38 | /** | |
39 | * Contains <a | |
40 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#client-extension-output">client | |
41 | * extension outputs</a> from a <code>navigator.credentials.get()</code> operation. | |
42 | * | |
43 | * <p>Note that there is no guarantee that any extension input present in {@link | |
44 | * AssertionExtensionInputs} will have a corresponding output present here. | |
45 | * | |
46 | * <p>The authenticator extension outputs are contained in the {@link AuthenticatorData} structure. | |
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 class ClientAssertionExtensionOutputs implements ClientExtensionOutputs { | |
55 | ||
56 | /** | |
57 | * The extension output for the FIDO AppID Extension (<code>appid</code>), if any. | |
58 | * | |
59 | * <p>This value should be ignored because its behaviour is underspecified, see: <a | |
60 | * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>. | |
61 | * | |
62 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
63 | * FIDO AppID Extension (appid)</a> | |
64 | */ | |
65 | private final Boolean appid; | |
66 | ||
67 | private final Extensions.LargeBlob.LargeBlobAuthenticationOutput largeBlob; | |
68 | ||
69 | @JsonCreator | |
70 | private ClientAssertionExtensionOutputs( | |
71 | @JsonProperty("appid") Boolean appid, | |
72 | @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobAuthenticationOutput largeBlob) { | |
73 | this.appid = appid; | |
74 | this.largeBlob = largeBlob; | |
75 | } | |
76 | ||
77 | @Override | |
78 | @EqualsAndHashCode.Include | |
79 | public Set<String> getExtensionIds() { | |
80 | HashSet<String> ids = new HashSet<>(); | |
81 |
1
1. getExtensionIds : negated conditional → KILLED |
if (appid != null) { |
82 | ids.add(Extensions.Appid.EXTENSION_ID); | |
83 | } | |
84 |
1
1. getExtensionIds : negated conditional → KILLED |
if (largeBlob != null) { |
85 | ids.add(Extensions.LargeBlob.EXTENSION_ID); | |
86 | } | |
87 |
1
1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getExtensionIds → KILLED |
return ids; |
88 | } | |
89 | ||
90 | /** | |
91 | * The extension output for the FIDO AppID Extension (<code>appid</code>), if any. | |
92 | * | |
93 | * <p>This value should be ignored because its behaviour is underspecified, see: <a | |
94 | * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>. | |
95 | * | |
96 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
97 | * FIDO AppID Extension (appid)</a> | |
98 | */ | |
99 | public Optional<Boolean> getAppid() { | |
100 |
1
1. getAppid : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getAppid → SURVIVED |
return Optional.ofNullable(appid); |
101 | } | |
102 | ||
103 | /** | |
104 | * The extension output for the <a | |
105 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">Large blob | |
106 | * storage (<code>largeBlob</code>) extension</a>, if any. | |
107 | * | |
108 | * @see com.yubico.webauthn.data.Extensions.LargeBlob.LargeBlobRegistrationOutput | |
109 | * @see <a | |
110 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.Large | |
111 | * blob storage extension (largeBlob)</a> | |
112 | */ | |
113 | public Optional<Extensions.LargeBlob.LargeBlobAuthenticationOutput> getLargeBlob() { | |
114 |
1
1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getLargeBlob → KILLED |
return Optional.ofNullable(largeBlob); |
115 | } | |
116 | ||
117 | public static class ClientAssertionExtensionOutputsBuilder { | |
118 | ||
119 | /** | |
120 | * The extension output for the FIDO AppID Extension (<code>appid</code>). | |
121 | * | |
122 | * <p>This value should be ignored because its behaviour is underspecified, see: <a | |
123 | * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>. | |
124 | * | |
125 | * @see <a | |
126 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
127 | * FIDO AppID Extension (appid)</a> | |
128 | */ | |
129 |
1
1. appid : negated conditional → KILLED |
public ClientAssertionExtensionOutputsBuilder appid(@NonNull Optional<Boolean> appid) { |
130 | this.appid = appid.orElse(null); | |
131 |
1
1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED |
return this; |
132 | } | |
133 | ||
134 | /* | |
135 | * Workaround, see: https://github.com/rzwitserloot/lombok/issues/2623#issuecomment-714816001 | |
136 | * Consider reverting this workaround if Lombok fixes that issue. | |
137 | */ | |
138 | private ClientAssertionExtensionOutputsBuilder appid(Boolean appid) { | |
139 |
1
1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED |
return this.appid(Optional.ofNullable(appid)); |
140 | } | |
141 | ||
142 | /** | |
143 | * The extension output for the FIDO AppID Extension (<code>appid</code>). | |
144 | * | |
145 | * <p>This value should be ignored because its behaviour is underspecified, see: <a | |
146 | * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>. | |
147 | * | |
148 | * @see <a | |
149 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1. | |
150 | * FIDO AppID Extension (appid)</a> | |
151 | */ | |
152 | public ClientAssertionExtensionOutputsBuilder appid(boolean appid) { | |
153 |
1
1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED |
return this.appid(Optional.of(appid)); |
154 | } | |
155 | } | |
156 | } | |
Mutations | ||
81 |
1.1 |
|
84 |
1.1 |
|
87 |
1.1 |
|
100 |
1.1 |
|
114 |
1.1 |
|
129 |
1.1 |
|
131 |
1.1 |
|
139 |
1.1 |
|
153 |
1.1 |