| 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.Arrays; | |
| 30 | import java.util.Optional; | |
| 31 | import lombok.AllArgsConstructor; | |
| 32 | import lombok.Getter; | |
| 33 | import lombok.NonNull; | |
| 34 | ||
| 35 | /** | |
| 36 | * Indicators of whether a {@link TokenBindingInfo}'s {@link TokenBindingInfo#getId() id} member is | |
| 37 | * present and, if not, whether the client supports token binding. | |
| 38 | * | |
| 39 | * @see <a | |
| 40 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-tokenbindingstatus">enum | |
| 41 | * TokenBindingStatus</a> | |
| 42 | * @see TokenBindingInfo | |
| 43 | */ | |
| 44 | @AllArgsConstructor | |
| 45 | public enum TokenBindingStatus { | |
| 46 | ||
| 47 | /** | |
| 48 | * Indicates token binding was used when communicating with the Relying Party. In this case, the | |
| 49 | * {@link TokenBindingInfo#getId()} member MUST be present. | |
| 50 | */ | |
| 51 | PRESENT("present"), | |
| 52 | ||
| 53 | /** | |
| 54 | * Indicates the client supports token binding, but it was not negotiated when communicating with | |
| 55 | * the Relying Party. | |
| 56 | */ | |
| 57 | SUPPORTED("supported"); | |
| 58 | ||
| 59 | @JsonValue @Getter @NonNull private final String value; | |
| 60 | ||
| 61 | /** | |
| 62 | * Attempt to parse a string as a {@link TokenBindingStatus}. | |
| 63 | * | |
| 64 | * @param value a {@link String} equal to the {@link #getValue() value} of a constant in {@link | |
| 65 | * TokenBindingStatus} | |
| 66 | * @return The {@link TokenBindingStatus} instance whose {@link #getValue() value} equals <code> | |
| 67 | * value</code>, if any. | |
| 68 | * @see <a | |
| 69 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#enumdef-tokenbindingstatus">enum | |
| 70 | * TokenBindingStatus</a> | |
| 71 | */ | |
| 72 |
1
1. fromValue : negated conditional → KILLED |
public static Optional<TokenBindingStatus> fromValue(@NonNull String value) { |
| 73 |
3
1. fromValue : replaced return value with Optional.empty for com/yubico/webauthn/data/TokenBindingStatus::fromValue → KILLED 2. lambda$fromValue$0 : replaced boolean return with true for com/yubico/webauthn/data/TokenBindingStatus::lambda$fromValue$0 → KILLED 3. lambda$fromValue$0 : replaced boolean return with false for com/yubico/webauthn/data/TokenBindingStatus::lambda$fromValue$0 → KILLED |
return Arrays.stream(values()).filter(v -> v.value.equals(value)).findAny(); |
| 74 | } | |
| 75 | ||
| 76 | @JsonCreator | |
| 77 |
1
1. fromJsonString : negated conditional → KILLED |
static TokenBindingStatus fromJsonString(@NonNull String value) { |
| 78 |
1
1. fromJsonString : replaced return value with null for com/yubico/webauthn/data/TokenBindingStatus::fromJsonString → KILLED |
return fromValue(value) |
| 79 | .orElseThrow( | |
| 80 | () -> | |
| 81 |
1
1. lambda$fromJsonString$1 : replaced return value with null for com/yubico/webauthn/data/TokenBindingStatus::lambda$fromJsonString$1 → NO_COVERAGE |
new IllegalArgumentException( |
| 82 | String.format( | |
| 83 | "Unknown %s value: %s", TokenBindingStatus.class.getSimpleName(), value))); | |
| 84 | } | |
| 85 | } | |
Mutations | ||
| 72 |
1.1 |
|
| 73 |
1.1 2.2 3.3 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 81 |
1.1 |