Search in sources :

Example 16 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.

the class RSecurityPolicy method toJAXB.

@Override
public SecurityPolicyType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    SecurityPolicyType object = new SecurityPolicyType();
    RUtil.revive(object, prismContext);
    RSecurityPolicy.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)

Example 17 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.

the class PageSecurityQuestions method initLayout.

public void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    pqPanels = new ArrayList<MyPasswordQuestionsPanel>();
    PrismObject<SecurityPolicyType> securityPolicy = getSecurityPolicy();
    LOGGER.trace("Found security policy: {}", securityPolicy);
    if (securityPolicy == null) {
        LOGGER.error("No security policy, cannot process security questions");
        // we do not want to provide any information to the attacker.
        throw new RestartResponseException(PageError.class);
    }
    questionNumber = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestionNumber() : 0;
    policyQuestionList = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestion() : new ArrayList<SecurityQuestionDefinitionType>();
    List<SecurityQuestionAnswerDTO> userQuestionList = model.getObject().getSecurityAnswers();
    if (userQuestionList == null) {
        getSession().error(getString("pageForgetPassword.message.ContactAdminQuestionsNotSet"));
        SecurityContext securityContext = SecurityContextHolder.getContext();
        securityContext.setAuthentication(null);
        throw new RestartResponseException(PageForgotPassword.class);
    }
    if (questionNumber <= userQuestionList.size()) {
        // Questions
        for (Iterator iterator = policyQuestionList.iterator(); iterator.hasNext(); ) {
            SecurityQuestionDefinitionType securityQuestionDefinitionType = (SecurityQuestionDefinitionType) iterator.next();
            // user's question List loop to match the questions
            for (int userQuestint = 0; userQuestint < userQuestionList.size(); userQuestint++) {
                // if the question is in the policy check
                int panelNumber = 0;
                if (userQuestionList.get(userQuestint).getPwdQuestion().equalsIgnoreCase(securityQuestionDefinitionType.getIdentifier())) {
                    SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(userQuestionList.get(userQuestint).getPwdQuestion(), "", userQuestionList.get(userQuestint).getQuestionItself());
                    a = checkIfQuestionisValid(a, policyQuestionList);
                    MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
                    pqPanels.add(panel);
                    panelNumber++;
                // This is the Question!
                }
            }
        }
    }
    add(mainForm);
    mainForm.add(getPanels(pqPanels));
    initButtons(mainForm);
}
Also used : SecurityQuestionDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionDefinitionType) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType) RestartResponseException(org.apache.wicket.RestartResponseException) SecurityQuestionAnswerDTO(com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO) SecurityContext(org.springframework.security.core.context.SecurityContext) Iterator(java.util.Iterator) MyPasswordQuestionsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel)

Example 18 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.

the class SystemConfigPanel method initLayout.

protected void initLayout() {
    ChooseTypePanel<ValuePolicyType> passPolicyChoosePanel = new ChooseTypePanel<ValuePolicyType>(ID_GLOBAL_PASSWORD_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<ValuePolicyType>>(getModel(), SystemConfigurationDto.F_PASSWORD_POLICY));
    ChooseTypePanel<SecurityPolicyType> securityPolicyChoosePanel = new ChooseTypePanel<SecurityPolicyType>(ID_GLOBAL_SECURITY_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<SecurityPolicyType>>(getModel(), SystemConfigurationDto.F_SECURITY_POLICY));
    add(passPolicyChoosePanel);
    add(securityPolicyChoosePanel);
    ObjectPolicyConfigurationEditor objectPolicyEditor = new ObjectPolicyConfigurationEditor(ID_OBJECT_POLICY_EDITOR, new PropertyModel<List<ObjectPolicyConfigurationTypeDto>>(getModel(), SystemConfigurationDto.F_OBJECT_POLICY_LIST));
    add(objectPolicyEditor);
    DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<>(ID_GLOBAL_AEP, new PropertyModel<AEPlevel>(getModel(), SystemConfigurationDto.F_AEP_LEVEL), WebComponentUtil.createReadonlyModelFromEnum(AEPlevel.class), new EnumChoiceRenderer<AEPlevel>(SystemConfigPanel.this));
    aepLevel.setOutputMarkupId(true);
    if (aepLevel.getModel().getObject() == null) {
        aepLevel.getModel().setObject(null);
    }
    aepLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(aepLevel);
    TextField<String> auditRecordsField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_AUDIT_CLEANUP));
    TextField<String> closedTasksField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_TASK_CLEANUP));
    add(auditRecordsField);
    add(closedTasksField);
    createTooltip(ID_CLEANUP_AUDIT_RECORDS_TOOLTIP);
    createTooltip(ID_CLEANUP_CLOSED_TASKS_TOOLTIP);
    CheckBox experimentalCodeCheck = WebComponentUtil.createAjaxCheckBox(ID_EXPERIMENTAL_CODE_CHECKBOX, new PropertyModel<Boolean>(getModel(), SystemConfigurationDto.F_ENABLE_EXPERIMENTAL_CODE));
    add(experimentalCodeCheck);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) AEPlevel(com.evolveum.midpoint.web.page.admin.configuration.dto.AEPlevel) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) List(java.util.List) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) ObjectPolicyConfigurationEditor(com.evolveum.midpoint.web.component.ObjectPolicyConfigurationEditor)

