ClientRegistrationExtensionOutputs.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.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
  @JsonCreator
62
  private ClientRegistrationExtensionOutputs(
63
      @JsonProperty("appidExclude") Boolean appidExclude,
64
      @JsonProperty("credProps")
65
          Extensions.CredentialProperties.CredentialPropertiesOutput credProps,
66
      @JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobRegistrationOutput largeBlob) {
67
    this.appidExclude = appidExclude;
68
    this.credProps = credProps;
69
    this.largeBlob = largeBlob;
70
  }
71
72
  @Override
73
  @EqualsAndHashCode.Include
74
  public Set<String> getExtensionIds() {
75
    HashSet<String> ids = new HashSet<>();
76 1 1. getExtensionIds : negated conditional → KILLED
    if (appidExclude != null) {
77
      ids.add(Extensions.AppidExclude.EXTENSION_ID);
78
    }
79 1 1. getExtensionIds : negated conditional → KILLED
    if (credProps != null) {
80
      ids.add(Extensions.CredentialProperties.EXTENSION_ID);
81
    }
82 1 1. getExtensionIds : negated conditional → KILLED
    if (largeBlob != null) {
83
      ids.add(Extensions.LargeBlob.EXTENSION_ID);
84
    }
85 1 1. getExtensionIds : replaced return value with Collections.emptySet for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getExtensionIds → KILLED
    return ids;
86
  }
87
88
  /**
89
   * The extension output for the <a
90
   * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">FIDO
91
   * AppID Exclusion (<code>appidExclude</code>) Extension</a>, if any.
92
   *
93
   * <p>This value is generally not useful, as it only communicates whether the client supports the
94
   * extension.
95
   *
96
   * @see <a
97
   *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-appid-exclude-extension">§10.2.FIDO
98
   *     AppID Exclusion Extension (appidExclude)</a>
99
   */
100
  public Optional<Boolean> getAppidExclude() {
101 1 1. getAppidExclude : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getAppidExclude → KILLED
    return Optional.ofNullable(appidExclude);
102
  }
103
104
  /**
105
   * The extension output for the Credential Properties Extension (<code>credProps</code>), if any.
106
   *
107
   * <p>This value MAY be present but have all members empty if the extension was successfully
108
   * processed but no credential properties could be determined.
109
   *
110
   * @see com.yubico.webauthn.data.Extensions.CredentialProperties.CredentialPropertiesOutput
111
   * @see <a
112
   *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-credential-properties-extension">§10.4.
113
   *     Credential Properties Extension (credProps)</a>
114
   */
115
  public Optional<Extensions.CredentialProperties.CredentialPropertiesOutput> getCredProps() {
116 1 1. getCredProps : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getCredProps → KILLED
    return Optional.ofNullable(credProps);
117
  }
118
119
  /**
120
   * The extension output for the Large blob storage extension (<code>largeBlob</code>), if any.
121
   *
122
   * @see com.yubico.webauthn.data.Extensions.LargeBlob.LargeBlobRegistrationOutput
123
   * @see <a
124
   *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-large-blob-extension">§10.5.Large
125
   *     blob storage extension (largeBlob)</a>
126
   */
127
  public Optional<Extensions.LargeBlob.LargeBlobRegistrationOutput> getLargeBlob() {
128 1 1. getLargeBlob : replaced return value with Optional.empty for com/yubico/webauthn/data/ClientRegistrationExtensionOutputs::getLargeBlob → KILLED
    return Optional.ofNullable(largeBlob);
129
  }
130
}

Mutations

76

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

79

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

82

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

85

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

101

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

116

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

128

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

Active mutators

Tests examined


Report generated by PIT 1.15.0