ClientAssertionExtensionOutputs.java

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.CredentialProperties.CredentialPropertiesOutput credProps;
68
69
  private final Extensions.LargeBlob.LargeBlobAuthenticationOutput largeBlob;
70
71
  @JsonCreator
72
  private ClientAssertionExtensionOutputs(
73
      @JsonProperty("appid") Boolean appid,
74
      @JsonProperty("credProps")
75
          Extensions.CredentialProperties.CredentialPropertiesOutput credProps,
76
      @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobAuthenticationOutput largeBlob) {
77
    this.appid = appid;
78
    this.credProps = credProps;
79
    this.largeBlob = largeBlob;
80
  }
81
82
  @Override
83
  @EqualsAndHashCode.Include
84
  public Set<String> getExtensionIds() {
85
    HashSet<String> ids = new HashSet<>();
86 1 1. getExtensionIds : negated conditional → KILLED
    if (appid != null) {
87
      ids.add(Extensions.Appid.EXTENSION_ID);
88
    }
89 1 1. getExtensionIds : negated conditional → KILLED
    if (credProps != null) {
90
      ids.add(Extensions.CredentialProperties.EXTENSION_ID);
91
    }
92 1 1. getExtensionIds : negated conditional → KILLED
    if (largeBlob != null) {
93
      ids.add(Extensions.LargeBlob.EXTENSION_ID);
94
    }
95 1 1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getExtensionIds → KILLED
    return ids;
96
  }
97
98
  /**
99
   * The extension output for the FIDO AppID Extension (<code>appid</code>), if any.
100
   *
101
   * <p>This value should be ignored because its behaviour is underspecified, see: <a
102
   * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>.
103
   *
104
   * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1.
105
   *     FIDO AppID Extension (appid)</a>
106
   */
107
  public Optional<Boolean> getAppid() {
108 1 1. getAppid : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getAppid → SURVIVED
    return Optional.ofNullable(appid);
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
   * @deprecated EXPERIMENTAL: This feature is from a not yet mature standard; it could change as
122
   *     the standard matures.
123
   */
124
  @Deprecated
125
  public Optional<Extensions.CredentialProperties.CredentialPropertiesOutput> getCredProps() {
126 1 1. getCredProps : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getCredProps → KILLED
    return Optional.ofNullable(credProps);
127
  }
128
129
  /**
130
   * The extension output for the <a
131
   * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">Large blob
132
   * storage (<code>largeBlob</code>) extension</a>, if any.
133
   *
134
   * @see com.yubico.webauthn.data.Extensions.LargeBlob.LargeBlobRegistrationOutput
135
   * @see <a
136
   *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.Large
137
   *     blob storage extension (largeBlob)</a>
138
   */
139
  public Optional<Extensions.LargeBlob.LargeBlobAuthenticationOutput> getLargeBlob() {
140 1 1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getLargeBlob → KILLED
    return Optional.ofNullable(largeBlob);
141
  }
142
143
  public static class ClientAssertionExtensionOutputsBuilder {
144
145
    /**
146
     * The extension output for the FIDO AppID Extension (<code>appid</code>).
147
     *
148
     * <p>This value should be ignored because its behaviour is underspecified, see: <a
149
     * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>.
150
     *
151
     * @see <a
152
     *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1.
153
     *     FIDO AppID Extension (appid)</a>
154
     */
155 1 1. appid : negated conditional → KILLED
    public ClientAssertionExtensionOutputsBuilder appid(@NonNull Optional<Boolean> appid) {
156
      this.appid = appid.orElse(null);
157 1 1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED
      return this;
158
    }
159
160
    /*
161
     * Workaround, see: https://github.com/rzwitserloot/lombok/issues/2623#issuecomment-714816001
162
     * Consider reverting this workaround if Lombok fixes that issue.
163
     */
164
    private ClientAssertionExtensionOutputsBuilder appid(Boolean appid) {
165 1 1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED
      return this.appid(Optional.ofNullable(appid));
166
    }
167
168
    /**
169
     * The extension output for the FIDO AppID Extension (<code>appid</code>).
170
     *
171
     * <p>This value should be ignored because its behaviour is underspecified, see: <a
172
     * href="https://github.com/w3c/webauthn/issues/1034">https://github.com/w3c/webauthn/issues/1034</a>.
173
     *
174
     * @see <a
175
     *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-extension">§10.1.
176
     *     FIDO AppID Extension (appid)</a>
177
     */
178
    public ClientAssertionExtensionOutputsBuilder appid(boolean appid) {
179 1 1. appid : replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED
      return this.appid(Optional.of(appid));
180
    }
181
  }
182
}

Mutations

86

1.1
Location : getExtensionIds
Killed by : com.yubico.webauthn.data.ExtensionsSpec
negated conditional → KILLED

89

1.1
Location : getExtensionIds
Killed by : com.yubico.webauthn.data.ExtensionsSpec
negated conditional → KILLED

92

1.1
Location : getExtensionIds
Killed by : com.yubico.webauthn.data.ExtensionsSpec
negated conditional → KILLED

95

1.1
Location : getExtensionIds
Killed by : com.yubico.webauthn.data.ExtensionsSpec
replaced return value with Collections.emptySet for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getExtensionIds → KILLED

108

1.1
Location : getAppid
Killed by : none
replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getAppid → SURVIVED

126

1.1
Location : getCredProps
Killed by : com.yubico.webauthn.RelyingPartyV2AssertionSpec
replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getCredProps → KILLED

140

1.1
Location : getLargeBlob
Killed by : com.yubico.webauthn.data.ExtensionsSpec
replaced return value with Optional.empty for com/yubico/webauthn/data/ClientAssertionExtensionOutputs::getLargeBlob → KILLED

155

1.1
Location : appid
Killed by : com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest)
negated conditional → KILLED

157

1.1
Location : appid
Killed by : com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest)
replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED

165

1.1
Location : appid
Killed by : com.yubico.webauthn.data.BuildersSpec
replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED

179

1.1
Location : appid
Killed by : com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.ClientAssertionExtensionOutputsTest)
replaced return value with null for com/yubico/webauthn/data/ClientAssertionExtensionOutputs$ClientAssertionExtensionOutputsBuilder::appid → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0