Beispiel #1
0
 /** The callback method for the forgot password link on the landing screen. */
 public void attemptForgotPassword() {
   Object usernameField = ui.find(mainPanel, "usernameField");
   String username = ui.getText(usernameField);
   if (username != null) {
     user = userDao.getUserByUsername(username);
     if (user != null) {
       changeModeRecoverPassword();
     } else {
       displayWarningMessage(INVALID_USER_MESSAGE);
     }
   } else {
     displayWarningMessage(INVALID_USER_MESSAGE);
   }
 }
Beispiel #2
0
 /**
  * The callback method for users creating a new password.
  *
  * @throws GeneralSecurityException if the crypto libray cannot be loaded
  */
 public void attemptSavePassword() throws GeneralSecurityException {
   // TODO: error handling
   Object passwordBox = ui.find(mainPanel, "password1");
   String pass1 = ui.getText(passwordBox);
   passwordBox = ui.find(mainPanel, "password2");
   String pass2 = ui.getText(passwordBox);
   if (pass1.equals(pass2)) {
     if (PasswordUtils.passwordMeetsRequirements(pass1)) {
       user.setPassword(pass1);
       userDao.updateUser(user);
       if (numberOfSecurityQuestions(user) < settings.getRequiredQuestionsRange().value()) {
         changeModeNewQuestions();
       } else {
         resetSoft();
         Object label = ui.find(mainPanel, "multiLabel");
         ui.setText(label, getI18NString("password.new.use"));
       }
     } else {
       displayWarningMessage("password.new.warning.criteria");
     }
   } else {
     displayWarningMessage("password.new.warning.match");
   }
 }
  @Override
  public List<CsvValidationException> validate(CSVReader reader) {
    int lineNumber = 0;
    String[] currLine;
    List<CsvValidationException> exceptions = new ArrayList<CsvValidationException>();
    try {
      while ((currLine = reader.readNext()) != null) {
        if (currLine.length != fields.size() + 1) {
          exceptions.add(
              new CsvValidationException(
                  lineNumber, getI18NString("medic.importer.column.mismatch.error")));
        }
        // determine the submitter of the form
        List<CommunityHealthWorker> chws = chwDao.getCommunityHealthWorkerByName(currLine[0], -1);
        if (chws.size() != 1) {
          List<User> users = userDao.getUsersByName(currLine[0], -1);
          if (users.size() != 1) {
            List<User> usernames = userDao.findUsersByUsername(currLine[0]);
            if (usernames.size() != 1) {
              try {
                long id = Long.parseLong(currLine[0]);
                CommunityHealthWorker chwById = chwDao.getCommunityHealthWorkerById(id);
                if (chwById == null) {
                  User userById = userDao.getUsersById(id);
                  if (userById == null) {
                    exceptions.add(
                        new CsvValidationException(
                            lineNumber,
                            getI18NString("medic.importer.unknown.submitter.error")
                                + " \""
                                + currLine[0]
                                + "\""));
                  }
                }
              } catch (Exception e) {
                exceptions.add(
                    new CsvValidationException(
                        lineNumber,
                        getI18NString("medic.importer.unknown.submitter.error")
                            + " \""
                            + currLine[0]
                            + "\""));
              }
            }
          }
        }

        String name = null;
        String id = null;
        String birthdate = null;
        for (int i = 1; i < fields.size(); i++) {
          MedicFormField field = fields.get(i - 1);
          // check for mappings
          if (field.getMapping() == PatientFieldMapping.NAMEFIELD) {
            name = currLine[i];
          } else if (field.getMapping() == PatientFieldMapping.BIRTHDATEFIELD) {
            birthdate = currLine[i];
          } else if (field.getMapping() == PatientFieldMapping.IDFIELD) {
            id = currLine[i];
          }

          if (field.getDatatype() == DataType.DATE_FIELD) {
            validateDate(currLine[i], lineNumber, exceptions);
          } else if (field.getDatatype() == DataType.POSITIVENEGATIVE
              || field.getDatatype() == DataType.TRUEFALSE
              || field.getDatatype() == DataType.YESNO
              || field.getDatatype() == DataType.CHECK_BOX) {
            validateBoolean(currLine[i], lineNumber, exceptions);
          } else {
            validateString(currLine[i], lineNumber, exceptions);
          }
        }
        Patient p = patientDao.getPatient(name, birthdate, id);
        if (p == null) {
          exceptions.add(
              new CsvValidationException(
                  lineNumber, getI18NString("medic.importer.unknown.subject.error")));
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    return exceptions;
  }