1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.filter.security.misc;
import java.time.LocalDate;
import java.util.Objects;
/**
* @author smorgrav
*/
public class User {
public static final String ATTRIBUTE_NAME = "vespa.user.attributes";
public static final LocalDate NO_DATE = LocalDate.EPOCH;
private final String email;
private final String name;
private final String nickname;
private final String picture;
private final boolean isVerified;
private final int loginCount;
private final LocalDate lastLogin;
public User(String email, String name, String nickname, String picture) {
this.email = Objects.requireNonNull(email);
this.name = name;
this.nickname = nickname;
this.picture = picture;
this.isVerified = false;
this.loginCount = -1;
this.lastLogin = NO_DATE;
}
public User(String email, String name, String nickname, String picture, boolean isVerified, int loginCount, LocalDate lastLogin) {
this.email = Objects.requireNonNull(email);
this.name = name;
this.nickname = nickname;
this.picture = picture;
this.isVerified = isVerified;
this.loginCount = loginCount;
this.lastLogin = Objects.requireNonNull(lastLogin);
}
public String name() {
return name;
}
public String email() {
return email;
}
public String nickname() {
return nickname;
}
public String picture() {
return picture;
}
public LocalDate lastLogin() { return lastLogin; }
public boolean isVerified() { return isVerified; }
public int loginCount() { return loginCount; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(name, user.name) &&
Objects.equals(email, user.email) &&
Objects.equals(nickname, user.nickname) &&
Objects.equals(picture, user.picture) &&
Objects.equals(lastLogin, user.lastLogin) &&
loginCount == user.loginCount &&
isVerified == user.isVerified;
}
@Override
public int hashCode() {
return Objects.hash(name, email, nickname, picture, lastLogin, loginCount, isVerified);
}
}
|