Beispiel #1
0
  private void validateUser(User user) throws Exception {
    StringBuilder errorList = new StringBuilder();

    if (user.getUsername() == null
        || user.getUsername().equals("")
        || user.getPassword() == null
        || user.getPassword().equals("")) {
      errorList.append("Please, provide username and password");
      errorList.append(System.getProperty("line.separator"));
    } else if (userService.find(user.getUsername(), Encryptor.MD5(user.getPassword())) == null) {
      errorList.append("Please, provide valid username and password");
      errorList.append(System.getProperty("line.separator"));
    }

    if (errorList.length() > 0) {
      throw new Exception(errorList.toString());
    }
  }