PublicKeyCredentialParameters.java

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#ES256} and type {@link
79
   * PublicKeyCredentialType#PUBLIC_KEY}.
80
   *
81
   * @since 0.3.0
82
   */
83
  public static final PublicKeyCredentialParameters ES256 =
84
      builder().alg(COSEAlgorithmIdentifier.ES256).build();
85
86
  /**
87
   * Algorithm {@link COSEAlgorithmIdentifier#ES384} and type {@link
88
   * PublicKeyCredentialType#PUBLIC_KEY}.
89
   *
90
   * @since 2.1.0
91
   */
92
  public static final PublicKeyCredentialParameters ES384 =
93
      builder().alg(COSEAlgorithmIdentifier.ES384).build();
94
95
  /**
96
   * Algorithm {@link COSEAlgorithmIdentifier#ES512} and type {@link
97
   * PublicKeyCredentialType#PUBLIC_KEY}.
98
   *
99
   * @since 2.1.0
100
   */
101
  public static final PublicKeyCredentialParameters ES512 =
102
      builder().alg(COSEAlgorithmIdentifier.ES512).build();
103
104
  /**
105
   * Algorithm {@link COSEAlgorithmIdentifier#RS1} and type {@link
106
   * PublicKeyCredentialType#PUBLIC_KEY}.
107
   *
108
   * @since 1.5.0
109
   */
110
  public static final PublicKeyCredentialParameters RS1 =
111
      builder().alg(COSEAlgorithmIdentifier.RS1).build();
112
113
  /**
114
   * Algorithm {@link COSEAlgorithmIdentifier#RS256} and type {@link
115
   * PublicKeyCredentialType#PUBLIC_KEY}.
116
   *
117
   * @since 0.3.0
118
   */
119
  public static final PublicKeyCredentialParameters RS256 =
120
      builder().alg(COSEAlgorithmIdentifier.RS256).build();
121
122
  /**
123
   * Algorithm {@link COSEAlgorithmIdentifier#RS384} and type {@link
124
   * PublicKeyCredentialType#PUBLIC_KEY}.
125
   *
126
   * @since 2.4.0
127
   */
128
  public static final PublicKeyCredentialParameters RS384 =
129
      builder().alg(COSEAlgorithmIdentifier.RS384).build();
130
131
  /**
132
   * Algorithm {@link COSEAlgorithmIdentifier#RS512} and type {@link
133
   * PublicKeyCredentialType#PUBLIC_KEY}.
134
   *
135
   * @since 2.4.0
136
   */
137
  public static final PublicKeyCredentialParameters RS512 =
138
      builder().alg(COSEAlgorithmIdentifier.RS512).build();
139
140
  public static PublicKeyCredentialParametersBuilder.MandatoryStages builder() {
141 1 1. builder : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters::builder → KILLED
    return new PublicKeyCredentialParametersBuilder.MandatoryStages();
142
  }
143
144
  public static class PublicKeyCredentialParametersBuilder {
145
    public static class MandatoryStages {
146
      private final PublicKeyCredentialParametersBuilder builder =
147
          new PublicKeyCredentialParametersBuilder();
148
149
      /**
150
       * {@link PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier) alg} is a required
151
       * parameter.
152
       *
153
       * @since 0.3.0
154
       * @see PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier)
155
       */
156
      public PublicKeyCredentialParametersBuilder alg(COSEAlgorithmIdentifier alg) {
157 1 1. alg : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters$PublicKeyCredentialParametersBuilder$MandatoryStages::alg → KILLED
        return builder.alg(alg);
158
      }
159
    }
160
  }
161
}

Mutations

62

1.1
Location : <init>
Killed by : com.yubico.webauthn.data.BuildersSpec
negated conditional → KILLED

63

1.1
Location : <init>
Killed by : com.yubico.webauthn.data.BuildersSpec
negated conditional → KILLED

141

1.1
Location : builder
Killed by : com.yubico.webauthn.data.BuildersSpec
replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters::builder → KILLED

157

1.1
Location : alg
Killed by : com.yubico.webauthn.data.BuildersSpec
replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters$PublicKeyCredentialParametersBuilder$MandatoryStages::alg → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0