Search in sources :

Example 6 with SecurityPolicyType

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

the class SecurityHelper method locateSecurityPolicy.

/**
     * Returns security policy applicable for the specified user. It looks for organization and global policies and takes into account
     * deprecated properties and password policy references. The resulting security policy has all the (non-deprecated) properties set.
     * If there is also referenced value policy, it is will be stored as "object" in the value policy reference inside the
     * returned security policy.
     */
public <F extends FocusType> SecurityPolicyType locateSecurityPolicy(PrismObject<F> user, PrismObject<SystemConfigurationType> systemConfiguration, Task task, OperationResult result) throws SchemaException {
    PrismObject<SecurityPolicyType> orgSecurityPolicy = objectResolver.searchOrgTreeWidthFirstReference(user, o -> o.asObjectable().getSecurityPolicyRef(), "security policy", task, result);
    LOGGER.trace("Found organization security policy: {}", orgSecurityPolicy);
    if (orgSecurityPolicy != null) {
        SecurityPolicyType orgSecurityPolicyType = orgSecurityPolicy.asObjectable();
        postProcessSecurityPolicy(orgSecurityPolicyType, task, result);
        traceSecurityPolicy(orgSecurityPolicyType, user);
        return orgSecurityPolicyType;
    }
    if (systemConfiguration != null) {
        SecurityPolicyType globalSecurityPolicy = resolveGlobalSecurityPolicy(user, systemConfiguration.asObjectable(), task, result);
        if (globalSecurityPolicy != null) {
            return globalSecurityPolicy;
        }
    }
    // DEPRECATED, legacy
    PrismObject<ValuePolicyType> orgPasswordPolicy = objectResolver.searchOrgTreeWidthFirstReference(user, o -> o.asObjectable().getPasswordPolicyRef(), "security policy", task, result);
    LOGGER.trace("Found organization password policy: {}", orgPasswordPolicy);
    if (orgPasswordPolicy != null) {
        SecurityPolicyType policy = postProcessPasswordPolicy(orgPasswordPolicy.asObjectable());
        traceSecurityPolicy(policy, user);
        return policy;
    }
    if (systemConfiguration != null) {
        SecurityPolicyType globalPasswordPolicy = resolveGlobalPasswordPolicy(user, systemConfiguration.asObjectable(), task, result);
        if (globalPasswordPolicy != null) {
            return globalPasswordPolicy;
        }
    }
    return null;
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)

Example 7 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType 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 8 with SecurityPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType 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 9 with SecurityPolicyType

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

the class ResetPolicyDto method initResetPolicy.

private void initResetPolicy(AbstractCredentialsResetPolicyType resetPolicy, SecurityPolicyType securityPolicyType) throws SchemaException {
    this.formRef = resetPolicy.getFormRef();
    AbstractAuthenticationPolicyType authPolicy = SecurityPolicyUtil.getAuthenticationPolicy(resetPolicy.getAdditionalAuthenticationName(), securityPolicyType);
    if (authPolicy instanceof MailAuthenticationPolicyType) {
        this.mailAuthentication = (MailAuthenticationPolicyType) authPolicy;
        noncePolicy = SecurityPolicyUtil.getCredentialPolicy(mailAuthentication.getMailNonce(), securityPolicyType);
    } else if (authPolicy instanceof SmsAuthenticationPolicyType) {
        this.smsAuthentication = (SmsAuthenticationPolicyType) authPolicy;
        this.noncePolicy = SecurityPolicyUtil.getCredentialPolicy(smsAuthentication.getSmsNonce(), securityPolicyType);
    }
    this.name = resetPolicy.getName();
}
Also used : MailAuthenticationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailAuthenticationPolicyType) SmsAuthenticationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsAuthenticationPolicyType) AbstractAuthenticationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractAuthenticationPolicyType)

Example 10 with SecurityPolicyType

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

the class ResetPolicyDto method initResetPolicyDto.

public void initResetPolicyDto(SecurityPolicyType securityPolicyType) throws SchemaException {
    if (securityPolicyType == null) {
        return;
    }
    if (securityPolicyType.getCredentialsReset() == null) {
        return;
    }
    MailResetPolicyType mailResetPolicy = securityPolicyType.getCredentialsReset().getMailReset();
    if (mailResetPolicy != null) {
        this.resetMethod = ResetMethod.MAIL;
        initResetPolicy(mailResetPolicy, securityPolicyType);
        return;
    }
    SmsResetPolicyType smsResetPolicy = securityPolicyType.getCredentialsReset().getSmsReset();
    if (smsResetPolicy != null) {
        this.resetMethod = ResetMethod.SMS;
        initResetPolicy(smsResetPolicy, securityPolicyType);
        return;
    }
    SecurityQuestionsResetPolicyType securityQuestionsResetPolicy = securityPolicyType.getCredentialsReset().getSecurityQuestionReset();
    if (securityQuestionsResetPolicy != null) {
        this.resetMethod = ResetMethod.SECURITY_QUESTIONS;
        initResetPolicy(securityQuestionsResetPolicy, securityPolicyType);
        return;
    }
}
Also used : MailResetPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailResetPolicyType) SmsResetPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsResetPolicyType) SecurityQuestionsResetPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsResetPolicyType)

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