Search in sources :

Example 1 with CredentialsPolicyType

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;
}
Also used : SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType)

Example 2 with CredentialsPolicyType

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;
}
Also used : PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)

Example 3 with CredentialsPolicyType

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);
        }
    }
}
Also used : PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) PasswordCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) SecurityQuestionsCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)

Example 4 with CredentialsPolicyType

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;
    }
}
Also used : SecurityQuestionsCredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType) SecurityQuestionAnswerDTO(com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType) Protector(com.evolveum.midpoint.prism.crypto.Protector)

Example 5 with CredentialsPolicyType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityQuestionDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionDefinitionType) Form(org.apache.wicket.markup.html.form.Form) SecurityQuestionAnswerDTO(com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO) MyPasswordQuestionsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) RestartResponseException(org.apache.wicket.RestartResponseException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException)

Aggregations

CredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType)6 NonceCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType)3 SecurityQuestionsCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SecurityQuestionAnswerDTO (com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO)2 PasswordCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType)2 SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)2 ArrayList (java.util.ArrayList)2 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 Protector (com.evolveum.midpoint.prism.crypto.Protector)1 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)1 Task (com.evolveum.midpoint.task.api.Task)1 MyPasswordQuestionsPanel (com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel)1 CredentialPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialPolicyType)1 CredentialsStorageMethodType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageMethodType)1 CredentialsStorageTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1