1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.lib.wa;
20
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.List;
24 import org.apache.commons.lang3.builder.EqualsBuilder;
25 import org.apache.commons.lang3.builder.HashCodeBuilder;
26 import org.apache.commons.lang3.builder.ToStringBuilder;
27 import org.apache.syncope.common.lib.BaseBean;
28
29 public class WebAuthnAccount implements BaseBean {
30
31 private static final long serialVersionUID = 2285073386484048953L;
32
33 public static class Builder {
34
35 private final WebAuthnAccount instance = new WebAuthnAccount();
36
37 public WebAuthnAccount.Builder credential(final WebAuthnDeviceCredential credential) {
38 instance.getCredentials().add(credential);
39 return this;
40 }
41
42 public WebAuthnAccount.Builder credentials(final WebAuthnDeviceCredential... credentials) {
43 instance.getCredentials().addAll(List.of(credentials));
44 return this;
45 }
46
47 public WebAuthnAccount.Builder credentials(final Collection<WebAuthnDeviceCredential> credentials) {
48 instance.getCredentials().addAll(credentials);
49 return this;
50 }
51
52 public WebAuthnAccount build() {
53 return instance;
54 }
55 }
56
57 private final List<WebAuthnDeviceCredential> credentials = new ArrayList<>();
58
59 public List<WebAuthnDeviceCredential> getCredentials() {
60 return credentials;
61 }
62
63 @Override
64 public int hashCode() {
65 return new HashCodeBuilder()
66 .appendSuper(super.hashCode())
67 .append(credentials)
68 .toHashCode();
69 }
70
71 @Override
72 public boolean equals(final Object obj) {
73 if (obj == null) {
74 return false;
75 }
76 if (obj == this) {
77 return true;
78 }
79 if (obj.getClass() != getClass()) {
80 return false;
81 }
82 WebAuthnAccount rhs = (WebAuthnAccount) obj;
83 return new EqualsBuilder()
84 .appendSuper(super.equals(obj))
85 .append(this.credentials, rhs.credentials)
86 .isEquals();
87 }
88
89 @Override
90 public String toString() {
91 return new ToStringBuilder(this)
92 .append("credentials", credentials)
93 .toString();
94 }
95 }