Пример #1
0
 /**
  * The callback method for users creating new security questions.
  *
  * @throws GeneralSecurityException if the crypto libray cannot be loaded
  */
 public void attemptSaveQuestions() throws GeneralSecurityException {
   // TODO: error handling
   if (questions == null || answers == null) {
     ui.createDialog(getI18NString("password.new.warning"));
     return;
   }
   for (int i = 0; i < questions.length; i++) {
     String q = ui.getText(questions[i]);
     String a = ui.getText(answers[i]);
     if (q != null && !q.equals("") && a != null && !a.equals("")) {
       // delete the question if it is alreay there
       saveQuestion(q, a, user);
     }
   }
   int count = numberOfSecurityQuestions(user);
   int requiredQuestions = settings.getRequiredQuestionsRange().value();
   if (count < requiredQuestions) {
     Object label = ui.find(mainPanel, MULTI_LABEL);
     String text;
     if (count == 1) {
       text = getI18NString(QUESTION_ON_FILE);
     } else {
       text = getI18NString(QUESTIONS_ON_FILE);
       text = text.replaceAll("<X>", "" + count);
     }
     int req = requiredQuestions - count;
     text = text.replaceFirst("<Y>", "" + req);
     ui.setText(label, text);
   } else {
     answers = null;
     questions = null;
     changeModePatientView();
   }
 }
Пример #2
0
 public void selectionChanged() {
   currentForm =
       (MedicForm) uiController.getAttachedObject(uiController.getSelectedItem(resultsList));
   if (delegate != null) {
     delegate.selectionChanged(currentForm);
   }
 }
Пример #3
0
 /** Resets the login screen, but preserves the username, if one was entered. */
 public void resetSoft() {
   reset();
   if (user != null) {
     Object usernameField = ui.find(mainPanel, "usernameField");
     ui.setText(usernameField, user.getUsername());
     ui.setFocus(ui.find(mainPanel, "passwordField"));
   }
 }
Пример #4
0
 protected void setResults(List<MedicForm> results) {
   this.results = results;
   uiController.removeAll(resultsList);
   for (MedicForm mf : results) {
     uiController.add(resultsList, uiController.createListItem(mf.getName(), mf));
   }
   uiController.setSelectedIndex(resultsList, 0);
   selectionChanged();
 }
Пример #5
0
 /** Resets the login screen back to its initial state. */
 public void reset() {
   UserSessionManager.getUserSessionManager().logout();
   user = null;
   Object landingScreen = ui.loadComponentFromFile(XML_LOGIN, this);
   Object usernameField = ui.find(landingScreen, "usernameField");
   ui.removeAll(mainPanel);
   ui.add(mainPanel, landingScreen);
   ui.setFocus(usernameField);
 }
Пример #6
0
 protected Object createQuestionComboBox() {
   Object question = Thinlet.create(Thinlet.COMBOBOX);
   for (int j = 1; j <= 4; j++) {
     Object choice = ui.createComboboxChoice(getI18NString(QUESTION + "." + j), null);
     ui.add(question, choice);
   }
   ui.setText(question, getI18NString(QUESTION_DEFAULT));
   ui.setColspan(question, 2);
   ui.setWeight(question, 1, 1);
   return question;
 }
Пример #7
0
 public FormSearchArea(
     UiGeneratorController uiController,
     ApplicationContext appCon,
     SearchAreaDelegate<MedicForm> delegate) {
   this.uiController = uiController;
   mainPanel = uiController.loadComponentFromFile(SEARCH_AREA_XML, this);
   resultsList = uiController.find(mainPanel, "formList");
   formDao = (MedicFormDao) appCon.getBean("MedicFormDao");
   this.delegate = delegate;
   textChanged("");
 }
Пример #8
0
 public LoginScreen(
     UiGeneratorController uiController,
     PatientViewThinletTabController tabController,
     ApplicationContext appCon) {
   this.tabController = tabController;
   this.ui = uiController;
   userDao = (UserDao) appCon.getBean("UserDao");
   questionDao = (SecurityQuestionDao) appCon.getBean("SecurityQuestionDao");
   settings = SecurityOptions.getInstance();
   mainPanel = ui.createPanel("");
   ui.setWeight(mainPanel, 1, 1);
   reset();
 }
