Search in sources :

Example 6 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class AbstractLdapTest method test030Capabilities.

@Test
public void test030Capabilities() throws Exception {
    final String TEST_NAME = "test030Capabilities";
    TestUtil.displayTestTile(this, TEST_NAME);
    CapabilitiesType capabilities = resourceType.getCapabilities();
    display("Resource capabilities", capabilities);
    assertNotNull("Null capabilities", capabilities);
    CapabilityCollectionType nativeCapabilitiesCollectionType = capabilities.getNative();
    assertNotNull("Null native capabilities type", nativeCapabilitiesCollectionType);
    List<Object> nativeCapabilities = nativeCapabilitiesCollectionType.getAny();
    assertNotNull("Null native capabilities", nativeCapabilities);
    assertFalse("Empty native capabilities", nativeCapabilities.isEmpty());
    assertCapability(nativeCapabilities, ReadCapabilityType.class);
    assertCapability(nativeCapabilities, CreateCapabilityType.class);
    assertCapability(nativeCapabilities, UpdateCapabilityType.class);
    assertCapability(nativeCapabilities, DeleteCapabilityType.class);
    // TODO: assert password capability. Check password readability.
    ActivationCapabilityType activationCapabilityType = CapabilityUtil.getCapability(nativeCapabilities, ActivationCapabilityType.class);
    assertActivationCapability(activationCapabilityType);
    assertAdditionalCapabilities(nativeCapabilities);
    assertStableSystem();
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 7 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method convertFromSimulatedActivationAdministrativeStatus.

private static void convertFromSimulatedActivationAdministrativeStatus(ActivationType activationType, ActivationCapabilityType activationCapability, ResourceType resource, PrismObject<ShadowType> shadow, OperationResult parentResult) {
    ActivationStatusCapabilityType statusCapabilityType = CapabilityUtil.getEffectiveActivationStatus(activationCapability);
    if (statusCapabilityType == null) {
        return;
    }
    ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);
    ResourceAttribute<?> simulatedStatusAttribute = null;
    if (statusCapabilityType.getAttribute() != null) {
        simulatedStatusAttribute = attributesContainer.findAttribute(statusCapabilityType.getAttribute());
    }
    // LOGGER.trace("activation property: {}", activationProperty.dump());
    // if (activationProperty == null) {
    // LOGGER.debug("No simulated activation attribute was defined for the account.");
    // return null;
    // }
    Collection<Object> simulatedStatusAttributeValues = null;
    if (simulatedStatusAttribute != null) {
        simulatedStatusAttributeValues = simulatedStatusAttribute.getRealValues(Object.class);
    }
    convertFromSimulatedActivationAdministrativeStatusInternal(activationType, statusCapabilityType, resource, simulatedStatusAttributeValues, parentResult);
    LOGGER.trace("Detected simulated activation administrativeStatus attribute {} on {} with value {}, resolved into {}", SchemaDebugUtil.prettyPrint(statusCapabilityType.getAttribute()), ObjectTypeUtil.toShortString(resource), simulatedStatusAttributeValues, activationType == null ? "null" : activationType.getAdministrativeStatus());
    // will have two ways to set activation.
    if (statusCapabilityType.isIgnoreAttribute() == null || statusCapabilityType.isIgnoreAttribute()) {
        if (simulatedStatusAttribute != null) {
            attributesContainer.remove(simulatedStatusAttribute);
        }
    }
}
Also used : ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 8 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method getActivationAdministrativeStatusFromSimulatedActivation.

private ActivationStatusCapabilityType getActivationAdministrativeStatusFromSimulatedActivation(ProvisioningContext ctx, ActivationCapabilityType activationCapability, ShadowType shadow, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    if (activationCapability == null) {
        result.recordWarning("Resource " + ctx.getResource() + " does not have native or simulated activation capability. Processing of activation for " + shadow + " was skipped");
        shadow.setFetchResult(result.createOperationResultType());
        return null;
    }
    ActivationStatusCapabilityType capActStatus = CapabilityUtil.getEffectiveActivationStatus(activationCapability);
    if (capActStatus == null) {
        result.recordWarning("Resource " + ctx.getResource() + " does not have native or simulated activation status capability. Processing of activation for " + shadow + " was skipped");
        shadow.setFetchResult(result.createOperationResultType());
        return null;
    }
    return capActStatus;
}
Also used : ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 9 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method completeActivation.

/**
	 * Completes activation state by determining simulated activation if necessary.
	 */
private void completeActivation(ProvisioningContext ctx, PrismObject<ShadowType> resourceObject, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ResourceType resourceType = ctx.getResource();
    ShadowType resourceObjectType = resourceObject.asObjectable();
    CapabilitiesType connectorCapabilities = ctx.getConnectorCapabilities(ReadCapabilityType.class);
    ActivationCapabilityType activationCapability = CapabilityUtil.getEffectiveCapability(connectorCapabilities, ActivationCapabilityType.class);
    if (resourceObjectType.getActivation() != null || CapabilityUtil.isCapabilityEnabled(activationCapability)) {
        ActivationType activationType = null;
        if (CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
            activationType = resourceObjectType.getActivation();
        } else if (CapabilityUtil.isCapabilityEnabled(activationCapability)) {
            activationType = convertFromSimulatedActivationAttributes(resourceType, resourceObject, activationCapability, parentResult);
        } else {
        // No activation capability, nothing to do
        }
        LOGGER.trace("Determined activation, administrativeStatus: {}, lockoutStatus: {}", activationType == null ? "null activationType" : activationType.getAdministrativeStatus(), activationType == null ? "null activationType" : activationType.getLockoutStatus());
        resourceObjectType.setActivation(activationType);
    } else {
        resourceObjectType.setActivation(null);
    }
}
Also used : ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)

Example 10 with ActivationCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method checkSimulatedActivationAdministrativeStatus.

private <T> void checkSimulatedActivationAdministrativeStatus(ProvisioningContext ctx, Collection<? extends ItemDelta> objectChange, ActivationStatusType status, ActivationCapabilityType activationCapabilityType, ShadowType shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapabilityType, shadow, result);
    ResourceAttribute<T> activationAttribute = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result);
    if (activationAttribute == null) {
        return;
    }
    PropertyDelta<T> simulatedActivationDelta = PropertyDelta.findPropertyDelta(objectChange, activationAttribute.getPath());
    if (simulatedActivationDelta == null) {
        return;
    }
    PrismProperty<T> simulatedActivationProperty = simulatedActivationDelta.getPropertyNewMatchingPath();
    Collection<T> realValues = simulatedActivationProperty.getRealValues();
    if (realValues.isEmpty()) {
        //nothing to do, no value for simulatedActivation
        return;
    }
    if (realValues.size() > 1) {
        throw new SchemaException("Found more than one value for simulated activation.");
    }
    T simulatedActivationValue = realValues.iterator().next();
    boolean transformedValue = getTransformedValue(ctx, activationCapabilityType, shadow, simulatedActivationValue, result);
    if (transformedValue && status == ActivationStatusType.ENABLED) {
    //this is ok, simulated value and also value for native capability resulted to the same vale
    } else {
        throw new SchemaException("Found conflicting change for activation. Simulated activation resulted to " + transformedValue + ", but native activation resulted to " + status);
    }
}
Also used : ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Aggregations

ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)29 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)16 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)13 QName (javax.xml.namespace.QName)11 Test (org.testng.annotations.Test)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)8 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 ActivationValidityCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType)6 Task (com.evolveum.midpoint.task.api.Task)5 ReadCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType)5 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)4 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)4 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)4 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)3 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)3 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 CreateCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)3