| 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 USER_VERIFY constants are flags in a bitfield represented as a 32 bit long integer. They | |
| 10 | * describe the methods and capabilities of a FIDO authenticator for locally verifying a user. The | |
| 11 | * operational details of these methods are opaque to the server. These constants are used in the | |
| 12 | * authoritative metadata for FIDO authenticators, reported and queried through the UAF Discovery | |
| 13 | * APIs, and used to form authenticator policies in UAF protocol messages. Each constant has a | |
| 14 | * case-sensitive string representation (in quotes), which is used in the authoritative metadata for | |
| 15 | * FIDO authenticators. | |
| 16 | * | |
| 17 | * @see #fromValue(int) | |
| 18 | * @see #fromName(String) | |
| 19 | * @see <a | |
| 20 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 21 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 22 | */ | |
| 23 | @Getter | |
| 24 | public enum UserVerificationMethod { | |
| 25 | ||
| 26 | /** | |
| 27 | * This flag MUST be set if the authenticator is able to confirm user presence in any fashion. If | |
| 28 | * this flag and no other is set for user verification, the guarantee is only that the | |
| 29 | * authenticator cannot be operated without some human intervention, not necessarily that the | |
| 30 | * sensing of "presence" provides any level of user verification (e.g. a device that requires a | |
| 31 | * button press to activate). | |
| 32 | * | |
| 33 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 34 | * | |
| 35 | * @see <a | |
| 36 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 37 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 38 | */ | |
| 39 | USER_VERIFY_PRESENCE_INTERNAL(0x00000001, "presence_internal"), | |
| 40 | ||
| 41 | /** | |
| 42 | * This flag MUST be set if the authenticator uses any type of measurement of a fingerprint for | |
| 43 | * user verification. | |
| 44 | * | |
| 45 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 46 | * | |
| 47 | * @see <a | |
| 48 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 49 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 50 | */ | |
| 51 | USER_VERIFY_FINGERPRINT_INTERNAL(0x00000002, "fingerprint_internal"), | |
| 52 | ||
| 53 | /** | |
| 54 | * This flag MUST be set if the authenticator uses a local-only passcode (i.e. a passcode not | |
| 55 | * known by the server) for user verification. | |
| 56 | * | |
| 57 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 58 | * | |
| 59 | * @see <a | |
| 60 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 61 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 62 | */ | |
| 63 | USER_VERIFY_PASSCODE_INTERNAL(0x00000004, "passcode_internal"), | |
| 64 | ||
| 65 | /** | |
| 66 | * This flag MUST be set if the authenticator uses a voiceprint (also known as speaker | |
| 67 | * recognition) for user verification. | |
| 68 | * | |
| 69 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 70 | * | |
| 71 | * @see <a | |
| 72 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 73 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 74 | */ | |
| 75 | USER_VERIFY_VOICEPRINT_INTERNAL(0x00000008, "voiceprint_internal"), | |
| 76 | ||
| 77 | /** | |
| 78 | * This flag MUST be set if the authenticator uses any manner of face recognition to verify the | |
| 79 | * user. | |
| 80 | * | |
| 81 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 82 | * | |
| 83 | * @see <a | |
| 84 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 85 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 86 | */ | |
| 87 | USER_VERIFY_FACEPRINT_INTERNAL(0x00000010, "faceprint_internal"), | |
| 88 | ||
| 89 | /** | |
| 90 | * This flag MUST be set if the authenticator uses any form of location sensor or measurement for | |
| 91 | * user verification. | |
| 92 | * | |
| 93 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 94 | * | |
| 95 | * @see <a | |
| 96 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 97 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 98 | */ | |
| 99 | USER_VERIFY_LOCATION_INTERNAL(0x00000020, "location_internal"), | |
| 100 | ||
| 101 | /** | |
| 102 | * This flag MUST be set if the authenticator uses any form of eye biometrics for user | |
| 103 | * verification. | |
| 104 | * | |
| 105 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 106 | * | |
| 107 | * @see <a | |
| 108 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 109 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 110 | */ | |
| 111 | USER_VERIFY_EYEPRINT_INTERNAL(0x00000040, "eyeprint_internal"), | |
| 112 | ||
| 113 | /** | |
| 114 | * This flag MUST be set if the authenticator uses a drawn pattern for user verification. | |
| 115 | * | |
| 116 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 117 | * | |
| 118 | * @see <a | |
| 119 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 120 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 121 | */ | |
| 122 | USER_VERIFY_PATTERN_INTERNAL(0x00000080, "pattern_internal"), | |
| 123 | ||
| 124 | /** | |
| 125 | * This flag MUST be set if the authenticator uses any measurement of a full hand (including | |
| 126 | * palm-print, hand geometry or vein geometry) for user verification. | |
| 127 | * | |
| 128 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 129 | * | |
| 130 | * @see <a | |
| 131 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 132 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 133 | */ | |
| 134 | USER_VERIFY_HANDPRINT_INTERNAL(0x00000100, "handprint_internal"), | |
| 135 | ||
| 136 | /** | |
| 137 | * This flag MUST be set if the authenticator uses a local-only passcode (i.e. a passcode not | |
| 138 | * known by the server) for user verification that might be gathered outside the authenticator | |
| 139 | * boundary. | |
| 140 | * | |
| 141 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 142 | * | |
| 143 | * @see <a | |
| 144 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 145 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 146 | */ | |
| 147 | USER_VERIFY_PASSCODE_EXTERNAL(0x00000800, "passcode_external"), | |
| 148 | ||
| 149 | /** | |
| 150 | * This flag MUST be set if the authenticator uses a drawn pattern for user verification that | |
| 151 | * might be gathered outside the authenticator boundary. | |
| 152 | * | |
| 153 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 154 | * | |
| 155 | * @see <a | |
| 156 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 157 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 158 | */ | |
| 159 | USER_VERIFY_PATTERN_EXTERNAL(0x00001000, "pattern_external"), | |
| 160 | ||
| 161 | /** | |
| 162 | * This flag MUST be set if the authenticator will respond without any user interaction (e.g. | |
| 163 | * Silent Authenticator). | |
| 164 | * | |
| 165 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 166 | * | |
| 167 | * @see <a | |
| 168 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 169 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 170 | */ | |
| 171 | USER_VERIFY_NONE(0x00000200, "none"), | |
| 172 | ||
| 173 | /** | |
| 174 | * If an authenticator sets multiple flags for the "_INTERNAL" and/or "_EXTERNAL" user | |
| 175 | * verification types, it MAY also set this flag to indicate that all verification methods with | |
| 176 | * respective flags set will be enforced (e.g. faceprint AND voiceprint). If flags for multiple | |
| 177 | * user verification methods are set and this flag is not set, verification with only one is | |
| 178 | * necessary (e.g. fingerprint OR passcode). | |
| 179 | * | |
| 180 | * <p>NOTE: The above requirements apply to authenticators; this library DOES NOT enforce them. | |
| 181 | * | |
| 182 | * @see <a | |
| 183 | * href="https://fidoalliance.org/specs/common-specs/fido-registry-v2.1-ps-20191217.html#user-verification-methods">FIDO | |
| 184 | * Registry of Predefined Values §3.1 User Verification Methods</a> | |
| 185 | */ | |
| 186 | USER_VERIFY_ALL(0x00000400, "all"); | |
| 187 | ||
| 188 | private final int value; | |
| 189 | ||
| 190 | @JsonValue private final String name; | |
| 191 | ||
| 192 | UserVerificationMethod(int value, String name) { | |
| 193 | this.value = value; | |
| 194 | this.name = name; | |
| 195 | } | |
| 196 | ||
| 197 | /** | |
| 198 | * @return If <code>value</code> matches any {@link UserVerificationMethod} constant, returns that | |
| 199 | * constant instance. Otherwise throws {@link IllegalArgumentException}. | |
| 200 | */ | |
| 201 | public static UserVerificationMethod fromValue(int value) { | |
| 202 |
1
1. fromValue : replaced return value with null for com/yubico/webauthn/extension/uvm/UserVerificationMethod::fromValue → KILLED |
return Stream.of(values()) |
| 203 |
2
1. lambda$fromValue$0 : negated conditional → KILLED 2. lambda$fromValue$0 : replaced boolean return with true for com/yubico/webauthn/extension/uvm/UserVerificationMethod::lambda$fromValue$0 → KILLED |
.filter(v -> v.value == value) |
| 204 | .findAny() | |
| 205 | .orElseThrow( | |
| 206 | () -> | |
| 207 |
1
1. lambda$fromValue$1 : replaced return value with null for com/yubico/webauthn/extension/uvm/UserVerificationMethod::lambda$fromValue$1 → KILLED |
new IllegalArgumentException( |
| 208 | String.format( | |
| 209 | "Unknown %s value: 0x%04x", UserVerificationMethod.class, value))); | |
| 210 | } | |
| 211 | ||
| 212 | /** | |
| 213 | * @return If <code>name</code> matches any {@link UserVerificationMethod} constant, returns that | |
| 214 | * constant instance. Otherwise throws {@link IllegalArgumentException}. | |
| 215 | */ | |
| 216 | @JsonCreator | |
| 217 | public static UserVerificationMethod fromName(String name) { | |
| 218 |
1
1. fromName : replaced return value with null for com/yubico/webauthn/extension/uvm/UserVerificationMethod::fromName → NO_COVERAGE |
return Stream.of(values()) |
| 219 |
2
1. lambda$fromName$2 : replaced boolean return with true for com/yubico/webauthn/extension/uvm/UserVerificationMethod::lambda$fromName$2 → NO_COVERAGE 2. lambda$fromName$2 : replaced boolean return with false for com/yubico/webauthn/extension/uvm/UserVerificationMethod::lambda$fromName$2 → NO_COVERAGE |
.filter(v -> v.name.equals(name)) |
| 220 | .findAny() | |
| 221 | .orElseThrow( | |
| 222 | () -> | |
| 223 |
1
1. lambda$fromName$3 : replaced return value with null for com/yubico/webauthn/extension/uvm/UserVerificationMethod::lambda$fromName$3 → NO_COVERAGE |
new IllegalArgumentException( |
| 224 | String.format("Unknown %s name: %s", UserVerificationMethod.class, name))); | |
| 225 | } | |
| 226 | } | |
Mutations | ||
| 202 |
1.1 |
|
| 203 |
1.1 2.2 |
|
| 207 |
1.1 |
|
| 218 |
1.1 |
|
| 219 |
1.1 2.2 |
|
| 223 |
1.1 |