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 | * A WebAuthn Relying Party may require <a | |
37 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#user-verification">user | |
38 | * verification</a> for some of its operations but not for others, and may use this type to express | |
39 | * its needs. | |
40 | * | |
41 | * @see <a | |
42 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-userverificationrequirement">§5.10.6. | |
43 | * User Verification Requirement Enumeration (enum UserVerificationRequirement)</a> | |
44 | */ | |
45 | @AllArgsConstructor | |
46 | public enum UserVerificationRequirement { | |
47 | ||
48 | /** | |
49 | * This value indicates that the Relying Party does not want user verification employed during the | |
50 | * operation (e.g., in the interest of minimizing disruption to the user interaction flow). | |
51 | */ | |
52 | DISCOURAGED("discouraged"), | |
53 | ||
54 | /** | |
55 | * This value indicates that the Relying Party prefers user verification for the operation if | |
56 | * possible, but will not fail the operation if the response does not have the {@link | |
57 | * AuthenticatorDataFlags#UV} flag set. | |
58 | */ | |
59 | PREFERRED("preferred"), | |
60 | ||
61 | /** | |
62 | * Indicates that the Relying Party requires user verification for the operation and will fail the | |
63 | * operation if the response does not have the {@link AuthenticatorDataFlags#UV} flag set. | |
64 | */ | |
65 | REQUIRED("required"); | |
66 | ||
67 | @JsonValue @Getter @NonNull private final String value; | |
68 | ||
69 | /** | |
70 | * Attempt to parse a string as a {@link UserVerificationRequirement}. | |
71 | * | |
72 | * @param value a {@link String} equal to the {@link #getValue() value} of a constant in {@link | |
73 | * UserVerificationRequirement} | |
74 | * @return The {@link UserVerificationRequirement} instance whose {@link #getValue() value} equals | |
75 | * <code>value</code>, if any. | |
76 | * @see <a | |
77 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-userverificationrequirement">§5.10.6. | |
78 | * User Verification Requirement Enumeration (enum UserVerificationRequirement)</a> | |
79 | */ | |
80 |
1
1. fromValue : negated conditional → KILLED |
public static Optional<UserVerificationRequirement> fromValue(@NonNull String value) { |
81 |
3
1. lambda$fromValue$0 : replaced boolean return with false for com/yubico/webauthn/data/UserVerificationRequirement::lambda$fromValue$0 → KILLED 2. lambda$fromValue$0 : replaced boolean return with true for com/yubico/webauthn/data/UserVerificationRequirement::lambda$fromValue$0 → KILLED 3. fromValue : replaced return value with Optional.empty for com/yubico/webauthn/data/UserVerificationRequirement::fromValue → KILLED |
return Stream.of(values()).filter(v -> v.value.equals(value)).findAny(); |
82 | } | |
83 | ||
84 | @JsonCreator | |
85 |
1
1. fromJsonString : negated conditional → KILLED |
private static UserVerificationRequirement fromJsonString(@NonNull String value) { |
86 |
1
1. fromJsonString : replaced return value with null for com/yubico/webauthn/data/UserVerificationRequirement::fromJsonString → KILLED |
return fromValue(value) |
87 | .orElseThrow( | |
88 | () -> | |
89 |
1
1. lambda$fromJsonString$1 : replaced return value with null for com/yubico/webauthn/data/UserVerificationRequirement::lambda$fromJsonString$1 → KILLED |
new IllegalArgumentException( |
90 | String.format( | |
91 | "Unknown %s value: %s", | |
92 | UserVerificationRequirement.class.getSimpleName(), value))); | |
93 | } | |
94 | } | |
Mutations | ||
80 |
1.1 |
|
81 |
1.1 2.2 3.3 |
|
85 |
1.1 |
|
86 |
1.1 |
|
89 |
1.1 |