StartRegistrationOptions.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;
26
27
import com.yubico.webauthn.data.AuthenticatorSelectionCriteria;
28
import com.yubico.webauthn.data.PublicKeyCredentialCreationOptions;
29
import com.yubico.webauthn.data.RegistrationExtensionInputs;
30
import com.yubico.webauthn.data.UserIdentity;
31
import java.util.Optional;
32
import lombok.Builder;
33
import lombok.NonNull;
34
import lombok.Value;
35
36
/** Parameters for {@link RelyingParty#startRegistration(StartRegistrationOptions)}. */
37
@Value
38
@Builder(toBuilder = true)
39
public class StartRegistrationOptions {
40
41
  /** Identifiers for the user creating a credential. */
42
  @NonNull private final UserIdentity user;
43
44
  /**
45
   * Constraints on what kind of authenticator the user is allowed to use to create the credential,
46
   * and on features that authenticator must or should support.
47
   */
48
  private final AuthenticatorSelectionCriteria authenticatorSelection;
49
50
  /** Extension inputs for this registration operation. */
51
  @NonNull @Builder.Default
52
  private final RegistrationExtensionInputs extensions =
53
      RegistrationExtensionInputs.builder().build();
54
55
  /**
56
   * The value for {@link PublicKeyCredentialCreationOptions#getTimeout()} for this registration
57
   * operation.
58
   *
59
   * <p>This library does not take the timeout into account in any way, other than passing it
60
   * through to the {@link PublicKeyCredentialCreationOptions} so it can be used as an argument to
61
   * <code>navigator.credentials.create()</code> on the client side.
62
   *
63
   * <p>The default is empty.
64
   */
65
  private final Long timeout;
66
67
  /**
68
   * Constraints on what kind of authenticator the user is allowed to use to create the credential,
69
   * and on features that authenticator must or should support.
70
   */
71
  public Optional<AuthenticatorSelectionCriteria> getAuthenticatorSelection() {
72 1 1. getAuthenticatorSelection : replaced return value with Optional.empty for com/yubico/webauthn/StartRegistrationOptions::getAuthenticatorSelection → KILLED
    return Optional.ofNullable(authenticatorSelection);
73
  }
74
75
  /**
76
   * The value for {@link PublicKeyCredentialCreationOptions#getTimeout()} for this registration
77
   * operation.
78
   *
79
   * <p>This library does not take the timeout into account in any way, other than passing it
80
   * through to the {@link PublicKeyCredentialCreationOptions} so it can be used as an argument to
81
   * <code>navigator.credentials.create()</code> on the client side.
82
   *
83
   * <p>The default is empty.
84
   */
85
  public Optional<Long> getTimeout() {
86 1 1. getTimeout : replaced return value with Optional.empty for com/yubico/webauthn/StartRegistrationOptions::getTimeout → KILLED
    return Optional.ofNullable(timeout);
87
  }
88
89
  public static StartRegistrationOptionsBuilder.MandatoryStages builder() {
90 1 1. builder : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions::builder → KILLED
    return new StartRegistrationOptionsBuilder.MandatoryStages();
91
  }
92
93
  public static class StartRegistrationOptionsBuilder {
94
    private AuthenticatorSelectionCriteria authenticatorSelection = null;
95
    private Long timeout = null;
96
97
    public static class MandatoryStages {
98
      private final StartRegistrationOptionsBuilder builder = new StartRegistrationOptionsBuilder();
99
100
      /**
101
       * {@link StartRegistrationOptionsBuilder#user(UserIdentity) user} is a required parameter.
102
       *
103
       * @see StartRegistrationOptionsBuilder#user(UserIdentity)
104
       */
105
      public StartRegistrationOptionsBuilder user(UserIdentity user) {
106 1 1. user : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder$MandatoryStages::user → KILLED
        return builder.user(user);
107
      }
108
    }
109
110
    /**
111
     * Constraints on what kind of authenticator the user is allowed to use to create the
112
     * credential, and on features that authenticator must or should support.
113
     */
114
    public StartRegistrationOptionsBuilder authenticatorSelection(
115 1 1. authenticatorSelection : negated conditional → KILLED
        @NonNull Optional<AuthenticatorSelectionCriteria> authenticatorSelection) {
116 1 1. authenticatorSelection : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::authenticatorSelection → KILLED
      return this.authenticatorSelection(authenticatorSelection.orElse(null));
117
    }
118
119
    /**
120
     * Constraints on what kind of authenticator the user is allowed to use to create the
121
     * credential, and on features that authenticator must or should support.
122
     */
123
    public StartRegistrationOptionsBuilder authenticatorSelection(
124
        AuthenticatorSelectionCriteria authenticatorSelection) {
125
      this.authenticatorSelection = authenticatorSelection;
126 1 1. authenticatorSelection : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::authenticatorSelection → KILLED
      return this;
127
    }
128
129
    /**
130
     * The value for {@link PublicKeyCredentialCreationOptions#getTimeout()} for this registration
131
     * operation.
132
     *
133
     * <p>This library does not take the timeout into account in any way, other than passing it
134
     * through to the {@link PublicKeyCredentialCreationOptions} so it can be used as an argument to
135
     * <code>navigator.credentials.create()</code> on the client side.
136
     *
137
     * <p>The default is empty.
138
     */
139 1 1. timeout : negated conditional → KILLED
    public StartRegistrationOptionsBuilder timeout(@NonNull Optional<Long> timeout) {
140 3 1. timeout : negated conditional → KILLED
2. timeout : changed conditional boundary → KILLED
3. timeout : negated conditional → KILLED
      if (timeout.isPresent() && timeout.get() <= 0) {
141
        throw new IllegalArgumentException("timeout must be positive, was: " + timeout.get());
142
      }
143
      this.timeout = timeout.orElse(null);
144 1 1. timeout : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::timeout → KILLED
      return this;
145
    }
146
147
    /**
148
     * The value for {@link PublicKeyCredentialCreationOptions#getTimeout()} for this registration
149
     * operation.
150
     *
151
     * <p>This library does not take the timeout into account in any way, other than passing it
152
     * through to the {@link PublicKeyCredentialCreationOptions} so it can be used as an argument to
153
     * <code>navigator.credentials.create()</code> on the client side.
154
     *
155
     * <p>The default is empty.
156
     */
157
    public StartRegistrationOptionsBuilder timeout(long timeout) {
158 1 1. timeout : replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::timeout → KILLED
      return this.timeout(Optional.of(timeout));
159
    }
160
  }
161
}

