Search in sources :

Example 56 with SystemConfigurationType

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

the class TestUserTemplate method test000Sanity.

@Test
public void test000Sanity() throws Exception {
    final String TEST_NAME = "test000Sanity";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<SystemConfigurationType> systemConfiguration = modelService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    display("System config", systemConfiguration);
    assertNotNull("no system config", systemConfiguration);
    List<ObjectPolicyConfigurationType> defaultObjectPolicyConfiguration = systemConfiguration.asObjectable().getDefaultObjectPolicyConfiguration();
    assertNotNull("No object policy", defaultObjectPolicyConfiguration);
    assertEquals("Wrong object policy size", 2, defaultObjectPolicyConfiguration.size());
    assertObjectTemplate(defaultObjectPolicyConfiguration, UserType.COMPLEX_TYPE, null, USER_TEMPLATE_COMPLEX_OID);
    assertObjectTemplate(defaultObjectPolicyConfiguration, UserType.COMPLEX_TYPE, EMPLOYEE_TYPE_MAROONED, USER_TEMPLATE_MAROONED_OID);
    assertRoles(NUMBER_OF_ROLES);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 57 with SystemConfigurationType

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

the class ConfirmationNotifier method createConfirmationLink.

protected String createConfirmationLink(UserType userType, GeneralNotifierType generalNotifierType, OperationResult result) {
    ConfirmationNotifierType userRegistrationNotifier = (ConfirmationNotifierType) generalNotifierType;
    RegistrationConfirmationMethodType confirmationMethod = userRegistrationNotifier.getConfirmationMethod();
    if (confirmationMethod == null) {
        return null;
    }
    ExpressionEnvironment expressionEnv = new ExpressionEnvironment();
    expressionEnv.setCurrentResult(result);
    ModelExpressionThreadLocalHolder.pushExpressionEnvironment(expressionEnv);
    try {
        switch(confirmationMethod) {
            case LINK:
                //				SystemConfigurationType systemConfiguration = notificationsUtil.getSystemConfiguration(result);
                //				if (systemConfiguration == null) {
                //					LOGGER.trace("No system configuration defined. Skipping link generation.");
                //					return null;
                //				}
                ////				String defaultHostname = SystemConfigurationTypeUtil.getDefaultHostname(systemConfiguration);
                String confirmationLink = getConfirmationLink(userType);
                return confirmationLink;
            case PIN:
                throw new UnsupportedOperationException("PIN confirmation not supported yes");
            //				return getNonce(userType);
            default:
                break;
        }
    } finally {
        ModelExpressionThreadLocalHolder.popExpressionEnvironment();
    }
    return null;
}
Also used : ExpressionEnvironment(com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment) RegistrationConfirmationMethodType(com.evolveum.midpoint.xml.ns._public.common.common_3.RegistrationConfirmationMethodType) ConfirmationNotifierType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConfirmationNotifierType)

Example 58 with SystemConfigurationType

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

the class ModelUtils method determineObjectPolicyConfiguration.

public static <O extends ObjectType> ObjectPolicyConfigurationType determineObjectPolicyConfiguration(Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfigurationType) throws ConfigurationException {
    ObjectPolicyConfigurationType applicablePolicyConfigurationType = null;
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getDefaultObjectPolicyConfiguration()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in default object policy definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            String aSubType = aPolicyConfigurationType.getSubtype();
            if (aSubType == null) {
                if (applicablePolicyConfigurationType == null) {
                    applicablePolicyConfigurationType = aPolicyConfigurationType;
                }
            } else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
                applicablePolicyConfigurationType = aPolicyConfigurationType;
            }
        }
    }
    if (applicablePolicyConfigurationType != null) {
        return applicablePolicyConfigurationType;
    }
    // Deprecated
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getObjectTemplate()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in object template definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            return aPolicyConfigurationType;
        }
    }
    // Deprecated method to specify user template. For compatibility only
    if (objectClass == UserType.class) {
        ObjectReferenceType templateRef = systemConfigurationType.getDefaultUserTemplateRef();
        if (templateRef == null) {
            return null;
        }
        ObjectPolicyConfigurationType policy = new ObjectPolicyConfigurationType();
        policy.setObjectTemplateRef(templateRef.clone());
        return policy;
    }
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 59 with SystemConfigurationType

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

the class ObjectMerger method computeMergeDeltas.

public <O extends ObjectType> MergeDeltas<O> computeMergeDeltas(Class<O> type, String leftOid, String rightOid, final String mergeConfigurationName, final Task task, final OperationResult result) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException {
    final PrismObject<O> objectLeft = (PrismObject<O>) objectResolver.getObjectSimple(type, leftOid, null, task, result).asPrismObject();
    final PrismObject<O> objectRight = (PrismObject<O>) objectResolver.getObjectSimple(type, rightOid, null, task, result).asPrismObject();
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    MergeConfigurationType mergeConfiguration = selectConfiguration(systemConfiguration, mergeConfigurationName);
    if (mergeConfiguration == null) {
        throw new ConfigurationException("No merge configuration defined");
    }
    // The "left" object is always the one that will be the result. We will use its OID.
    final ObjectDelta<O> leftObjectDelta = objectLeft.createModifyDelta();
    final ObjectDelta<O> leftLinkDelta = objectLeft.createModifyDelta();
    final ObjectDelta<O> rightLinkDelta = objectRight.createModifyDelta();
    final List<ItemPath> processedPaths = new ArrayList<>();
    computeItemDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result);
    computeDefaultDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result);
    computeProjectionDeltas(leftLinkDelta, rightLinkDelta, objectLeft, objectRight, mergeConfiguration, mergeConfigurationName, task, result);
    return new MergeDeltas<>(leftObjectDelta, leftLinkDelta, rightLinkDelta);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) MergeDeltas(com.evolveum.midpoint.model.api.util.MergeDeltas) ProjectionMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType) ItemRefMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemRefMergeConfigurationType) MergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MergeConfigurationType) ItemMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemMergeConfigurationType) ArrayList(java.util.ArrayList) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 60 with SystemConfigurationType

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

the class SchemaTransformer method determineObjectTemplate.

public <O extends ObjectType> ObjectTemplateType determineObjectTemplate(PrismObject<O> object, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException {
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    if (systemConfiguration == null) {
        return null;
    }
    ObjectPolicyConfigurationType objectPolicyConfiguration = ModelUtils.determineObjectPolicyConfiguration(object, systemConfiguration.asObjectable());
    if (objectPolicyConfiguration == null) {
        return null;
    }
    ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef();
    if (objectTemplateRef == null) {
        return null;
    }
    PrismObject<ObjectTemplateType> template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result);
    return template.asObjectable();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Aggregations

SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)40 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 Task (com.evolveum.midpoint.task.api.Task)14 Test (org.testng.annotations.Test)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)10 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)9 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)8 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)8 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)8 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 ObjectPolicyConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType)6 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4