RRRRHHHH_Code
Diff Revisions
2ac167 ...
vs
0f75b2 ...
for ruralHouses/src/domain/Account.java
|
@@ -1,33 +1,48 @@ |
1 |
1 |
|
package domain; |
2 |
2 |
|
|
|
3 |
+ |
import businessLogic.SecurityManager; |
|
4 |
+ |
|
3 |
5 |
|
public class Account { |
4 |
6 |
|
|
5 |
|
- |
private String username = ""; |
6 |
|
- |
private String password = ""; |
|
7 |
+ |
private byte[] username; |
|
8 |
+ |
private byte[] password; |
|
9 |
+ |
private byte[] salt; |
|
10 |
+ |
|
7 |
11 |
|
private Owner owner; |
8 |
12 |
|
private boolean admin = false; |
9 |
13 |
|
|
10 |
|
- |
public Account(String usr, String pass, boolean admin) { |
11 |
|
- |
this.username = usr; |
12 |
|
- |
this.password = pass; |
|
14 |
+ |
|
|
15 |
+ |
public Account(String usr){ |
|
16 |
+ |
this.username = SecurityManager.getInstance().calculateHash(usr); |
|
17 |
+ |
this.salt =null; |
|
18 |
+ |
this.password = null; |
13 |
19 |
|
this.owner = null; |
14 |
|
- |
this.admin = admin; |
|
20 |
+ |
|
|
21 |
+ |
} |
|
22 |
+ |
public Account(String usr, String pass, boolean isAdmin) { |
|
23 |
+ |
this.username = SecurityManager.getInstance().calculateHash(usr); |
|
24 |
+ |
this.salt = SecurityManager.getInstance().generateSalt(); |
|
25 |
+ |
this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(), this.salt); |
|
26 |
+ |
this.owner = null; |
|
27 |
+ |
this.admin = isAdmin; |
15 |
28 |
|
|
16 |
29 |
|
} |
17 |
30 |
|
|
18 |
31 |
|
public Account(String usr, String pass, Owner ow) { |
19 |
|
- |
this.username = usr; |
20 |
|
- |
this.password = pass; |
|
32 |
+ |
this.username = SecurityManager.getInstance().calculateHash(usr); |
|
33 |
+ |
this.salt = SecurityManager.getInstance().generateSalt(); |
|
34 |
+ |
this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(), |
|
35 |
+ |
this.salt); |
21 |
36 |
|
this.owner = ow; |
22 |
37 |
|
this.admin = false; |
23 |
38 |
|
|
24 |
39 |
|
} |
25 |
40 |
|
|
26 |
|
- |
public String getUsername() { |
|
41 |
+ |
public byte[] getUsername() { |
27 |
42 |
|
return username; |
28 |
43 |
|
} |
29 |
44 |
|
|
30 |
|
- |
public String getPassword() { |
|
45 |
+ |
public byte[] getPassword() { |
31 |
46 |
|
return password; |
32 |
47 |
|
} |
33 |
48 |
|
|
|
@@ -43,4 +58,12 @@ |
43 |
58 |
|
this.admin = admin; |
44 |
59 |
|
} |
45 |
60 |
|
|
|
61 |
+ |
public byte[] getSalt() { |
|
62 |
+ |
return salt; |
|
63 |
+ |
} |
|
64 |
+ |
|
|
65 |
+ |
public void setSalt(byte[] salt) { |
|
66 |
+ |
this.salt = salt; |
|
67 |
+ |
} |
|
68 |
+ |
|
46 |
69 |
|
} |