Пример #9
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);
   }
 }
  public KeywordTabHandler(UiGeneratorController ui) {
    super(ui, true);

    FrontlineSMS frontlineController = ui.getFrontlineController();
    this.keywordDao = frontlineController.getKeywordDao();
    this.groupDao = frontlineController.getGroupDao();
    this.keywordActionDao = frontlineController.getKeywordActionDao();
  }
  /**
   * Helps create a Thinlet node for a section
   *
   * @param isRootNode
   * @param title
   * @param attachedObject
   * @param iconPath
   * @return
   */
  protected Object createSectionNode(
      String title, UiSettingsSectionHandler attachedObject, String iconPath) {
    Object sectionRootNode = ui.createNode(title, attachedObject);

    // Try to get an icon from the classpath
    this.ui.setIcon(sectionRootNode, iconPath);

    return sectionRootNode;
  }
Пример #12
0
 /** The callback method for when a user preses a login button in this screen. */
 public void attemptLogin() {
   Object usernameField = ui.find(mainPanel, "usernameField");
   Object passwordField = ui.find(mainPanel, "passwordField");
   String username = ui.getText(usernameField);
   String password = ui.getText(passwordField);
   UserSessionManager manager = UserSessionManager.getUserSessionManager();
   AuthenticationResult result = manager.login(username, password);
   if (result == AuthenticationResult.NOSUCHUSER || result == AuthenticationResult.WRONGPASSWORD) {
     displayWarningMessage(INCORRECT_LOGIN_MESSAGE);
   }
   if (result == AuthenticationResult.SUCCESS) {
     user = manager.getCurrentUser();
     if (user.needsNewPassword()) {
       changeModeNewPassword();
     } else if (numberOfSecurityQuestions(user) < settings.getRequiredQuestionsRange().value()) {
       changeModeNewQuestions();
     } else {
       changeModePatientView();
     }
   }
 }
Пример #13
0
 /**
  * The callback function for when a user attempts to recover their security questions by answering
  * their security questions.
  *
  * @throws GeneralSecurityException
  */
 public void attemptRecoverPassword() throws GeneralSecurityException {
   // TODO: error handling
   int correct = 0;
   for (int i = 0; i < questions.length; i++) {
     String a = ui.getText(answers[i]);
     // find the SecurityQuestion object that corrosponds to the string
     SecurityQuestion sq = ui.getAttachedObject(questions[i], SecurityQuestion.class);
     if (sq.verifyAnswer(a)) {
       correct++;
     }
   }
   System.out.println(correct);
   if (correct >= settings.getRequiredAnswersRange().value()) {
     changeModeNewPassword();
   } else {
     Object label = ui.find(mainPanel, MULTI_LABEL);
     String text = getI18NString("password.reset.wrong.answer");
     // text = text.replaceFirst("<X>", "" );
     ui.setText(label, text);
   }
 }
Пример #14
0
 /** Transforms the login screen into a dialog for inputting a new password. */
 protected void changeModeNewPassword() {
   Object passwordScreen = ui.loadComponentFromFile(XML_NEW_PASSWORD, this);
   Object notice = ui.find(passwordScreen, "noticeTextArea");
   String text = getI18NString("password.new.notice");
   text +=
       "\n -" + settings.getPasswordLength() + " " + getI18NString("admin.security.pass.length");
   if (settings.isCaseRequired()) {
     text += "\n -" + getI18NString("admin.security.pass.letters");
   }
   if (settings.isNumberRequired()) {
     text += "\n -" + getI18NString("admin.security.pass.numbers");
   }
   if (settings.isSymbolRequired()) {
     text += "\n -" + getI18NString("admin.security.pass.symbols");
   }
   ui.setText(notice, text);
   Object passwordBox = ui.find(passwordScreen, "passwordBox1");
   ui.removeAll(mainPanel);
   ui.add(mainPanel, passwordScreen);
   ui.setFocus(passwordBox);
 }