Mutations

72

1.1
Location : getAuthenticatorSelection
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with Optional.empty for com/yubico/webauthn/StartRegistrationOptions::getAuthenticatorSelection → KILLED

86

1.1
Location : getTimeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with Optional.empty for com/yubico/webauthn/StartRegistrationOptions::getTimeout → KILLED

90

1.1
Location : builder
Killed by : com.yubico.webauthn.RelyingPartyTest.filtersAlgorithmsToThoseAvailable(com.yubico.webauthn.RelyingPartyTest)
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions::builder → KILLED

106

1.1
Location : user
Killed by : com.yubico.webauthn.RelyingPartyTest.filtersAlgorithmsToThoseAvailable(com.yubico.webauthn.RelyingPartyTest)
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder$MandatoryStages::user → KILLED

115

1.1
Location : authenticatorSelection
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
negated conditional → KILLED

116

1.1
Location : authenticatorSelection
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::authenticatorSelection → KILLED

126

1.1
Location : authenticatorSelection
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::authenticatorSelection → KILLED

139

1.1
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
negated conditional → KILLED

140

1.1
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
negated conditional → KILLED

2.2
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
changed conditional boundary → KILLED

3.3
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
negated conditional → KILLED

144

1.1
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::timeout → KILLED

158

1.1
Location : timeout
Killed by : com.yubico.webauthn.RelyingPartyStartOperationSpec
replaced return value with null for com/yubico/webauthn/StartRegistrationOptions$StartRegistrationOptionsBuilder::timeout → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0