Skip to content

Commit

Permalink
MID-2604 is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 28, 2015
1 parent 641bb64 commit 967552d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
Expand Up @@ -139,39 +139,38 @@ private PasswordQuestionsDto loadPageModel() {

public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObject<UserType> user){
LOGGER.debug("Security Questions Loading for user: "+ user.getOid());
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.logException(LOGGER, "Couldn't decrypt user answer", e);

}
}
//LOGGER.debug("SecAnswerIdentifier:"+securityQuestionAnswerType.getQuestionIdentifier());
secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}

return secQuestAnswListDTO;
}
else{
return null;
}

}
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.logException(LOGGER, "Couldn't decrypt user answer", e);

}
}
//LOGGER.debug("SecAnswerIdentifier:"+securityQuestionAnswerType.getQuestionIdentifier());
secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}

return secQuestAnswListDTO;
}
}
return null;
}


public void initLayout(){
Expand Down
Expand Up @@ -385,22 +385,24 @@ private void savePerformed(AjaxRequestTarget target) {
MyPasswordQuestionsPanel type = (MyPasswordQuestionsPanel) iterator.next();

List<SecurityQuestionAnswerDTO> userQuestionList = model.getObject().getSecurityAnswers();
for (Iterator iterator2 = userQuestionList.iterator(); iterator2.hasNext();) {
SecurityQuestionAnswerDTO securityQuestionAnswerDTO = (SecurityQuestionAnswerDTO) iterator2
.next();
// TODO do this in a proper way, what is this.
String results = StringEscapeUtils.unescapeHtml((type
.get(MyPasswordQuestionsPanel.F_QUESTION)).getDefaultModelObjectAsString());
if (getQuestionIdentifierFromQuestion(results).trim().equalsIgnoreCase(
securityQuestionAnswerDTO.getPwdQuestion().trim())) {

if (((TextField<String>) type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject()
.equalsIgnoreCase(securityQuestionAnswerDTO.getPwdAnswer())) {
correctAnswers++;
}
}

}
if (userQuestionList != null) {
for (Iterator iterator2 = userQuestionList.iterator(); iterator2.hasNext(); ) {
SecurityQuestionAnswerDTO securityQuestionAnswerDTO = (SecurityQuestionAnswerDTO) iterator2
.next();
// TODO do this in a proper way, what is this.
String results = StringEscapeUtils.unescapeHtml((type
.get(MyPasswordQuestionsPanel.F_QUESTION)).getDefaultModelObjectAsString());
if (getQuestionIdentifierFromQuestion(results).trim().equalsIgnoreCase(
securityQuestionAnswerDTO.getPwdQuestion().trim())) {

if (((TextField<String>) type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject()
.equalsIgnoreCase(securityQuestionAnswerDTO.getPwdAnswer())) {
correctAnswers++;
}
}

}
}

}

Expand Down

0 comments on commit 967552d

Please sign in to comment.