Search in sources :

Example 86 with ActivationType

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

the class UserAsserter method assertAdministrativeStatus.

public UserAsserter<RA> assertAdministrativeStatus(ActivationStatusType expected) {
    ActivationType activation = getActivation();
    if (activation == null) {
        if (expected == null) {
            return this;
        } else {
            fail("No activation in " + desc());
        }
    }
    assertEquals("Wrong activation administrativeStatus in " + desc(), expected, activation.getAdministrativeStatus());
    return this;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Example 87 with ActivationType

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

the class ActivationConverter method transformActivationOnAdd.

// endregion
// region midPoint -> resource object (activation -> simulating/native) on object ADD
/**
 * Transforms activation information when an object is being added.
 */
void transformActivationOnAdd(ShadowType shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationType activation = shadow.getActivation();
    if (activation == null) {
        return;
    }
    ActivationCapabilityType activationCapability = ctx.getEffectiveCapability(ActivationCapabilityType.class);
    if (activation.getAdministrativeStatus() != null) {
        transformActivationStatusOnAdd(shadow, activationCapability, result);
    }
    if (activation.getLockoutStatus() != null) {
        transformLockoutStatusOnAdd(shadow, activationCapability, result);
    }
}
Also used : ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)

Example 88 with ActivationType

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

the class ActivationConverter method determineActivationStatus.

/**
 * Determines activation status for resource object. Uses either native or simulated value.
 */
private ActivationStatusType determineActivationStatus(PrismObject<ShadowType> resourceObject, ActivationCapabilityType activationCapability, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationType existingActivation = resourceObject.asObjectable().getActivation();
    ActivationStatusType nativeValue = existingActivation != null ? existingActivation.getAdministrativeStatus() : null;
    ActivationStatusCapabilityType statusCapability = CapabilityUtil.getEnabledActivationStatusStrict(activationCapability);
    if (statusCapability == null) {
        if (nativeValue != null) {
            LOGGER.trace("The status capability is disabled. Ignoring native value: {}", nativeValue);
        }
        // TODO Reconsider this. Maybe we should return native value.
        return null;
    }
    if (statusCapability.getAttribute() == null) {
        LOGGER.trace("Simulated activation status is not configured. Using native value: {}", nativeValue);
        return nativeValue;
    }
    Collection<Object> simulatingAttributeValues = getSimulatingAttributeValues(resourceObject, statusCapability.getAttribute());
    TwoStateSimulatedToRealConverter<ActivationStatusType> converter = new TwoStateSimulatedToRealConverter<>(statusCapability.getEnableValue(), statusCapability.getDisableValue(), ActivationStatusType.ENABLED, ActivationStatusType.DISABLED, "activation status", ctx);
    ActivationStatusType status = converter.convert(simulatingAttributeValues, result);
    LOGGER.trace("Detected simulated activation administrativeStatus attribute {} on {} with value {}, resolved into {}", lazy(() -> SchemaDebugUtil.prettyPrint(statusCapability.getAttribute())), ctx.getResource(), simulatingAttributeValues, status);
    if (!Boolean.FALSE.equals(statusCapability.isIgnoreAttribute())) {
        removeSimulatingAttribute(resourceObject, statusCapability.getAttribute());
    }
    return status;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 89 with ActivationType

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

the class TestOpenDj method test170DisableAccount.

@Test
public void test170DisableAccount() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ShadowType object = parseObjectType(ACCOUNT_DISABLE_SIMULATED_FILE, ShadowType.class);
    System.out.println(SchemaDebugUtil.prettyPrint(object));
    System.out.println(object.asPrismObject().debugDump());
    String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result);
    assertEquals(ACCOUNT_DISABLE_SIMULATED_OID, addedObjectOid);
    ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(REQUEST_DISABLE_ACCOUNT_SIMULATED_FILE, ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, object.asPrismObject().getDefinition());
    displayDumpable("Object change", delta);
    // WHEN
    when();
    provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result);
    // THEN
    then();
    ShadowType accountAfter = provisioningService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, task, result).asObjectable();
    display("Object after change", accountAfter);
    assertEquals("The account was not disabled in the shadow", ActivationStatusType.DISABLED, accountAfter.getActivation().getAdministrativeStatus());
    String uid = ShadowUtil.getSingleStringAttributeValue(accountAfter, getPrimaryIdentifierQName());
    assertNotNull(uid);
    // Check if object was modified in LDAP
    Entry response = openDJController.searchAndAssertByEntryUuid(uid);
    display("LDAP account", response);
    String disabled = OpenDJController.getAttributeValue(response, "ds-pwp-account-disabled");
    assertNotNull("no ds-pwp-account-disabled attribute in account " + uid, disabled);
    display("ds-pwp-account-disabled after change: " + disabled);
    assertEquals("ds-pwp-account-disabled not set to \"TRUE\"", "TRUE", disabled);
    PrismObject<ShadowType> repoShadow = getShadowRepo(ACCOUNT_DISABLE_SIMULATED_OID);
    ActivationType repoActivation = repoShadow.asObjectable().getActivation();
    assertNotNull("No activation in repo", repoActivation);
    XMLGregorianCalendar repoDisableTimestamp = repoActivation.getDisableTimestamp();
    assertNotNull("No activation disableTimestamp in repo", repoDisableTimestamp);
    assertEquals("Wrong activation disableTimestamp in repo", XmlTypeConverter.createXMLGregorianCalendar(2001, 2, 3, 4, 5, 6), repoDisableTimestamp);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 90 with ActivationType

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

the class GetAssignmentResult method toActivation.

private ActivationType toActivation(RActivation repoActivation, PrismContext prismContext) throws DtoTranslationException {
    if (repoActivation == null) {
        return null;
    }
    ActivationType activation = new ActivationType(prismContext);
    RActivation.fromJaxb(activation, repoActivation);
    return activation;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)76 Test (org.testng.annotations.Test)48 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)40 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)7 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)4 QName (javax.xml.namespace.QName)4