AuthenticatorAttachment.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.JsonValue;
29
import java.util.Optional;
30
import java.util.stream.Stream;
31
import lombok.AllArgsConstructor;
32
import lombok.Getter;
33
import lombok.NonNull;
34
35
/**
36
 * This enumeration’s values describe authenticators' <a
37
 * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#authenticator-attachment-modality">attachment
38
 * modalities</a>. Relying Parties use this for two purposes:
39
 *
40
 * <ul>
41
 *   <li>to express a preferred authenticator attachment modality when calling <code>
42
 *       navigator.credentials.create()</code> to create a credential, and
43
 *   <li>to inform the client of the Relying Party's best belief about how to locate the managing
44
 *       authenticators of the credentials listed in {@link
45
 *       PublicKeyCredentialRequestOptions#getAllowCredentials()} when calling <code>
46
 *       navigator.credentials.get()</code>.
47
 * </ul>
48
 *
49
 * @see <a
50
 *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-authenticatorattachment">§5.4.5.
51
 *     Authenticator Attachment Enumeration (enum AuthenticatorAttachment) </a>
52
 */
53
@AllArgsConstructor
54
public enum AuthenticatorAttachment {
55
56
  /**
57
   * Indicates <a
58
   * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#cross-platform-attachment">cross-platform
59
   * attachment</a>.
60
   *
61
   * <p>Authenticators of this class are removable from, and can "roam" among, client platforms.
62
   */
63
  CROSS_PLATFORM("cross-platform"),
64
65
  /**
66
   * Indicates <a
67
   * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#platform-attachment">platform
68
   * attachment</a>.
69
   *
70
   * <p>Usually, authenticators of this class are not removable from the platform.
71
   */
72
  PLATFORM("platform");
73
74
  @JsonValue @Getter @NonNull private final String value;
75
76
  /**
77
   * Attempt to parse a string as an {@link AuthenticatorAttachment}.
78
   *
79
   * @param value a {@link String} equal to the {@link #getValue() value} of a constant in {@link
80
   *     AuthenticatorAttachment}
81
   * @return The {@link AuthenticatorAttachment} instance whose {@link #getValue() value} equals
82
   *     <code>value</code>, if any.
83
   * @see <a
84
   *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-authenticatorattachment">§5.4.5.
85
   *     Authenticator Attachment Enumeration (enum AuthenticatorAttachment) </a>
86
   */
87 1 1. fromValue : negated conditional → KILLED
  public static Optional<AuthenticatorAttachment> fromValue(@NonNull String value) {
88 3 1. fromValue : replaced return value with Optional.empty for com/yubico/webauthn/data/AuthenticatorAttachment::fromValue → KILLED
2. lambda$fromValue$0 : replaced boolean return with true for com/yubico/webauthn/data/AuthenticatorAttachment::lambda$fromValue$0 → KILLED
3. lambda$fromValue$0 : replaced boolean return with false for com/yubico/webauthn/data/AuthenticatorAttachment::lambda$fromValue$0 → KILLED
    return Stream.of(values()).filter(v -> v.value.equals(value)).findAny();
89
  }
90
91
  @JsonCreator
92 1 1. fromJsonString : negated conditional → KILLED
  private static AuthenticatorAttachment fromJsonString(@NonNull String value) {
93 1 1. fromJsonString : replaced return value with null for com/yubico/webauthn/data/AuthenticatorAttachment::fromJsonString → KILLED
    return fromValue(value).orElse(null);
94
  }
95
}

Mutations

87

1.1
Location : fromValue
Killed by : com.yubico.webauthn.data.EnumsSpec
negated conditional → KILLED

88

1.1
Location : fromValue
Killed by : com.yubico.webauthn.data.JsonIoSpec
replaced return value with Optional.empty for com/yubico/webauthn/data/AuthenticatorAttachment::fromValue → KILLED

2.2
Location : lambda$fromValue$0
Killed by : com.yubico.webauthn.data.EnumsSpec
replaced boolean return with true for com/yubico/webauthn/data/AuthenticatorAttachment::lambda$fromValue$0 → KILLED

3.3
Location : lambda$fromValue$0
Killed by : com.yubico.webauthn.data.JsonIoSpec
replaced boolean return with false for com/yubico/webauthn/data/AuthenticatorAttachment::lambda$fromValue$0 → KILLED

92

1.1
Location : fromJsonString
Killed by : com.yubico.webauthn.data.EnumsSpec
negated conditional → KILLED

93

1.1
Location : fromJsonString
Killed by : com.yubico.webauthn.data.JsonIoSpec
replaced return value with null for com/yubico/webauthn/data/AuthenticatorAttachment::fromJsonString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0