Search in sources :

Example 11 with ObjectReferenceType

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

the class SecurityHelper method resolveGlobalPasswordPolicy.

private <F extends FocusType> SecurityPolicyType resolveGlobalPasswordPolicy(PrismObject<F> user, SystemConfigurationType systemConfiguration, Task task, OperationResult result) {
    ObjectReferenceType globalPasswordPolicyRef = systemConfiguration.getGlobalPasswordPolicyRef();
    if (globalPasswordPolicyRef != null) {
        try {
            ValuePolicyType globalPasswordPolicyType = objectResolver.resolve(globalPasswordPolicyRef, ValuePolicyType.class, null, "global security policy reference in system configuration", task, result);
            LOGGER.trace("Using global password policy: {}", globalPasswordPolicyType);
            SecurityPolicyType policy = postProcessPasswordPolicy(globalPasswordPolicyType);
            traceSecurityPolicy(policy, user);
            return policy;
        } catch (ObjectNotFoundException | SchemaException e) {
            LOGGER.error(e.getMessage(), e);
            traceSecurityPolicy(null, user);
            return null;
        }
    }
    return null;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)

Example 12 with ObjectReferenceType

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

the class PipelineData method getDataAsReferences.

public Collection<ObjectReferenceType> getDataAsReferences(QName defaultTargetType) throws ScriptExecutionException {
    Collection<ObjectReferenceType> retval = new ArrayList<>(data.size());
    for (PipelineItem item : data) {
        PrismValue value = item.getValue();
        if (value instanceof PrismObjectValue) {
            PrismObjectValue objectValue = (PrismObjectValue) value;
            ObjectReferenceType ref = new ObjectReferenceType();
            // todo check the definition is present
            ref.setType(objectValue.asPrismObject().getDefinition().getTypeName());
            // todo check if oid is present
            ref.setOid(objectValue.getOid());
            retval.add(ref);
        } else if (value instanceof PrismPropertyValue) {
            Object realValue = ((PrismPropertyValue) value).getRealValue();
            if (realValue instanceof String) {
                ObjectReferenceType ref = new ObjectReferenceType();
                ref.setType(defaultTargetType);
                // todo implement search by name
                ref.setOid((String) realValue);
                retval.add(ref);
            } else if (realValue instanceof ObjectReferenceType) {
                retval.add((ObjectReferenceType) realValue);
            } else {
                throw new ScriptExecutionException("Unsupported reference type: " + value.getClass());
            }
        } else if (value instanceof PrismReferenceValue) {
            PrismReferenceValue referenceValue = (PrismReferenceValue) value;
            ObjectReferenceType ref = new ObjectReferenceType();
            ref.setupReferenceValue(referenceValue);
            retval.add(ref);
        }
    }
    return retval;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) ScriptExecutionException(com.evolveum.midpoint.model.api.ScriptExecutionException)

Example 13 with ObjectReferenceType

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

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

the class TestJaxbConstruction method assertAccountRefs.

private void assertAccountRefs(UserType userType, String... accountOids) {
    List<ObjectReferenceType> accountRefs = userType.getLinkRef();
    assertEquals("Wrong number of accountRefs", accountOids.length, accountRefs.size());
    for (String expectedAccountOid : accountOids) {
        assertAccountRef(accountRefs, expectedAccountOid);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 15 with ObjectReferenceType

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

the class MappingEditorDialog method createPasswordPolicyList.

private List<ObjectReferenceType> createPasswordPolicyList() {
    policyMap.clear();
    OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
    List<PrismObject<ValuePolicyType>> policies = null;
    List<ObjectReferenceType> references = new ArrayList<>();
    try {
        policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't load password policies.", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
    }
    if (policies != null) {
        ObjectReferenceType ref;
        for (PrismObject<ValuePolicyType> policy : policies) {
            policyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
            ref = new ObjectReferenceType();
            ref.setType(ValuePolicyType.COMPLEX_TYPE);
            ref.setOid(policy.getOid());
            references.add(ref);
        }
    }
    return references;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)225 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)100 Test (org.testng.annotations.Test)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)77 Task (com.evolveum.midpoint.task.api.Task)50 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)41 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)36 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)31 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 QName (javax.xml.namespace.QName)29 ArrayList (java.util.ArrayList)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)25 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)22 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17