Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabria committed Jun 4, 2015
2 parents 2f3dd1c + 431df4b commit afa97b6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 98 deletions.
Expand Up @@ -22,31 +22,34 @@
<title>Insert title here</title>
</head>
<body>
<wicket:extend>
<form wicket:id="mainForm" class="form-horizontal">
<wicket:extend>

<div wicket:container wicket:id="pwdQuestionsPanel">
<div wicket:container wicket:id="questionAnswerPanel"></div>
</div>
<div class="main-button-bar">
<span class="button-group">
<a class="btn btn-default" wicket:id="back" />
</span>
<a class="btn btn-primary" wicket:id="save"/>
</div>


<!-- <div wicket:id="panelRepeater">
<div wicket:id="pwdQuestionsPanel"></div>
</div> -->
<!-- <div class="main-button-bar">
<span class="button-group">
<a class="btn btn-default" wicket:id="back" />
</span>
<a class="btn btn-primary" wicket:id="save"/>
</div> -->

</form>
</wicket:extend>
</body>
<div class="row">
<div class="col-md-offset-2 col-md-8 col-lg-offset-4 col-lg-4">
<div class="panel panel-default" style="margin-top: 120px;">
<div class="panel-body">
<form wicket:id="mainForm" class="form-horizontal">
<div class="form-group">
<div class="col-md-10 col-lg-10 control-label">
<div wicket:container wicket:id="pwdQuestionsPanel">
<div class="col-md-12 col-lg-12">
<div wicket:container wicket:id="questionAnswerPanel"></div>
</div>
</div>
<div class="col-md-10 col-lg-10">
<div class="main-button-bar">
<span class="button-group"> <a class="btn btn-default"
wicket:id="back" />
</span> <a class="btn btn-primary" wicket:id="save" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</wicket:extend>
</body>
</html>
Expand Up @@ -108,13 +108,10 @@ public class PageMyPasswordQuestions extends PageAdminHome {
public PageMyPasswordQuestions() {



model = new LoadableModel<PasswordQuestionsDto>(false) {

private static final long serialVersionUID = 1L;




@Override
protected PasswordQuestionsDto load() {
return loadPageModel();
Expand All @@ -138,8 +135,6 @@ protected ObjectWrapper load() {





private PasswordQuestionsDto loadPageModel() {
LOGGER.debug("Loading user for Security Question Page.");

Expand All @@ -158,11 +153,6 @@ private PasswordQuestionsDto loadPageModel() {

subResult.recordSuccessIfUnknown();






}
catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Couldn't load accounts", ex);
Expand All @@ -171,7 +161,6 @@ private PasswordQuestionsDto loadPageModel() {
result.recomputeStatus();
}
return dto;

}

public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObject<UserType> user){
Expand All @@ -196,21 +185,15 @@ public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObj
e.printStackTrace();
}
}


secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}



return secQuestAnswListDTO;

}
else{
return null;
}


}


