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;
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations