java-doc updated
authorMichael <Michael@Michael-LT.bfh.ch>
Tue, 3 Nov 2015 10:35:26 +0000 (11:35 +0100)
committerMichael <Michael@Michael-LT.bfh.ch>
Tue, 3 Nov 2015 10:35:26 +0000 (11:35 +0100)
src/main/java/ch/bfh/ti/srs/core/User.java

index 4f01b0b..95240e8 100644 (file)
@@ -52,7 +52,6 @@ public class User {
                this.hashedPassword = Password.getSaltedHash(password);
        }
 
-       //Getter
        public String getUserName(){
                return userName;
        }
@@ -73,7 +72,6 @@ public class User {
                return hashedPassword;
        }
        
-       //Setter
        public boolean setMail(String mail){
                if(mail != null){
                        if(isValidEmailAddress(mail)){
@@ -92,21 +90,36 @@ public class User {
                this.lastname = lastname;
        }
        
-       
-       //Password methods
+       /**
+        * Checks if the given password matches the hashedPassword
+        * 
+        * @param       password
+        * @return      
+        * @throws      Exception
+        */
        public boolean checkPassword(String password) throws Exception{
                if(password == null) throw new IllegalArgumentException("Password must not be null");
                return Password.check(password, this.hashedPassword);
        }
 
+       /**
+        * Changes the current password to the given newPassword param, if newPassword is whether null nor equals the current password
+        * 
+        * @param       newPassword
+        * @throws      Exception
+        */
        public void changePassword(String newPassword) throws Exception{
                if(newPassword == null) throw new IllegalArgumentException("Password must not be null");
                if(checkPassword(newPassword)) throw new IllegalArgumentException("Can not be the current password");
                this.hashedPassword = Password.getSaltedHash(newPassword);
        }
 
-
-       //private Helper methods
+       /**
+        * Checks if the given string represents a valid email address
+        * 
+        * @param       mail    address
+        * @return
+        */
        private boolean isValidEmailAddress(String mail){
                String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
                java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);