Пример #15
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");
   }
 }
 public SettingsDeviceSectionHandler(UiGeneratorController ui, SmsModemSettings deviceSettings) {
   super(ui);
   this.smsModemSettingsDao = ui.getFrontlineController().getSmsModemSettingsDao();
   this.setDeviceSettings(deviceSettings);
 }
Пример #17
0
 public MedicForm getCurrentlySelectedForm() {
   return (MedicForm) uiController.getAttachedObject(uiController.getSelectedItem(resultsList));
 }
Пример #18
0
  /** Transforms the login screen into a dialog for inputing security questions. */
  protected void changeModeNewQuestions() {
    // components that are worked with
    Object questionScreen = ui.loadComponentFromFile(XML_QUESTIONS, this);
    Object questionPanel = ui.find(questionScreen, "questionCreationPanel");
    Object multiLabel = ui.find(questionPanel, MULTI_LABEL);
    // set the text describing how many questions are needed
    String text;
    int num = numberOfSecurityQuestions(user);
    if (num == 1) {
      text = getI18NString(QUESTION_ON_FILE);
    } else {
      text = getI18NString(QUESTIONS_ON_FILE);
      text = text.replaceFirst("<X>", "" + num);
    }
    int required = settings.getRequiredQuestionsRange().value() - num;
    text = text.replaceFirst("<Y>", "" + required);
    ui.setText(multiLabel, text);

    // create the panel
    ui.removeAll(questionPanel);
    ui.add(questionPanel, multiLabel);
    questions = new Object[required];
    answers = new Object[required];
    for (int i = 0; i < required; i++) {
      questions[i] = createQuestionComboBox();
      ui.add(questionPanel, questions[i]);
      answers[i] = ui.createTextfield("", "");
      ui.setColspan(answers[i], 2);
      ui.add(questionPanel, answers[i]);
    }

    ui.removeAll(mainPanel);
    ui.add(mainPanel, questionScreen);
    ui.setFocus(questions[0]);
  }
Пример #19
0
 /** The mode that lets a user answer their security questions to generate a new password. */
 protected void changeModeRecoverPassword() {
   List<SecurityQuestion> userQuestions = questionDao.getSecurityQuestionsForUser(user);
   if (userQuestions.size() < settings.getRequiredAnswersRange().value()) {
     displayWarningMessage("password.new.no.questions");
     return;
   }
   Object recoverPanel = ui.loadComponentFromFile(XML_RECOVER_PASSWORD, this);
   Object questionsPanel = ui.find(recoverPanel, "questionsPanel");
   Object multiLabel = ui.find(questionsPanel, MULTI_LABEL);
   ui.removeAll(questionsPanel);
   ui.add(questionsPanel, multiLabel);
   questions = new Object[settings.getRequiredQuestionsRange().value()];
   answers = new Object[settings.getRequiredQuestionsRange().value()];
   for (int i = 0; i < questions.length; i++) {
     SecurityQuestion sq = userQuestions.get(i);
     questions[i] = ui.createLabel(sq.getQuestion());
     ui.setAttachedObject(questions[i], sq);
     ui.add(questionsPanel, questions[i]);
     answers[i] = ui.createTextfield("", "");
     ui.add(questionsPanel, answers[i]);
   }
   ui.removeAll(mainPanel);
   ui.add(mainPanel, recoverPanel);
   ui.setFocus(answers[0]);
 }
Пример #20
0
 /**
  * Displays a warning message in red text in the label above the username box.
  *
  * @param key the i18n key of the message to be displayed
  */
 protected void displayWarningMessage(String key) {
   Object label = ui.find(mainPanel, MULTI_LABEL);
   ui.setColor(label, Thinlet.FOREGROUND, Color.RED);
   ui.setText(label, getI18NString(key));
   ui.setFocus(ui.find(mainPanel, "usernameField"));
 }