MatcherProtectionType.java

1
package com.yubico.webauthn.extension.uvm;
2
3
import com.fasterxml.jackson.annotation.JsonCreator;
4
import com.fasterxml.jackson.annotation.JsonValue;
5
import java.util.stream.Stream;
6
import lombok.Getter;
7
8
/**
9
 * The MATCHER_PROTECTION constants are flags in a bit field represented as a 16 bit long integer.
10
 * They describe the method an authenticator uses to protect the matcher that performs user
11
 * verification. These constants are reported and queried through the UAF Discovery APIs and used to
12
 * form authenticator policies in UAF protocol messages. Refer to [UAFAuthnrCommands] for more
13
 * details on the matcher component. Each constant has a case-sensitive string representation (in
14
 * quotes), which is used in the authoritative metadata for FIDO authenticators.
15
 *
16
 * @see #fromValue(int)
17
 * @see #fromName(String)
18
 * @see <a
19
 *     href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#matcher-protection-types">FIDO
20
 *     Registry of Predefined Values §3.3 Matcher Protection Types</a>
21
 */
22
@Getter
23
public enum MatcherProtectionType {
24
25
  /**
26
   * This flag MUST be set if the authenticator's matcher is running in software. Exclusive in
27
   * authenticator metadata with {@link #MATCHER_PROTECTION_TEE}, {@link
28
   * #MATCHER_PROTECTION_ON_CHIP}.
29
   *
30
   * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them.
31
   *
32
   * @see <a
33
   *     href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#matcher-protection-types">FIDO
34
   *     Registry of Predefined Values §3.3 Matcher Protection Types</a>
35
   */
36
  MATCHER_PROTECTION_SOFTWARE((short) 0x0001, "software"),
37
38
  /**
39
   * This flag SHOULD be set if the authenticator's matcher is running inside the Trusted Execution
40
   * Environment [TEE]. Mutually exclusive in authenticator metadata with {@link
41
   * #MATCHER_PROTECTION_SOFTWARE}, {@link #MATCHER_PROTECTION_ON_CHIP}.
42
   *
43
   * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them.
44
   *
45
   * @see <a
46
   *     href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#matcher-protection-types">FIDO
47
   *     Registry of Predefined Values §3.3 Matcher Protection Types</a>
48
   */
49
  MATCHER_PROTECTION_TEE((short) 0x0002, "tee"),
50
51
  /**
52
   * This flag SHOULD be set if the authenticator's matcher is running on the chip. Mutually
53
   * exclusive in authenticator metadata with {@link #MATCHER_PROTECTION_TEE}, {@link
54
   * #MATCHER_PROTECTION_SOFTWARE}
55
   *
56
   * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them.
57
   *
58
   * @see <a
59
   *     href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#matcher-protection-types">FIDO
60
   *     Registry of Predefined Values §3.3 Matcher Protection Types</a>
61
   */
62
  MATCHER_PROTECTION_ON_CHIP((short) 0x0004, "on_chip");
63
64
  private final short value;
65
66
  @JsonValue private final String name;
67
68
  MatcherProtectionType(short value, String name) {
69
    this.value = value;
70
    this.name = name;
71
  }
72
73
  /**
74
   * @return If <code>value</code> matches any {@link MatcherProtectionType} constant, returns that
75
   *     constant instance. Otherwise throws {@link IllegalArgumentException}.
76
   */
77
  public static MatcherProtectionType fromValue(int value) {
78 1 1. fromValue : replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::fromValue → KILLED
    return Stream.of(values())
79 2 1. lambda$fromValue$0 : negated conditional → KILLED
2. lambda$fromValue$0 : replaced boolean return with true for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromValue$0 → KILLED
        .filter(v -> v.value == value)
80
        .findAny()
81
        .orElseThrow(
82
            () ->
83 1 1. lambda$fromValue$1 : replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromValue$1 → KILLED
                new IllegalArgumentException(
84
                    String.format("Unknown %s value: 0x%04x", MatcherProtectionType.class, value)));
85
  }
86
87
  /**
88
   * @return If <code>name</code> matches any {@link MatcherProtectionType} constant, returns that
89
   *     constant instance. Otherwise throws {@link IllegalArgumentException}.
90
   */
91
  @JsonCreator
92
  public static MatcherProtectionType fromName(String name) {
93 1 1. fromName : replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::fromName → NO_COVERAGE
    return Stream.of(values())
94 2 1. lambda$fromName$2 : replaced boolean return with true for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$2 → NO_COVERAGE
2. lambda$fromName$2 : replaced boolean return with false for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$2 → NO_COVERAGE
        .filter(v -> v.name.equals(name))
95
        .findAny()
96
        .orElseThrow(
97
            () ->
98 1 1. lambda$fromName$3 : replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$3 → NO_COVERAGE
                new IllegalArgumentException(
99
                    String.format("Unknown %s name: %s", MatcherProtectionType.class, name)));
100
  }
101
}

Mutations

78

1.1
Location : fromValue
Killed by : com.yubico.webauthn.data.EnumsSpec
replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::fromValue → KILLED

79

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

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

83

1.1
Location : lambda$fromValue$1
Killed by : com.yubico.webauthn.data.EnumsSpec
replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromValue$1 → KILLED

93

1.1
Location : fromName
Killed by : none
replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::fromName → NO_COVERAGE

94

1.1
Location : lambda$fromName$2
Killed by : none
replaced boolean return with true for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$2 → NO_COVERAGE

2.2
Location : lambda$fromName$2
Killed by : none
replaced boolean return with false for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$2 → NO_COVERAGE

98

1.1
Location : lambda$fromName$3
Killed by : none
replaced return value with null for com/yubico/webauthn/extension/uvm/MatcherProtectionType::lambda$fromName$3 → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.15.0