Started with the separated DB with the given code
[RRRRHHHH_Code] / ruralHouses / src / domain / Account.java
index 53dff45..989440c 100644 (file)
@@ -1,23 +1,31 @@
 package domain;
 
+import java.io.Serializable;
+import java.util.Arrays;
+
 import businessLogic.SecurityManager;
 
-public class Account {
+
+public class Account implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       
 
        private byte[] username;
        private byte[] password;
        private byte[] salt;
-
        private Owner owner;
        private boolean admin = false;
 
-       
-       public Account(String usr){
-               this.username = SecurityManager.getInstance().calculateHash(usr);
+
+       public Account(byte[] usr){
+               this.username = usr;
                this.salt =null;
                this.password = null;
                this.owner = null;
-               
        }
        public Account(String usr, String pass, boolean isAdmin) {
                this.username = SecurityManager.getInstance().calculateHash(usr);
@@ -25,7 +33,13 @@ public class Account {
                this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(), this.salt);
                this.owner = null;
                this.admin = isAdmin;
-
+       }
+       
+       public Account(Owner own){
+               this.username = null;
+               this.salt =null;
+               this.password = null;
+               this.owner = own;
        }
 
        public Account(String usr, String pass, Owner ow) {
@@ -38,6 +52,9 @@ public class Account {
 
        }
 
+
+       
+
        public byte[] getUsername() {
                return username;
        }
@@ -54,6 +71,7 @@ public class Account {
                return admin;
        }
 
+       
        public void setAdmin(boolean admin) {
                this.admin = admin;
        }
@@ -65,5 +83,20 @@ public class Account {
        public void setSalt(byte[] salt) {
                this.salt = salt;
        }
+       
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               Account other = (Account) obj;
+               if (!Arrays.equals(username, other.username))
+                       return false;
+               return true;
+       }
 
 }