Example 19 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.

the class SecurityPolicyUtil method getAuthenticationPolicy.

public static AbstractAuthenticationPolicyType getAuthenticationPolicy(String authPolicyName, SecurityPolicyType securityPolicy) throws SchemaException {
    MailAuthenticationPolicyType mailAuthPolicy = getMailAuthenticationPolicy(authPolicyName, securityPolicy);
    SmsAuthenticationPolicyType smsAuthPolicy = getSmsAuthenticationPolicy(authPolicyName, securityPolicy);
    return checkAndGetAuthPolicyConsistence(mailAuthPolicy, smsAuthPolicy);
}
Also used : MailAuthenticationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailAuthenticationPolicyType) SmsAuthenticationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsAuthenticationPolicyType)

Example 20 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.

the class SecurityPolicyUtil method getCredentialPolicy.

public static NonceCredentialsPolicyType getCredentialPolicy(String policyName, SecurityPolicyType securityPolicy) throws SchemaException {
    CredentialsPolicyType credentialsPolicy = securityPolicy.getCredentials();
    if (credentialsPolicy == null) {
        return null;
    }
    List<NonceCredentialsPolicyType> noncePolicies = credentialsPolicy.getNonce();
    List<NonceCredentialsPolicyType> availableNoncePolicies = new ArrayList<>();
    for (NonceCredentialsPolicyType noncePolicy : noncePolicies) {
        if (noncePolicy.getName() == null && policyName == null) {
            availableNoncePolicies.add(noncePolicy);
        }
        if (noncePolicy.getName() == null && policyName != null) {
            continue;
        }
        if (noncePolicy.getName() != null && policyName == null) {
            continue;
        }
        if (noncePolicy.getName().equals(policyName)) {
            availableNoncePolicies.add(noncePolicy);
        }
    }
    if (availableNoncePolicies.size() > 1) {
        throw new SchemaException("Found more than one nonce credentials policy. Please review your configuration");
    }
    if (availableNoncePolicies.size() == 0) {
        return null;
    }
    return availableNoncePolicies.iterator().next();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType) ArrayList(java.util.ArrayList) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) NonceCredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType)

Aggregations

SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)13 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)6 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)5 CredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 MailAuthenticationPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.MailAuthenticationPolicyType)3 NonceCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.NonceCredentialsPolicyType)3 SecurityQuestionsCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsPolicyType)3 SmsAuthenticationPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SmsAuthenticationPolicyType)3 AbstractAuthenticationPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractAuthenticationPolicyType)2 PasswordCredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordCredentialsPolicyType)2 ArrayList (java.util.ArrayList)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 ObjectPolicyConfigurationEditor (com.evolveum.midpoint.web.component.ObjectPolicyConfigurationEditor)1 AEPlevel (com.evolveum.midpoint.web.page.admin.configuration.dto.AEPlevel)1 ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)1 MyPasswordQuestionsPanel (com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel)1