| 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.JsonProperty; | |
| 28 | import lombok.Builder; | |
| 29 | import lombok.NonNull; | |
| 30 | import lombok.Value; | |
| 31 | ||
| 32 | /** | |
| 33 | * Used to supply additional parameters when creating a new credential. | |
| 34 | * | |
| 35 | * @since 0.2.0 | |
| 36 | * @see <a | |
| 37 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dictdef-publickeycredentialparameters">§5.3. | |
| 38 | * Parameters for Credential Generation (dictionary PublicKeyCredentialParameters) </a> | |
| 39 | */ | |
| 40 | @Value | |
| 41 | @Builder(toBuilder = true) | |
| 42 | public class PublicKeyCredentialParameters { | |
| 43 | ||
| 44 | /** | |
| 45 | * Specifies the cryptographic signature algorithm with which the newly generated credential will | |
| 46 | * be used, and thus also the type of asymmetric key pair to be generated, e.g., RSA or Elliptic | |
| 47 | * Curve. | |
| 48 | * | |
| 49 | * @since 0.2.0 | |
| 50 | */ | |
| 51 | @NonNull private final COSEAlgorithmIdentifier alg; | |
| 52 | ||
| 53 | /** | |
| 54 | * Specifies the type of credential to be created. | |
| 55 | * | |
| 56 | * @since 0.2.0 | |
| 57 | */ | |
| 58 | @NonNull @Builder.Default | |
| 59 | private final PublicKeyCredentialType type = PublicKeyCredentialType.PUBLIC_KEY; | |
| 60 | ||
| 61 | private PublicKeyCredentialParameters( | |
| 62 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("alg") COSEAlgorithmIdentifier alg, |
| 63 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("type") PublicKeyCredentialType type) { |
| 64 | this.alg = alg; | |
| 65 | this.type = type; | |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Algorithm {@link COSEAlgorithmIdentifier#EdDSA} and type {@link | |
| 70 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 71 | * | |
| 72 | * @since 1.4.0 | |
| 73 | */ | |
| 74 | public static final PublicKeyCredentialParameters EdDSA = | |
| 75 | builder().alg(COSEAlgorithmIdentifier.EdDSA).build(); | |
| 76 | ||
| 77 | /** | |
| 78 | * Algorithm {@link COSEAlgorithmIdentifier#Ed448} and type {@link | |
| 79 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 80 | */ | |
| 81 | public static final PublicKeyCredentialParameters Ed448 = | |
| 82 | builder().alg(COSEAlgorithmIdentifier.Ed448).build(); | |
| 83 | ||
| 84 | /** | |
| 85 | * Algorithm {@link COSEAlgorithmIdentifier#ES256} and type {@link | |
| 86 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 87 | * | |
| 88 | * @since 0.3.0 | |
| 89 | */ | |
| 90 | public static final PublicKeyCredentialParameters ES256 = | |
| 91 | builder().alg(COSEAlgorithmIdentifier.ES256).build(); | |
| 92 | ||
| 93 | /** | |
| 94 | * Algorithm {@link COSEAlgorithmIdentifier#ES384} and type {@link | |
| 95 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 96 | * | |
| 97 | * @since 2.1.0 | |
| 98 | */ | |
| 99 | public static final PublicKeyCredentialParameters ES384 = | |
| 100 | builder().alg(COSEAlgorithmIdentifier.ES384).build(); | |
| 101 | ||
| 102 | /** | |
| 103 | * Algorithm {@link COSEAlgorithmIdentifier#ES512} and type {@link | |
| 104 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 105 | * | |
| 106 | * @since 2.1.0 | |
| 107 | */ | |
| 108 | public static final PublicKeyCredentialParameters ES512 = | |
| 109 | builder().alg(COSEAlgorithmIdentifier.ES512).build(); | |
| 110 | ||
| 111 | /** | |
| 112 | * Algorithm {@link COSEAlgorithmIdentifier#RS1} and type {@link | |
| 113 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 114 | * | |
| 115 | * @since 1.5.0 | |
| 116 | */ | |
| 117 | public static final PublicKeyCredentialParameters RS1 = | |
| 118 | builder().alg(COSEAlgorithmIdentifier.RS1).build(); | |
| 119 | ||
| 120 | /** | |
| 121 | * Algorithm {@link COSEAlgorithmIdentifier#RS256} and type {@link | |
| 122 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 123 | * | |
| 124 | * @since 0.3.0 | |
| 125 | */ | |
| 126 | public static final PublicKeyCredentialParameters RS256 = | |
| 127 | builder().alg(COSEAlgorithmIdentifier.RS256).build(); | |
| 128 | ||
| 129 | /** | |
| 130 | * Algorithm {@link COSEAlgorithmIdentifier#RS384} and type {@link | |
| 131 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 132 | * | |
| 133 | * @since 2.4.0 | |
| 134 | */ | |
| 135 | public static final PublicKeyCredentialParameters RS384 = | |
| 136 | builder().alg(COSEAlgorithmIdentifier.RS384).build(); | |
| 137 | ||
| 138 | /** | |
| 139 | * Algorithm {@link COSEAlgorithmIdentifier#RS512} and type {@link | |
| 140 | * PublicKeyCredentialType#PUBLIC_KEY}. | |
| 141 | * | |
| 142 | * @since 2.4.0 | |
| 143 | */ | |
| 144 | public static final PublicKeyCredentialParameters RS512 = | |
| 145 | builder().alg(COSEAlgorithmIdentifier.RS512).build(); | |
| 146 | ||
| 147 | public static PublicKeyCredentialParametersBuilder.MandatoryStages builder() { | |
| 148 |
1
1. builder : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters::builder → KILLED |
return new PublicKeyCredentialParametersBuilder.MandatoryStages(); |
| 149 | } | |
| 150 | ||
| 151 | public static class PublicKeyCredentialParametersBuilder { | |
| 152 | public static class MandatoryStages { | |
| 153 | private final PublicKeyCredentialParametersBuilder builder = | |
| 154 | new PublicKeyCredentialParametersBuilder(); | |
| 155 | ||
| 156 | /** | |
| 157 | * {@link PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier) alg} is a required | |
| 158 | * parameter. | |
| 159 | * | |
| 160 | * @since 0.3.0 | |
| 161 | * @see PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier) | |
| 162 | */ | |
| 163 | public PublicKeyCredentialParametersBuilder alg(COSEAlgorithmIdentifier alg) { | |
| 164 |
1
1. alg : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters$PublicKeyCredentialParametersBuilder$MandatoryStages::alg → KILLED |
return builder.alg(alg); |
| 165 | } | |
| 166 | } | |
| 167 | } | |
| 168 | } | |
Mutations | ||
| 62 |
1.1 |
|
| 63 |
1.1 |
|
| 148 |
1.1 |
|
| 164 |
1.1 |