The bug found in the presentation that we forgot to review has been fixed
[RRRRHHHH_Code] / ruralHouses / src / domain / Account.java
1 package domain;
2
3 import java.io.Serializable;
4 import java.util.Arrays;
5
6 import businessLogic.SecurityManager;
7
8
9 public class Account implements Serializable {
10
11         /**
12          * 
13          */
14         private static final long serialVersionUID = 1L;
15         
16
17         private byte[] username;
18         private byte[] password;
19         private byte[] salt;
20         private Owner owner;
21         private boolean admin = false;
22
23
24         public Account(byte[] usr){
25                 this.username = usr;
26                 this.salt =null;
27                 this.password = null;
28                 this.owner = null;
29         }
30         public Account(String usr, String pass, boolean isAdmin) {
31                 this.username = SecurityManager.getInstance().calculateHash(usr);
32                 this.salt = SecurityManager.getInstance().generateSalt();
33                 this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(), this.salt);
34                 this.owner = null;
35                 this.admin = isAdmin;
36         }
37         
38         public Account(Owner own){
39                 this.username = null;
40                 this.salt =null;
41                 this.password = null;
42                 this.owner = own;
43         }
44
45         public Account(String usr, String pass, Owner ow) {
46                 this.username = SecurityManager.getInstance().calculateHash(usr);
47                 this.salt = SecurityManager.getInstance().generateSalt();
48                 this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(),
49                                 this.salt);
50                 this.owner = ow;
51                 this.admin = false;
52
53         }
54
55
56         
57
58         public byte[] getUsername() {
59                 return username;
60         }
61
62         public byte[] getPassword() {
63                 return password;
64         }
65
66         public Owner getOwner() {
67                 return owner;
68         }
69
70         public boolean getAdmin() {
71                 return admin;
72         }
73
74         
75         public void setAdmin(boolean admin) {
76                 this.admin = admin;
77         }
78
79         public byte[] getSalt() {
80                 return salt;
81         }
82
83         public void setSalt(byte[] salt) {
84                 this.salt = salt;
85         }
86         
87
88         @Override
89         public boolean equals(Object obj) {
90                 if (this == obj)
91                         return true;
92                 if (obj == null)
93                         return false;
94                 if (getClass() != obj.getClass())
95                         return false;
96                 Account other = (Account) obj;
97                 if (!Arrays.equals(username, other.username))
98                         return false;
99                 return true;
100         }
101
102 }