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
 * @see <a
36
 *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dictdef-publickeycredentialparameters">§5.3.
37
 *     Parameters for Credential Generation (dictionary PublicKeyCredentialParameters) </a>
38
 */
39
@Value
40
@Builder(toBuilder = true)
41
public class PublicKeyCredentialParameters {
42
43
  /**
44
   * Specifies the cryptographic signature algorithm with which the newly generated credential will
45
   * be used, and thus also the type of asymmetric key pair to be generated, e.g., RSA or Elliptic
46
   * Curve.
47
   */
48
  @NonNull private final COSEAlgorithmIdentifier alg;
49
50
  /** Specifies the type of credential to be created. */
51
  @NonNull @Builder.Default
52
  private final PublicKeyCredentialType type = PublicKeyCredentialType.PUBLIC_KEY;
53
54
  private PublicKeyCredentialParameters(
55 1 1. <init> : negated conditional → KILLED
      @NonNull @JsonProperty("alg") COSEAlgorithmIdentifier alg,
56 1 1. <init> : negated conditional → KILLED
      @NonNull @JsonProperty("type") PublicKeyCredentialType type) {
57
    this.alg = alg;
58
    this.type = type;
59
  }
60
61
  /**
62
   * Algorithm {@link COSEAlgorithmIdentifier#EdDSA} and type {@link
63
   * PublicKeyCredentialType#PUBLIC_KEY}.
64
   */
65
  public static final PublicKeyCredentialParameters EdDSA =
66
      builder().alg(COSEAlgorithmIdentifier.EdDSA).build();
67
68
  /**
69
   * Algorithm {@link COSEAlgorithmIdentifier#ES256} and type {@link
70
   * PublicKeyCredentialType#PUBLIC_KEY}.
71
   */
72
  public static final PublicKeyCredentialParameters ES256 =
73
      builder().alg(COSEAlgorithmIdentifier.ES256).build();
74
75
  /**
76
   * Algorithm {@link COSEAlgorithmIdentifier#ES384} and type {@link
77
   * PublicKeyCredentialType#PUBLIC_KEY}.
78
   */
79
  public static final PublicKeyCredentialParameters ES384 =
80
      builder().alg(COSEAlgorithmIdentifier.ES384).build();
81
82
  /**
83
   * Algorithm {@link COSEAlgorithmIdentifier#ES512} and type {@link
84
   * PublicKeyCredentialType#PUBLIC_KEY}.
85
   */
86
  public static final PublicKeyCredentialParameters ES512 =
87
      builder().alg(COSEAlgorithmIdentifier.ES512).build();
88
89
  /**
90
   * Algorithm {@link COSEAlgorithmIdentifier#RS1} and type {@link
91
   * PublicKeyCredentialType#PUBLIC_KEY}.
92
   */
93
  public static final PublicKeyCredentialParameters RS1 =
94
      builder().alg(COSEAlgorithmIdentifier.RS1).build();
95
96
  /**
97
   * Algorithm {@link COSEAlgorithmIdentifier#RS256} and type {@link
98
   * PublicKeyCredentialType#PUBLIC_KEY}.
99
   */
100
  public static final PublicKeyCredentialParameters RS256 =
101
      builder().alg(COSEAlgorithmIdentifier.RS256).build();
102
103
  /**
104
   * Algorithm {@link COSEAlgorithmIdentifier#RS384} and type {@link
105
   * PublicKeyCredentialType#PUBLIC_KEY}.
106
   */
107
  public static final PublicKeyCredentialParameters RS384 =
108
      builder().alg(COSEAlgorithmIdentifier.RS384).build();
109
110
  /**
111
   * Algorithm {@link COSEAlgorithmIdentifier#RS512} and type {@link
112
   * PublicKeyCredentialType#PUBLIC_KEY}.
113
   */
114
  public static final PublicKeyCredentialParameters RS512 =
115
      builder().alg(COSEAlgorithmIdentifier.RS512).build();
116
117
  public static PublicKeyCredentialParametersBuilder.MandatoryStages builder() {
118 1 1. builder : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters::builder → KILLED
    return new PublicKeyCredentialParametersBuilder.MandatoryStages();
119
  }
120
121
  public static class PublicKeyCredentialParametersBuilder {
122
    public static class MandatoryStages {
123
      private final PublicKeyCredentialParametersBuilder builder =
124
          new PublicKeyCredentialParametersBuilder();
125
126
      /**
127
       * {@link PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier) alg} is a required
128
       * parameter.
129
       *
130
       * @see PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier)
131
       */
132
      public PublicKeyCredentialParametersBuilder alg(COSEAlgorithmIdentifier alg) {
133 1 1. alg : replaced return value with null for com/yubico/webauthn/data/PublicKeyCredentialParameters$PublicKeyCredentialParametersBuilder$MandatoryStages::alg → KILLED
        return builder.alg(alg);
134
      }
135
    }
136
  }
137
}

Mutations

55

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

56

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

118

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

133

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