-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
184 lines (163 loc) · 3.38 KB
/
User.java
File metadata and controls
184 lines (163 loc) · 3.38 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* @author abhin
* The user class to dtore the user records as user objects
*/
public class User implements Hash {
String username;
String Hpass;
String Name;
String eadd;
long phno;
int failli;
String lalgin;
boolean locked;
String Alg = "SHA-1";
/**
* @param u stores username
* @param p stores password
* @param n stores full name
* @param e stores email id
* @param ph stores phone number
* @param f stores failed login count
* @param b stores boolean of whether the account is locked
* @param ll stores the last login date
*/
User(String u, String p, String n, String e, long ph, int f, boolean b, String ll) {
username = u;
Hpass = p;
Name = n;
eadd = e;
phno = ph;
failli = f;
lalgin = ll;
locked = b;
}
/**
* @param u stores username
* @param p stores password
* @param n stores full name
* @param e stores email id
* @param ph stores phone number
*/
User(String u, String p, String n, String e, long ph) {
username = u;
Hpass = p;
Name = n;
eadd = e;
phno = ph;
failli = 0;
lalgin = "";
locked = false;
}
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username that is to be set as the current username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the password of the user
*/
public String getHpass() {
return Hpass;
}
/**
* @param hpass password to be set
*/
public void setHpass(String hpass) {
Hpass = hpass;
}
/**
* @return the full name
*/
public String getName() {
return Name;
}
/**
* @param name the name that is to be set
*/
public void setName(String name) {
Name = name;
}
/**
* @return the email address
*/
public String getEadd() {
return eadd;
}
/**
* @param eadd the email address that is to be set
*/
public void setEadd(String eadd) {
this.eadd = eadd;
}
/**
* @return the phone number
*/
public long getPhno() {
return phno;
}
/**
* @param phno the phone number that is to be set
*/
public void setPhno(long phno) {
this.phno = phno;
}
/**
* @return the failed login count
*/
public int getFailli() {
return failli;
}
/**
* @param failli the failed login count that is to be set
*/
public void setFailli(int failli) {
this.failli = failli;
}
/**
* @return the last login date
*/
public String getLalgin() {
return lalgin;
}
/**
* @param lalgin the last login date to be set
*/
public void setLalgin(String lalgin) {
this.lalgin = lalgin;
}
/**
* @return boolean whether the user account is locked
*/
public boolean isLocked() {
return locked;
}
/**
* @param locked boolean to be set
*/
public void setLocked(boolean locked) {
this.locked = locked;
}
/* (non-Javadoc)
* @see Hash#hashthis(java.lang.String)
*/
public String hashthis(String a) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance(Alg);
md.update(a.getBytes());
byte[] hash = md.digest();
StringBuilder sb = new StringBuilder();
for (byte b : hash) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
}