Advertisement
Guest User

Untitled

a guest
Jun 4th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. /**
  2. * Method that creates a new UserDefault and returns it
  3. *
  4. * @param name the user's name
  5. * @param email the user's email
  6. * @param uncryptedPassword the user's uncrypted password
  7. * @return the created User Default
  8. */
  9. public UserDefault newUserDefault(String name, String email, String uncryptedPassword) {
  10. return new UserDefault(name, email, uncryptedPassword);
  11. }
  12.  
  13. /**
  14. * Method to add and validate a user if the user is valid it is then added
  15. * to the list
  16. *
  17. * @param user the user we are validating and adding
  18. * @param passwordUncrypted the user's password
  19. * @return true if the user was valid and added sucessfully
  20. */
  21. public boolean addUser(UserDefault user, String passwordUncrypted) {
  22.  
  23. if (findUser(user.getEmail()) != null) {
  24. return false;
  25. }
  26.  
  27. if (!user.validateUser(passwordUncrypted)) {
  28. return false;
  29. }
  30.  
  31. return add(user);
  32. }
  33.  
  34. }
  35.  
  36. ///Diferente
  37. /**
  38. * Complete constructor for UserDafault
  39. * @param username The user's username
  40. * @param email the user's email
  41. * @param uncryptedPassword the user's uncrypted password
  42. */
  43. public UserDefault(String username , String email , String uncryptedPassword){
  44. this.username=username;
  45. this.email=email;
  46. this.password=new Password(uncryptedPassword);
  47. }
  48.  
  49. /**
  50. * Method the validates the userDefault
  51. * @param uncryptedPassword the user's uncrypted password
  52. * @return true if inserted password was equal to user's pre-determined password
  53. */
  54. public boolean validateUser(String uncryptedPassword){
  55. return password.checkPassword(uncryptedPassword);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement