use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType in project midpoint by Evolveum.
the class CredentialsProcessor method transformFocusExectionDelta.
/**
* Called from ChangeExecutor. Will modify the execution deltas to hash or remove credentials if needed.
*/
public <O extends ObjectType> ObjectDelta<O> transformFocusExectionDelta(LensContext<O> context, ObjectDelta<O> focusDelta) throws SchemaException, EncryptionException {
LensFocusContext<O> focusContext = context.getFocusContext();
SecurityPolicyType securityPolicy = focusContext.getSecurityPolicy();
if (securityPolicy == null) {
return focusDelta;
}
CredentialsPolicyType credsType = securityPolicy.getCredentials();
if (credsType == null) {
return focusDelta;
}
ObjectDelta<O> transformedDelta = focusDelta.clone();
transformFocusExectionDeltaCredential(context, credsType, credsType.getPassword(), SchemaConstants.PATH_PASSWORD_VALUE, transformedDelta);
return transformedDelta;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType in project midpoint by Evolveum.
the class SecurityHelper method postProcessPasswordPolicy.
private SecurityPolicyType postProcessPasswordPolicy(ValuePolicyType passwordPolicyType) {
SecurityPolicyType securityPolicyType = new SecurityPolicyType();
CredentialsPolicyType creds = new CredentialsPolicyType();
PasswordCredentialsPolicyType passwd = new PasswordCredentialsPolicyType();
ObjectReferenceType passwordPolicyRef = new ObjectReferenceType();
passwordPolicyRef.asReferenceValue().setObject(passwordPolicyType.asPrismObject());
passwd.setValuePolicyRef(passwordPolicyRef);
creds.setPassword(passwd);
securityPolicyType.setCredentials(creds);
setDeprecatedPasswordPolicyProperties(passwordPolicyType, passwd);
return securityPolicyType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType in project midpoint by Evolveum.
the class SecurityHelper method postProcessSecurityPolicy.
private void postProcessSecurityPolicy(SecurityPolicyType securityPolicyType, Task task, OperationResult result) {
CredentialsPolicyType creds = securityPolicyType.getCredentials();
if (creds != null) {
PasswordCredentialsPolicyType passwd = creds.getPassword();
if (passwd != null) {
postProcessPasswordCredentialPolicy(securityPolicyType, passwd, task, result);
}
for (NonceCredentialsPolicyType nonce : creds.getNonce()) {
postProcessCredentialPolicy(securityPolicyType, nonce, "nonce credential policy", task, result);
}
SecurityQuestionsCredentialsPolicyType securityQuestions = creds.getSecurityQuestions();
if (securityQuestions != null) {
postProcessCredentialPolicy(securityPolicyType, securityQuestions, "security questions credential policy", task, result);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType in project midpoint by Evolveum.
the class PageSecurityQuestions method createUsersSecurityQuestionsList.
public List<SecurityQuestionAnswerDTO> createUsersSecurityQuestionsList(PrismObject<UserType> user) {
SecurityQuestionsCredentialsType credentialsPolicyType = user.asObjectable().getCredentials().getSecurityQuestions();
if (credentialsPolicyType == null) {
return null;
}
List<SecurityQuestionAnswerType> secQuestAnsList = credentialsPolicyType.getQuestionAnswer();
if (secQuestAnsList != 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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
secQuestAnswListDTO.add(new SecurityQuestionAnswerDTO(securityQuestionAnswerType.getQuestionIdentifier(), decoded));
}
return secQuestAnswListDTO;
} else {
return null;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType 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);
}
Aggregations