use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class TestOpenLdap method test705UnlockBarbossaAccount.
@Test
public void test705UnlockBarbossaAccount() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ObjectDelta<ShadowType> accountDelta = createModifyAccountShadowReplaceDelta(accountBarbossaOid, null, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL);
// WHEN
when();
executeChanges(accountDelta, null, task, result);
// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<ShadowType> shadow = getShadowModel(accountBarbossaOid);
display("Shadow (model)", shadow);
ActivationType activation = shadow.asObjectable().getActivation();
if (activation != null) {
LockoutStatusType lockoutStatus = shadow.asObjectable().getActivation().getLockoutStatus();
if (lockoutStatus != null && lockoutStatus != LockoutStatusType.NORMAL) {
AssertJUnit.fail("Barbossa is locked!");
}
}
Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
displayValue("LDAP Entry", entry);
assertNoAttribute(entry, "pwdAccountLockedTime");
assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD_2);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class ActivationConverter method completeActivation.
// region Resource object -> midPoint (simulating/native -> activation)
/**
* Completes activation for fetched object by determining simulated values if necessary.
*/
void completeActivation(PrismObject<ShadowType> resourceObject, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ShadowType resourceObjectBean = resourceObject.asObjectable();
ActivationCapabilityType activationCapability = ctx.getEffectiveCapability(ActivationCapabilityType.class);
if (!CapabilityUtil.isCapabilityEnabled(activationCapability) && resourceObjectBean.getActivation() == null) {
LOGGER.trace("No activation capability and also no activation information in the resource object.");
return;
}
ActivationStatusType activationStatus = determineActivationStatus(resourceObject, activationCapability, result);
LockoutStatusType lockoutStatus = determineLockoutStatus(resourceObject, activationCapability, result);
if (activationStatus != null || lockoutStatus != null) {
if (resourceObjectBean.getActivation() == null) {
resourceObjectBean.setActivation(new ActivationType(beans.prismContext));
}
resourceObjectBean.getActivation().setAdministrativeStatus(activationStatus);
resourceObjectBean.getActivation().setLockoutStatus(lockoutStatus);
} else {
if (resourceObjectBean.getActivation() != null) {
resourceObjectBean.getActivation().setAdministrativeStatus(null);
resourceObjectBean.getActivation().setLockoutStatus(null);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class ActivationConverter method determineLockoutStatus.
/**
* Determines lockout status for resource object. Uses either native or simulated value.
*/
private LockoutStatusType determineLockoutStatus(PrismObject<ShadowType> resourceObject, ActivationCapabilityType activationCapability, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ActivationType existingActivation = resourceObject.asObjectable().getActivation();
LockoutStatusType nativeValue = existingActivation != null ? existingActivation.getLockoutStatus() : null;
ActivationLockoutStatusCapabilityType lockoutCapability = CapabilityUtil.getEnabledActivationLockoutStrict(activationCapability);
if (lockoutCapability == null) {
if (nativeValue != null) {
LOGGER.trace("The lockout capability is disabled. Ignoring native value: {}", nativeValue);
}
// TODO Reconsider this. Maybe we should return native value.
return null;
}
if (lockoutCapability.getAttribute() == null) {
LOGGER.trace("Simulated lockout status is not configured. Using native value: {}", nativeValue);
return nativeValue;
}
Collection<Object> simulatingAttributeValues = getSimulatingAttributeValues(resourceObject, lockoutCapability.getAttribute());
TwoStateSimulatedToRealConverter<LockoutStatusType> converter = new TwoStateSimulatedToRealConverter<>(lockoutCapability.getNormalValue(), lockoutCapability.getLockedValue(), LockoutStatusType.NORMAL, LockoutStatusType.LOCKED, "lockout status", ctx);
LockoutStatusType lockout = converter.convert(simulatingAttributeValues, result);
LOGGER.trace("Detected simulated activation lockoutStatus attribute {} on {} with value {}, resolved into {}", lazy(() -> SchemaDebugUtil.prettyPrint(lockoutCapability.getAttribute())), ctx.getResource(), simulatingAttributeValues, lockout);
if (!Boolean.FALSE.equals(lockoutCapability.isIgnoreAttribute())) {
removeSimulatingAttribute(resourceObject, lockoutCapability.getAttribute());
}
return lockout;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class TestDummyPrioritiesAndReadReplace method test100AddAccount.
// copied from TestDummy
@Test
public void test100AddAccount() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> account = prismContext.parseObject(getAccountWillFile());
account.checkConsistence();
display("Adding shadow", account);
// WHEN
String addedObjectOid = provisioningService.addObject(account, null, null, task, result);
// THEN
result.computeStatus();
display("add object result", result);
TestUtil.assertSuccess("addObject has failed (result)", result);
assertEquals(ACCOUNT_WILL_OID, addedObjectOid);
account.checkConsistence();
PrismObject<ShadowType> accountRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
willIcfUid = getIcfUid(accountRepo);
ActivationType activationRepo = accountRepo.asObjectable().getActivation();
if (supportsActivation()) {
assertNotNull("No activation in " + accountRepo + " (repo)", activationRepo);
assertEquals("Wrong activation enableTimestamp in " + accountRepo + " (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp());
} else {
assertNull("Activation sneaked in (repo)", activationRepo);
}
syncServiceMock.assertSingleNotifySuccessOnly();
PrismObject<ShadowType> accountProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Account provisioning", accountProvisioning);
ShadowType accountTypeProvisioning = accountProvisioning.asObjectable();
display("account from provisioning", accountTypeProvisioning);
PrismAsserts.assertEqualsPolyString("Name not equal", ACCOUNT_WILL_USERNAME, accountTypeProvisioning.getName());
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, accountTypeProvisioning.getKind());
assertAttribute(accountProvisioning, SchemaConstants.ICFS_NAME, ACCOUNT_WILL_USERNAME);
assertAttribute(accountProvisioning, getUidMatchingRule(), SchemaConstants.ICFS_UID, willIcfUid);
ActivationType activationProvisioning = accountTypeProvisioning.getActivation();
if (supportsActivation()) {
assertNotNull("No activation in " + accountProvisioning + " (provisioning)", activationProvisioning);
assertEquals("Wrong activation administrativeStatus in " + accountProvisioning + " (provisioning)", ActivationStatusType.ENABLED, activationProvisioning.getAdministrativeStatus());
TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in " + accountProvisioning + " (provisioning)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationProvisioning.getEnableTimestamp());
} else {
assertNull("Activation sneaked in (provisioning)", activationProvisioning);
}
assertNull("The _PASSSWORD_ attribute sneaked into shadow", ShadowUtil.getAttributeValues(accountTypeProvisioning, new QName(SchemaConstants.NS_ICF_SCHEMA, "password")));
// Check if the account was created in the dummy resource
DummyAccount dummyAccount = getDummyAccountAssert(ACCOUNT_WILL_USERNAME, willIcfUid);
assertNotNull("No dummy account", dummyAccount);
assertEquals("Username is wrong", ACCOUNT_WILL_USERNAME, dummyAccount.getName());
assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname"));
assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Wrong password", "3lizab3th", dummyAccount.getPassword());
// Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it)
PrismObject<ShadowType> shadowFromRepo = repositoryService.getObject(ShadowType.class, addedObjectOid, null, result);
assertNotNull("Shadow was not created in the repository", shadowFromRepo);
displayValue("Repository shadow", shadowFromRepo.debugDump());
ProvisioningTestUtil.checkRepoAccountShadow(shadowFromRepo);
checkUniqueness(accountProvisioning);
// assertSteadyResource();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class QAccessCertificationCaseMapping method insert.
// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject
@SuppressWarnings("DuplicatedCode")
@Override
public MAccessCertificationCase insert(AccessCertificationCaseType acase, MAccessCertificationCampaign ownerRow, JdbcSession jdbcSession) throws SchemaException {
MAccessCertificationCase row = initRowObject(acase, ownerRow);
// activation
ActivationType activation = acase.getActivation();
if (activation != null) {
row.administrativeStatus = activation.getAdministrativeStatus();
row.effectiveStatus = activation.getEffectiveStatus();
row.enableTimestamp = MiscUtil.asInstant(activation.getEnableTimestamp());
row.disableTimestamp = MiscUtil.asInstant(activation.getDisableTimestamp());
row.disableReason = activation.getDisableReason();
row.validityStatus = activation.getValidityStatus();
row.validFrom = MiscUtil.asInstant(activation.getValidFrom());
row.validTo = MiscUtil.asInstant(activation.getValidTo());
row.validityChangeTimestamp = MiscUtil.asInstant(activation.getValidityChangeTimestamp());
row.archiveTimestamp = MiscUtil.asInstant(activation.getArchiveTimestamp());
}
row.currentStageOutcome = acase.getCurrentStageOutcome();
row.fullObject = createFullObject(acase);
// TODO
row.campaignIteration = acase.getIteration();
setReference(acase.getObjectRef(), o -> row.objectRefTargetOid = o, t -> row.objectRefTargetType = t, r -> row.objectRefRelationId = r);
setReference(acase.getOrgRef(), o -> row.orgRefTargetOid = o, t -> row.orgRefTargetType = t, r -> row.orgRefRelationId = r);
row.outcome = acase.getOutcome();
row.remediedTimestamp = MiscUtil.asInstant(acase.getRemediedTimestamp());
row.currentStageDeadline = MiscUtil.asInstant(acase.getCurrentStageDeadline());
row.currentStageCreateTimestamp = MiscUtil.asInstant(acase.getCurrentStageCreateTimestamp());
row.stageNumber = acase.getStageNumber();
setReference(acase.getTargetRef(), o -> row.targetRefTargetOid = o, t -> row.targetRefTargetType = t, r -> row.targetRefRelationId = r);
setReference(acase.getTenantRef(), o -> row.tenantRefTargetOid = o, t -> row.tenantRefTargetType = t, r -> row.tenantRefRelationId = r);
insert(row, jdbcSession);
storeWorkItems(row, acase, jdbcSession);
return row;
}
Aggregations