use of com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO in project midpoint by Evolveum.
the class SecurityQuestionsPanel method createUsersSecurityQuestionsList.
public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObject<UserType> user) {
LOGGER.debug("Security Questions Loading for user: " + user.getOid());
if (user.asObjectable().getCredentials() != null && user.asObjectable().getCredentials().getSecurityQuestions() != null) {
List<SecurityQuestionAnswerType> secQuestAnsList = user.asObjectable().getCredentials().getSecurityQuestions().getQuestionAnswer();
if (secQuestAnsList != null) {
LOGGER.debug("User SecurityQuestion ANswer List is Not null");
List<SecurityQuestionAnswerDTO> secQuestAnswListDTO = new ArrayList<>();
for (SecurityQuestionAnswerType securityQuestionAnswerType : secQuestAnsList) {
Protector protector = getPrismContext().getDefaultProtector();
String decoded = "";
if (securityQuestionAnswerType.getQuestionAnswer().getEncryptedDataType() != null) {
try {
decoded = protector.decryptString(securityQuestionAnswerType.getQuestionAnswer());
} catch (EncryptionException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't decrypt user answer", e);
}
}
secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}
return secQuestAnswListDTO;
}
}
return null;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO in project midpoint by Evolveum.
the class PageMyPasswordQuestions method executePasswordQuestionsAndAnswers.
/**
* method for get existing questions and answer from user credentials
* @author oguzhan
* @param userQuestionList
* @param policyQuestionList
* @param panelNumber
*/
public void executePasswordQuestionsAndAnswers(List<SecurityQuestionAnswerDTO> userQuestionList, List<SecurityQuestionDefinitionType> policyQuestionList, int panelNumber) {
int userQuest = 0;
LOGGER.debug("executePasswordQuestionsAndAnswers");
for (Iterator iterator = policyQuestionList.iterator(); iterator.hasNext(); ) {
/* Loop for finding the Existing Questions
* and Answers according to Policy*/
SecurityQuestionDefinitionType securityQuestionDefinitionType = (SecurityQuestionDefinitionType) iterator.next();
//user's question List loop to match the questions
for (int i = userQuest; i < userQuestionList.size(); i++) {
if (userQuestionList.get(i).getPwdQuestion().trim().compareTo(securityQuestionDefinitionType.getIdentifier().trim()) == 0) {
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(userQuestionList.get(i).getPwdQuestion(), userQuestionList.get(i).getPwdAnswer(), userQuestionList.get(i).getQuestionItself());
a = checkIfQuestionisValidSingle(a, securityQuestionDefinitionType);
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
pqPanels.add(panel);
panelNumber++;
userQuest++;
break;
} else if (userQuestionList.get(i).getPwdQuestion().trim().compareTo(securityQuestionDefinitionType.getIdentifier().trim()) != 0) {
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(policyQuestionList.get(panelNumber).getIdentifier(), "", policyQuestionList.get(panelNumber).getQuestionText());
a.setQuestionItself(securityQuestionDefinitionType.getQuestionText());
userQuestionList.get(i).setPwdQuestion(securityQuestionDefinitionType.getIdentifier().trim());
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
pqPanels.add(panel);
panelNumber++;
userQuest++;
break;
}
}
}
}
use of com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO in project midpoint by Evolveum.
the class PageMyPasswordQuestions method initLayout.
public void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
//question panel list
pqPanels = new ArrayList<MyPasswordQuestionsPanel>();
OperationResult result = new OperationResult(OPERATION_LOAD_QUESTION_POLICY);
try {
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_QUESTION_POLICY);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_QUESTION_POLICY);
try {
//PrismObject<SystemConfigurationType> config = getPageBase().getModelService().getObject(
// SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null,
//task, result);
CredentialsPolicyType credPolicy = getModelInteractionService().getCredentialsPolicy(null, null, result);
//Global Policy set question numbers
if (credPolicy != null && credPolicy.getSecurityQuestions() != null) {
questionNumber = credPolicy.getSecurityQuestions().getQuestionNumber();
// Actual Policy Question List
policyQuestionList = credPolicy.getSecurityQuestions().getQuestion();
} else {
questionNumber = 0;
policyQuestionList = new ArrayList<SecurityQuestionDefinitionType>();
}
} catch (Exception ex) {
ex.printStackTrace();
/* List<SecurityQuestionAnswerDTO> userQuestionList= model.getObject().getSecurityAnswers();
int panelNumber=0;
PrismObject<UserType> user = null;
Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS,
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
Task taskTwo = createSimpleTask("LOAD USER WRAPPER");
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, taskTwo, result);
OperationResult parentResult = new OperationResult(OPERATION_LOAD_QUESTION_POLICY);
questionNumber = getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestionNumber();
policyQuestionList=getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestion();
if(userQuestionList==null){
executeAddingQuestions(questionNumber, 0, policyQuestionList);
LOGGER.info(getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestionNumber().toString());
}else{
for(int userQuestint=0;userQuestint<userQuestionList.size();userQuestint++){
SecurityQuestionAnswerDTO answerDTO= checkIfQuestionisValid(userQuestionList.get(userQuestint), policyQuestionList);
if (userQuestionList.get(userQuestint)!=null){
LOGGER.debug("Questitself"+userQuestionList.get(userQuestint).getQuestionItself());
MyPasswordQuestionsPanel panel=new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL+ panelNumber,userQuestionList.get(userQuestint));
pqPanels.add(panel);
panelNumber++;
}
}
//TODO same questions check should be implemented
}
add(mainForm);
mainForm.add(getPanels(pqPanels));
initButtons(mainForm);
return;
*/
}
/*User's Pre-Set Question List*/
List<SecurityQuestionAnswerDTO> userQuestionList = model.getObject().getSecurityAnswers();
//Case that policy have more than users's number of numbers
if ((userQuestionList == null) || (questionNumber > userQuestionList.size())) {
if (userQuestionList == null) {
executeAddingQuestions(questionNumber, 0, policyQuestionList);
//TODO same questions check should be implemented
} else {
executePasswordQuestionsAndAnswers(userQuestionList, policyQuestionList, userQuestionList.size());
//QUESTION NUMBER BIGGER THAN QUESTION LIST
//rest of the questions
int difference = questionNumber - userQuestionList.size();
executeAddingQuestions(difference, userQuestionList.size(), policyQuestionList);
}
} else if (questionNumber == userQuestionList.size()) {
//QUESTION NUMBER EQUALS TO QUESTION LIST
executePasswordQuestionsAndAnswers(userQuestionList, policyQuestionList, 0);
//TODO PART2: Case that policy have smaller than users's number of numbers
} else if (questionNumber < userQuestionList.size()) {
//QUESTION NUMBER SMALLER THAN QUESTION LIST
executePasswordQuestionsAndAnswers(userQuestionList, policyQuestionList, 0);
//this part will be using at remove operation in the future
/* int diff = userQuestionList.size()-questionNumber;
for(Iterator iterator = userQuestionList.iterator(); iterator.hasNext();){
SecurityQuestionAnswerDTO element = (SecurityQuestionAnswerDTO)iterator.next();
for(int i=0; i<diff;i++){
if(element == userQuestionList.get(questionNumber+i)){
try{
//LOGGER.info("REMOVE");
iterator.remove();
} catch (UnsupportedOperationException uoe) {
LOGGER.info(uoe.getStackTrace().toString());
}
}
}
}*/
}
} catch (Exception ex) {
result.recordFatalError("Couldn't load system configuration.", ex);
}
add(mainForm);
mainForm.add(getPanels(pqPanels));
initButtons(mainForm);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO in project midpoint by Evolveum.
the class PageMyPasswordQuestions method executeAddingQuestions.
/**
* method for adding questions to user credentials
* @author oguzhan
* @param questionNumber
* @param panelNumber
* @param policyQuestionList
*/
public void executeAddingQuestions(int questionNumber, int panelNumber, List<SecurityQuestionDefinitionType> policyQuestionList) {
LOGGER.debug("executeAddingQuestions");
for (int i = 0; i < questionNumber; i++) {
//LOGGER.info("\n\n Adding panel element");
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(policyQuestionList.get(panelNumber).getIdentifier(), "", policyQuestionList.get(panelNumber).getQuestionText());
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
pqPanels.add(panel);
panelNumber++;
}
}
use of com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO in project midpoint by Evolveum.
the class PageMyPasswordQuestions method createUsersSecurityQuestionsList.
public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObject<UserType> user) {
LOGGER.debug("Security Questions Loading for user: " + user.getOid());
if (user.asObjectable().getCredentials() != null && user.asObjectable().getCredentials().getSecurityQuestions() != null) {
List<SecurityQuestionAnswerType> secQuestAnsList = user.asObjectable().getCredentials().getSecurityQuestions().getQuestionAnswer();
if (secQuestAnsList != null) {
LOGGER.debug("User SecurityQuestion ANswer List is Not null");
List<SecurityQuestionAnswerDTO> secQuestAnswListDTO = new ArrayList<SecurityQuestionAnswerDTO>();
for (Iterator iterator = secQuestAnsList.iterator(); iterator.hasNext(); ) {
SecurityQuestionAnswerType securityQuestionAnswerType = (SecurityQuestionAnswerType) iterator.next();
Protector protector = getPrismContext().getDefaultProtector();
String decoded = "";
if (securityQuestionAnswerType.getQuestionAnswer().getEncryptedDataType() != null) {
try {
decoded = protector.decryptString(securityQuestionAnswerType.getQuestionAnswer());
} catch (EncryptionException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't decrypt user answer", e);
}
}
//LOGGER.debug("SecAnswerIdentifier:"+securityQuestionAnswerType.getQuestionIdentifier());
secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}
return secQuestAnswListDTO;
}
}
return null;
}
Aggregations