UserIdentity.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.JsonCreator;
28
import com.fasterxml.jackson.annotation.JsonProperty;
29
import lombok.Builder;
30
import lombok.Getter;
31
import lombok.NonNull;
32
import lombok.Value;
33
34
/**
35
 * Describes a user account, with which public key credentials can be associated.
36
 *
37
 * @see <a
38
 *     href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dictdef-publickeycredentialuserentity">§5.4.3.
39
 *     User Account Parameters for Credential Generation (dictionary PublicKeyCredentialUserEntity)
40
 *     </a>
41
 */
42
@Value
43
@Builder(toBuilder = true)
44
public class UserIdentity implements PublicKeyCredentialEntity {
45
46
  /**
47
   * A human-palatable identifier for a user account. It is intended only for display, i.e., aiding
48
   * the user in determining the difference between user accounts with similar {@link
49
   * #displayName}s.
50
   *
51
   * <p>For example: "alexm", "alex.p.mueller@example.com" or "+14255551234".
52
   */
53
  @NonNull
54
  @Getter(onMethod = @__({@Override}))
55
  private final String name;
56
57
  /**
58
   * A human-palatable name for the user account, intended only for display. For example, "Alex P.
59
   * Müller" or "田中 倫". The Relying Party SHOULD let the user choose this, and SHOULD NOT restrict
60
   * the choice more than necessary.
61
   *
62
   * <ul>
63
   *   <li>Relying Parties SHOULD perform enforcement, as prescribed in Section 2.3 of [RFC8266] for
64
   *       the Nickname Profile of the PRECIS FreeformClass [RFC8264], when setting {@link
65
   *       #displayName}'s value, or displaying the value to the user.
66
   *   <li>Clients SHOULD perform enforcement, as prescribed in Section 2.3 of [RFC8266] for the
67
   *       Nickname Profile of the PRECIS FreeformClass [RFC8264], on {@link #displayName}'s value
68
   *       prior to displaying the value to the user or including the value as a parameter of the
69
   *       <code>authenticatorMakeCredential</code> operation.
70
   * </ul>
71
   *
72
   * <p>When clients, client platforms, or authenticators display a {@link #displayName}'s value,
73
   * they should always use UI elements to provide a clear boundary around the displayed value, and
74
   * not allow overflow into other elements.
75
   *
76
   * <p>Authenticators MUST accept and store a 64-byte minimum length for a {@link #displayName}
77
   * member's value. Authenticators MAY truncate a {@link #displayName} member's value to a length
78
   * equal to or greater than 64 bytes.
79
   *
80
   * @see <a href="https://tools.ietf.org/html/rfc8264">RFC 8264</a>
81
   * @see <a href="https://tools.ietf.org/html/rfc8266">RFC 8266</a>
82
   */
83
  @NonNull private final String displayName;
84
85
  /**
86
   * The <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#user-handle">user handle</a>
87
   * for the account, specified by the Relying Party.
88
   *
89
   * <p>A user handle is an opaque byte sequence with a maximum size of 64 bytes. User handles are
90
   * not meant to be displayed to users. The user handle SHOULD NOT contain personally identifying
91
   * information about the user, such as a username or e-mail address; see <a
92
   * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-user-handle-privacy">§14.9 User
93
   * Handle Contents</a> for details.
94
   *
95
   * <p>To ensure secure operation, authentication and authorization decisions MUST be made on the
96
   * basis of this {@link #id} member, not the {@link #displayName} nor {@link #name} members. See
97
   * <a href="https://tools.ietf.org/html/rfc8266#section-6.1">Section 6.1 of RFC 8266</a>.
98
   *
99
   * <p>An authenticator will never contain more than one credential for a given Relying Party under
100
   * the same user handle.
101
   */
102
  @NonNull private final ByteArray id;
103
104
  @JsonCreator
105
  private UserIdentity(
106 1 1. <init> : negated conditional → KILLED
      @NonNull @JsonProperty("name") String name,
107 1 1. <init> : negated conditional → KILLED
      @NonNull @JsonProperty("displayName") String displayName,
108 1 1. <init> : negated conditional → KILLED
      @NonNull @JsonProperty("id") ByteArray id) {
109
    this.name = name;
110
    this.displayName = displayName;
111
    this.id = id;
112
  }
113
114
  public static UserIdentityBuilder.MandatoryStages builder() {
115 1 1. builder : replaced return value with null for com/yubico/webauthn/data/UserIdentity::builder → KILLED
    return new UserIdentityBuilder.MandatoryStages();
116
  }
117
118
  public static class UserIdentityBuilder {
119
120
    public static class MandatoryStages {
121
      private final UserIdentityBuilder builder = new UserIdentityBuilder();
122
123
      /**
124
       * {@link UserIdentityBuilder#name(String) name} is a required parameter.
125
       *
126
       * @see UserIdentityBuilder#name(String)
127
       */
128
      public Step2 name(String name) {
129
        builder.name(name);
130 1 1. name : replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages::name → KILLED
        return new Step2();
131
      }
132
133
      public class Step2 {
134
        /**
135
         * {@link UserIdentityBuilder#displayName(String) displayName} is a required parameter.
136
         *
137
         * @see UserIdentityBuilder#displayName(String)
138
         */
139
        public Step3 displayName(String displayName) {
140
          builder.displayName(displayName);
141 1 1. displayName : replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages$Step2::displayName → KILLED
          return new Step3();
142
        }
143
      }
144
145
      public class Step3 {
146
        /**
147
         * {@link UserIdentityBuilder#id(ByteArray) id} is a required parameter.
148
         *
149
         * @see UserIdentityBuilder#id(ByteArray)
150
         */
151
        public UserIdentityBuilder id(ByteArray id) {
152 1 1. id : replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages$Step3::id → KILLED
          return builder.id(id);
153
        }
154
      }
155
    }
156
  }
157
}

Mutations

106

1.1
Location : <init>
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
negated conditional → KILLED

107

1.1
Location : <init>
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
negated conditional → KILLED

108

1.1
Location : <init>
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
negated conditional → KILLED

115

1.1
Location : builder
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
replaced return value with null for com/yubico/webauthn/data/UserIdentity::builder → KILLED

130

1.1
Location : name
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages::name → KILLED

141

1.1
Location : displayName
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages$Step2::displayName → KILLED

152

1.1
Location : id
Killed by : com.yubico.webauthn.data.UserIdentityTest.itHasTheseBuilderMethods(com.yubico.webauthn.data.UserIdentityTest)
replaced return value with null for com/yubico/webauthn/data/UserIdentity$UserIdentityBuilder$MandatoryStages$Step3::id → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0