blob: 87ec8991f0da53d0f4d1dd054853ead4a886e710 [file] [log] [blame]
Michael Hanlca740d72015-06-16 10:04:58 +02001package de.ids_mannheim.korap.user;
2
Michael Hanlca740d72015-06-16 10:04:58 +02003import lombok.Getter;
4import lombok.Setter;
5import org.slf4j.Logger;
Michael Hanlac113e52016-01-19 15:49:20 +01006import org.slf4j.LoggerFactory;
Michael Hanlca740d72015-06-16 10:04:58 +02007
8@Getter
9@Setter
10public class KorAPUser extends User {
Michael Hanlac113e52016-01-19 15:49:20 +010011 private static Logger jlog = LoggerFactory.getLogger(KorAPUser.class);
Michael Hanlca740d72015-06-16 10:04:58 +020012 private static final long serialVersionUID = -7108308497625884584L;
13
14 //fixme: accountlink to shibboleth account
15 private String accountLink;
16
17 private String password;
18 private String URIFragment;
19 private Long URIExpiration;
20
21 protected KorAPUser(String username) {
22 super(username, 0);
23 this.URIFragment = "";
24 this.URIExpiration = 0L;
25 }
26
27 public KorAPUser(Integer id, String username) {
28 this(username);
29 this.setId(id);
30 }
31
32 public KorAPUser() {
33 super();
34 }
35
36 @Override
37 protected User clone() {
38 KorAPUser user = new KorAPUser(this.getUsername());
39 user.setUsername(this.getUsername());
40 user.setAccountCreation(this.getAccountCreation());
41 return user;
42 }
43
44 @Override
45 public int hashCode() {
46 int result = super.hashCode();
47 result = 31 * result + (jlog != null ? jlog.hashCode() : 0);
48 result = 31 * result + (password != null ? password.hashCode() : 0);
49 result = 31 * result + (URIFragment != null ?
50 URIFragment.hashCode() :
51 0);
52 result = 31 * result + (URIExpiration != null ?
53 URIExpiration.hashCode() :
54 0);
55 return result;
56 }
57
58 @Override
59 public boolean equals(Object o) {
60 if (this == o)
61 return true;
62 if (!(o instanceof KorAPUser))
63 return false;
64 if (!super.equals(o))
65 return false;
66
67 KorAPUser korAPUser = (KorAPUser) o;
68 if (URIExpiration != korAPUser.URIExpiration)
69 return false;
70 if (URIFragment != null ?
71 !URIFragment.equals(korAPUser.URIFragment) :
72 korAPUser.URIFragment != null)
73 return false;
74 return true;
75 }
76}