| 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 static com.yubico.internal.util.ExceptionUtil.assertTrue; | |
| 28 | ||
| 29 | import com.fasterxml.jackson.annotation.JsonCreator; | |
| 30 | import com.fasterxml.jackson.annotation.JsonProperty; | |
| 31 | import java.util.Optional; | |
| 32 | import lombok.NonNull; | |
| 33 | import lombok.Value; | |
| 34 | ||
| 35 | /** | |
| 36 | * Information about the state of the <a href="https://tools.ietf.org/html/rfc8471">Token Binding | |
| 37 | * protocol</a> used when communicating with the Relying Party. | |
| 38 | * | |
| 39 | * @see <a | |
| 40 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dictdef-tokenbinding">dictionary | |
| 41 | * TokenBinding</a> | |
| 42 | */ | |
| 43 | @Value | |
| 44 | public class TokenBindingInfo { | |
| 45 | ||
| 46 | @NonNull private final TokenBindingStatus status; | |
| 47 | ||
| 48 | /** | |
| 49 | * This member MUST be present if {@link #status} is {@link TokenBindingStatus#PRESENT PRESENT}, | |
| 50 | * and MUST be the Token Binding ID that was used when communicating with the Relying Party. | |
| 51 | */ | |
| 52 | private final ByteArray id; | |
| 53 | ||
| 54 | @JsonCreator | |
| 55 | TokenBindingInfo( | |
| 56 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("status") TokenBindingStatus status, |
| 57 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("id") Optional<ByteArray> id) { |
| 58 |
1
1. <init> : negated conditional → KILLED |
if (status == TokenBindingStatus.PRESENT) { |
| 59 |
1
1. <init> : removed call to com/yubico/internal/util/ExceptionUtil::assertTrue → SURVIVED |
assertTrue( |
| 60 | id.isPresent(), | |
| 61 | "Token binding ID must be present if status is \"%s\".", | |
| 62 | TokenBindingStatus.PRESENT); | |
| 63 | } else { | |
| 64 |
1
1. <init> : removed call to com/yubico/internal/util/ExceptionUtil::assertTrue → SURVIVED |
assertTrue( |
| 65 |
1
1. <init> : negated conditional → KILLED |
!id.isPresent(), |
| 66 | "Token binding ID must not be present if status is not \"%s\".", | |
| 67 | TokenBindingStatus.PRESENT); | |
| 68 | } | |
| 69 | ||
| 70 | this.status = status; | |
| 71 | this.id = id.orElse(null); | |
| 72 | } | |
| 73 | ||
| 74 |
1
1. present : negated conditional → KILLED |
public static TokenBindingInfo present(@NonNull ByteArray id) { |
| 75 |
1
1. present : replaced return value with null for com/yubico/webauthn/data/TokenBindingInfo::present → KILLED |
return new TokenBindingInfo(TokenBindingStatus.PRESENT, Optional.of(id)); |
| 76 | } | |
| 77 | ||
| 78 | public static TokenBindingInfo supported() { | |
| 79 |
1
1. supported : replaced return value with null for com/yubico/webauthn/data/TokenBindingInfo::supported → SURVIVED |
return new TokenBindingInfo(TokenBindingStatus.SUPPORTED, Optional.empty()); |
| 80 | } | |
| 81 | ||
| 82 | public Optional<ByteArray> getId() { | |
| 83 |
1
1. getId : replaced return value with Optional.empty for com/yubico/webauthn/data/TokenBindingInfo::getId → KILLED |
return Optional.ofNullable(id); |
| 84 | } | |
| 85 | } | |
Mutations | ||
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 58 |
1.1 |
|
| 59 |
1.1 |
|
| 64 |
1.1 |
|
| 65 |
1.1 |
|
| 74 |
1.1 |
|
| 75 |
1.1 |
|
| 79 |
1.1 |
|
| 83 |
1.1 |