DataHandlerForTestsTest added,
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / core / User.java
index 0c438c2..e964628 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2015 Berner Fachhochschule, Switzerland.
+ *
+ * Project Smart Reservation System.
+ *
+ * Distributable under GPL license. See terms of license at gnu.org.
+ */
 package ch.bfh.ti.srs.core;
 
 import ch.bfh.ti.srs.extern.Password;
@@ -10,12 +17,37 @@ public class User {
        private String name;
        private String lastname;
 
+       /**
+        * Constructor for already existing user in the Datacontext
+        * Only to be used by DataHandler implementation!
+        * 
+        * @param userName              Username
+        * @param password              Encrypted password
+        * @param mail                  Mail
+        * @param name                  Name
+        * @param lastname              Lastname
+        */
+       //TODO: Change constructor to package when DataHandlerForExcel is moved back to this package
+       public User(String userName, String password, String mail, String name, String lastname){
+               this.userName = userName;
+               this.password = password;
+               this.mail = mail;
+               this.name = name;
+               this.lastname = lastname;
+       }
 
+       /**
+        * Normal constructor for new users created in the UserController
+        * 
+        * @param userName
+        * @param password
+        * @throws Exception
+        */
        public User(String userName, String password) throws Exception{
                if(userName == null) throw new IllegalArgumentException("Username must not be null");
                if(userName.length() < 4) throw new IllegalArgumentException("Username must have at least 4 characters");
                if(password == null) throw new IllegalArgumentException("Password must not be null");
-               
+
                this.userName = userName;
                this.password = Password.getSaltedHash(password);
        }
@@ -37,6 +69,9 @@ public class User {
                return lastname;
        }
        
+       public String getEncryptedPassword(){
+               return password;
+       }
        
        //Setter
        public boolean setMail(String mail){