/** * 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(); } }