Expand All @@ -236,14 +219,12 @@ public void initLayout(){
//Global Policy set question numbers
questionNumber=securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestionNumber();

//LOGGER.info("****************Policy QuestionNumber************** :"+questionNumber);

// Actual Policy Question List
policyQuestionList = securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestion();

}catch(Exception ex){

LOGGER.info("\n\nAccess");
//LOGGER.info("\n\nAccess");
List<SecurityQuestionAnswerDTO> userQuestionList= model.getObject().getSecurityAnswers();
int panelNumber=0;
PrismObject<UserType> user = null;
Expand All @@ -261,19 +242,11 @@ public void initLayout(){
policyQuestionList=getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestion();
if(userQuestionList==null){

for(int i=0;i<questionNumber;i++){
// System.out.println("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++;
}

executeAddingQuestions(questionNumber, 0, policyQuestionList);

LOGGER.info(getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestionNumber().toString());
//TODO Warn user

}else{
//LOGGER.info("\n\nFIRST Else AT CATCH");
for(int userQuestint=0;userQuestint<userQuestionList.size();userQuestint++){
SecurityQuestionAnswerDTO answerDTO= checkIfQuestionisValid(userQuestionList.get(userQuestint), policyQuestionList);
if (userQuestionList.get(userQuestint)!=null){
Expand All @@ -284,7 +257,6 @@ public void initLayout(){
}

}
//rest of the questions
//TODO same questions check should be implemented

}
Expand Down Expand Up @@ -326,22 +298,25 @@ public void initLayout(){

//QUESTION NUMBER SMALLER THAN QUESTION LIST
executePasswordQuestionsAndAnswers(userQuestionList, policyQuestionList, 0);
int diff = userQuestionList.size()-questionNumber;


//this part will be using at remove operation in the future
/* int diff = userQuestionList.size()-questionNumber;
for(Iterator iterator = userQuestionList.iterator(); iterator.hasNext();){
SecurityQuestionAnswerDTO remove = (SecurityQuestionAnswerDTO)iterator.next();
SecurityQuestionAnswerDTO element = (SecurityQuestionAnswerDTO)iterator.next();
for(int i=0; i<diff;i++){
if(remove == userQuestionList.get(questionNumber+i)){
LOGGER.info("\n\n ***REMOVE");
if(element == userQuestionList.get(questionNumber+i)){
try{
//LOGGER.info("REMOVE");
iterator.remove();
} catch (UnsupportedOperationException uoe) {
LOGGER.info(uoe.getStackTrace().toString());
}
}
}
}
}*/
}

} catch (Exception ex) {
Expand Down Expand Up @@ -530,8 +505,6 @@ private ObjectWrapper loadUserWrapper(PrismObject<UserType> userToEdit) {
return wrapper;
}

//TODO remove securityQuestionList

private SecurityQuestionAnswerDTO checkIfQuestionisValid(SecurityQuestionAnswerDTO questionIdentifier,List<SecurityQuestionDefinitionType> securityQuestionList){


Expand All @@ -542,34 +515,27 @@ private SecurityQuestionAnswerDTO checkIfQuestionisValid(SecurityQuestionAnswerD

if(securityQuestionDefinitionType.getIdentifier().trim().compareTo(questionIdentifier.getPwdQuestion().trim())==0){
questionIdentifier.setQuestionItself(securityQuestionDefinitionType.getQuestionText());
// System.out.println("Check&SetQuestion: "+questionIdentifier.getQuestionItself());
// x=true;
LOGGER.info("\n\n: TRUE QUESTION");

//LOGGER.info("\n\n: TRUE QUESTION");
return questionIdentifier;
}else{
LOGGER.info("\n\n: DIFFERENT QUESTION");
//questionIdentifier.setQuestionItself("aa");
return null;
}


}
LOGGER.info("\n\n: wrong quest ident");
// questionIdentifier.setQuestionItself("aa");

return null;
}

private SecurityQuestionAnswerDTO checkIfQuestionisValidSingle(SecurityQuestionAnswerDTO questionIdentifier,SecurityQuestionDefinitionType securityQuestion){

if(securityQuestion.getIdentifier().trim().compareTo(questionIdentifier.getPwdQuestion().trim())==0){
questionIdentifier.setQuestionItself(securityQuestion.getQuestionText());
// System.out.println("Check&SetQuestion: "+questionIdentifier.getQuestionItself());
// x=true;
LOGGER.info("\n\n: TRUE QUESTION");

//LOGGER.info("\n\n: TRUE QUESTION");
return questionIdentifier;
}else{
LOGGER.info("\n\n: DIFFERENT QUESTION");
//questionIdentifier.setQuestionItself("aa");
return null;
}
}
Expand All @@ -582,13 +548,6 @@ private void updateQuestions(String useroid, AjaxRequestTarget target){
Task task = createSimpleTask(OPERATION_SAVE_QUESTIONS);
OperationResult result = new OperationResult(OPERATION_SAVE_QUESTIONS);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();


/*oguzhan:comment out unnecessary codes:
String newPassword="";
PageBase page = (PageBase) getPage();
*/

SecurityQuestionAnswerType[] answerTypeList=new SecurityQuestionAnswerType[questionNumber];

try {
Expand All @@ -598,16 +557,14 @@ private void updateQuestions(String useroid, AjaxRequestTarget target){

SecurityQuestionAnswerType answerType = new SecurityQuestionAnswerType();
ProtectedStringType answer = new ProtectedStringType();
// System.out.println("Answerrrrr:"+((TextField<String>)type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject());

answer.setClearValue(((TextField<String>)type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject());
answerType.setQuestionAnswer(answer);

answerType.setQuestionIdentifier(getQuestionIdentifierFromQuestion(((Label)type.get(MyPasswordQuestionsPanel.F_QUESTION)).getDefaultModelObjectAsString()));
answerTypeList[listnum]=answerType;
listnum++;
//oguzhan:


}

//if(answerTypeList.length !=)
Expand Down Expand Up @@ -651,18 +608,10 @@ private void updateQuestions(String useroid, AjaxRequestTarget target){
target.add(getFeedbackPanel());
} catch(Exception ex){



error(getString("message.error"));
target.add(getFeedbackPanel());
ex.printStackTrace();
}








}

private String getQuestionIdentifierFromQuestion(String questionItself){
Expand Down
2 changes: 1 addition & 1 deletion samples/objects/security-policy.xml
Expand Up @@ -23,7 +23,7 @@
<resetMethod>
<resetType>securityQuestions</resetType>
</resetMethod>
<questionNumber>3</questionNumber>
<questionNumber>2</questionNumber>
<question>
<identifier>http://midpoint.evolveum.com/xml/ns/public/security/question-2#q001</identifier>
<enabled>true</enabled>
Expand Down

0 comments on commit afa97b6

Please sign in to comment.