java-doc update
authorMichael <Michael@Michael-LT.bfh.ch>
Wed, 25 Nov 2015 10:07:34 +0000 (11:07 +0100)
committerMichael <Michael@Michael-LT.bfh.ch>
Wed, 25 Nov 2015 10:07:34 +0000 (11:07 +0100)
src/main/java/ch/bfh/ti/srs/dataschema/User.java

index fc75482..82301eb 100644 (file)
@@ -22,15 +22,20 @@ public class User implements Cloneable{
        /**
         * Constructor for already existing <code>User</code> in the Datacontext.
         * Only to be used by <code>DataHandler</code> implementation!
        /**
         * Constructor for already existing <code>User</code> in the Datacontext.
         * Only to be used by <code>DataHandler</code> implementation!
-        * 
-        * @param userName                      user name
-        * @param hashedPassword        encrypted password
-        * @param mail                          mail
-        * @param name                          name
-        * @param lastname                      last name
+        * @param userName
+        *            user name
+        * @param hashedPassword
+        *            encrypted password
+        * @param mail
+        *            mail
+        * @param name
+        *            name
+        * @param lastname
+        *            last name
         */
         */
-       //TODO: Change constructor to package when DataHandlerForExcel is moved back to this package
-       public User(String userName, String hashedPassword, String mail, String name, String lastname){
+       // TODO: Change constructor to package when DataHandlerForExcel is moved
+       // back to this package
+       public User(String userName, String hashedPassword, String mail, String name, String lastname) {
                this.userName = userName;
                this.hashedPassword = hashedPassword;
                this.mail = mail;
                this.userName = userName;
                this.hashedPassword = hashedPassword;
                this.mail = mail;
@@ -40,43 +45,49 @@ public class User implements Cloneable{
 
        /**
         * Normal constructor for new users created in the UserController
 
        /**
         * Normal constructor for new users created in the UserController
-        * 
-        * @param userName                                      user name
-        * @param password                                      password
-        * @throws IllegalArgumentException     user name or password does not meet requirements
+        * @param userName
+        *            user name
+        * @param password
+        *            password
+        * @throws IllegalArgumentException
+        *             user name or password does not meet requirements
+        * @throws Exception thrown by <code>Password</code> class
         */
         */
-       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");
+       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.hashedPassword = Password.getSaltedHash(password);
        }
 
 
                this.userName = userName;
                this.hashedPassword = Password.getSaltedHash(password);
        }
 
-       public String getUserName(){
+       public String getUserName() {
                return userName;
        }
 
                return userName;
        }
 
-       public String getMail(){
+       public String getMail() {
                return mail;
        }
                return mail;
        }
-       
+
        public String getName() {
                return name;
        }
        public String getName() {
                return name;
        }
-       
+
        public String getLastname() {
                return lastname;
        }
        public String getLastname() {
                return lastname;
        }
-       
-       public String getEncryptedPassword(){
+
+       public String getEncryptedPassword() {
                return hashedPassword;
        }
                return hashedPassword;
        }
-       
-       public boolean setMail(String mail){
-               if(mail != null){
-                       if(isValidEmailAddress(mail)){
+
+       public boolean setMail(String mail) {
+               if (mail != null) {
+                       if (isValidEmailAddress(mail)) {
                                this.mail = mail;
                                return true;
                        }
                                this.mail = mail;
                                return true;
                        }
@@ -87,53 +98,59 @@ public class User implements Cloneable{
        public void setName(String name) {
                this.name = name;
        }
        public void setName(String name) {
                this.name = name;
        }
-       
+
        public void setLastname(String lastname) {
                this.lastname = lastname;
        }
        public void setLastname(String lastname) {
                this.lastname = lastname;
        }
-       
+
        /**
         * Checks if the given password matches the hashedPassword
         * 
        /**
         * Checks if the given password matches the hashedPassword
         * 
-        * @param       password
-        * @return      
-        * @throws      Exception
+        * @param password      password to check
+        * @return      <code>True</code> password accepted, <code>False</code> password rejected
+        * @throws IllegalArgumentException     password is null
+        * @throws Exception thrown by <code>Password</code> class
         */
         */
-       public boolean checkPassword(String password) throws Exception{
-               if(password == null) throw new IllegalArgumentException("Password must not be null");
+       public boolean checkPassword(String password) throws Exception {
+               if (password == null)
+                       throw new IllegalArgumentException("Password must not be null");
                return Password.check(password, this.hashedPassword);
        }
 
        /**
                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
+        * Changes the current password
         * 
         * 
-        * @param       newPassword
-        * @throws      Exception
+        * @param newPassword   new password
+        * @throws IllegalArgumentException     password does not meet the requirements
+        * @throws Exception thrown by <code>Password</code> class
         */
         */
-       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");
+       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);
        }
 
        /**
         * Checks if the given string represents a valid email address
                this.hashedPassword = Password.getSaltedHash(newPassword);
        }
 
        /**
         * Checks if the given string represents a valid email address
-        * 
-        * @param       mail    address
+        * @param mail
+        *            address
         * @return
         */
         * @return
         */
-       private boolean isValidEmailAddress(String mail){
+       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);
                java.util.regex.Matcher m = p.matcher(mail);
                return m.matches();
        }
                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);
                java.util.regex.Matcher m = p.matcher(mail);
                return m.matches();
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
         * @see java.lang.Object#clone()
         */
        @Override
         * @see java.lang.Object#clone()
         */
        @Override
-    public User clone() throws CloneNotSupportedException {
-        return (User)super.clone();
-    }
+       public User clone() throws CloneNotSupportedException {
+               return (User) super.clone();
+       }
 }
\ No newline at end of file
 }
\ No newline at end of file