use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.
the class ResourceObjectConverter method convertFromSimulatedActivationLockoutStatus.
private static void convertFromSimulatedActivationLockoutStatus(ActivationType activationType, ActivationCapabilityType activationCapability, ResourceType resource, PrismObject<ShadowType> shadow, OperationResult parentResult) {
ActivationLockoutStatusCapabilityType statusCapabilityType = CapabilityUtil.getEffectiveActivationLockoutStatus(activationCapability);
if (statusCapabilityType == null) {
return;
}
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);
ResourceAttribute<?> activationProperty = null;
if (statusCapabilityType.getAttribute() != null) {
activationProperty = 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> activationValues = null;
if (activationProperty != null) {
activationValues = activationProperty.getRealValues(Object.class);
}
convertFromSimulatedActivationLockoutStatusInternal(activationType, statusCapabilityType, resource, activationValues, parentResult);
LOGGER.trace("Detected simulated activation lockout attribute {} on {} with value {}, resolved into {}", SchemaDebugUtil.prettyPrint(statusCapabilityType.getAttribute()), ObjectTypeUtil.toShortString(resource), activationValues, activationType == null ? "null" : activationType.getAdministrativeStatus());
// will have two ways to set activation.
if (statusCapabilityType.isIgnoreAttribute() == null || statusCapabilityType.isIgnoreAttribute()) {
if (activationProperty != null) {
attributesContainer.remove(activationProperty);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.
the class ResourceObjectConverter method convertToSimulatedActivationLockoutStatusAttribute.
private PropertyModificationOperation convertToSimulatedActivationLockoutStatusAttribute(ProvisioningContext ctx, PropertyDelta activationDelta, ShadowType shadow, LockoutStatusType status, ActivationCapabilityType activationCapability, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ActivationLockoutStatusCapabilityType capActStatus = getActivationLockoutStatusFromSimulatedActivation(ctx, activationCapability, shadow, result);
if (capActStatus == null) {
throw new SchemaException("Attempt to modify lockout on " + ctx.getResource() + " which does not have activation lockout capability");
}
ResourceAttribute<?> activationAttribute = getSimulatedActivationLockoutStatusAttribute(ctx, shadow, capActStatus, result);
if (activationAttribute == null) {
return null;
}
PropertyDelta<?> lockoutAttributeDelta = null;
if (status == null && activationDelta.isDelete()) {
LOGGER.trace("deleting activation property.");
lockoutAttributeDelta = PropertyDelta.createModificationDeleteProperty(new ItemPath(ShadowType.F_ATTRIBUTES, activationAttribute.getElementName()), activationAttribute.getDefinition(), activationAttribute.getRealValue());
} else if (status == LockoutStatusType.NORMAL) {
String normalValue = getLockoutNormalValue(capActStatus);
lockoutAttributeDelta = createActivationPropDelta(activationAttribute.getElementName(), activationAttribute.getDefinition(), normalValue);
} else {
String lockedValue = getLockoutLockedValue(capActStatus);
lockoutAttributeDelta = createActivationPropDelta(activationAttribute.getElementName(), activationAttribute.getDefinition(), lockedValue);
}
PropertyModificationOperation attributeChange = new PropertyModificationOperation(lockoutAttributeDelta);
return attributeChange;
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.
the class ResourceObjectConverter method getActivationLockoutStatusFromSimulatedActivation.
private ActivationLockoutStatusCapabilityType getActivationLockoutStatusFromSimulatedActivation(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;
}
ActivationLockoutStatusCapabilityType capActStatus = CapabilityUtil.getEffectiveActivationLockoutStatus(activationCapability);
if (capActStatus == null) {
result.recordWarning("Resource " + ctx.getResource() + " does not have native or simulated activation lockout capability. Processing of activation for " + shadow + " was skipped");
shadow.setFetchResult(result.createOperationResultType());
return null;
}
return capActStatus;
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.
the class ResourceObjectConverter method transformActivationAttributesAdd.
private void transformActivationAttributesAdd(ProvisioningContext ctx, ShadowType shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
final ActivationType activation = shadow.getActivation();
if (activation == null) {
return;
}
PrismContainer attributesContainer = shadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES);
CapabilitiesType connectorCapabilities = ctx.getConnectorCapabilities(CreateCapabilityType.class);
ActivationCapabilityType activationCapability = CapabilityUtil.getEffectiveCapability(connectorCapabilities, ActivationCapabilityType.class);
if (activation.getAdministrativeStatus() != null) {
if (!CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapability, shadow, result);
if (capActStatus == null) {
throw new SchemaException("Attempt to change activation/administrativeStatus on " + ctx.getResource() + " that has neither native" + " nor simulated activation capability");
}
ResourceAttribute<?> newSimulatedAttr = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result);
if (newSimulatedAttr != null) {
Class<?> simulatedAttrValueClass = getAttributeValueClass(ctx, shadow, newSimulatedAttr, capActStatus);
Object newSimulatedAttrRealValue;
if (activation.getAdministrativeStatus() == ActivationStatusType.ENABLED) {
newSimulatedAttrRealValue = getEnableValue(capActStatus, simulatedAttrValueClass);
} else {
newSimulatedAttrRealValue = getDisableValue(capActStatus, simulatedAttrValueClass);
}
Item existingSimulatedAttr = attributesContainer.findItem(newSimulatedAttr.getElementName());
if (!isBlank(newSimulatedAttrRealValue)) {
PrismPropertyValue newSimulatedAttrValue = new PrismPropertyValue(newSimulatedAttrRealValue);
if (existingSimulatedAttr == null) {
newSimulatedAttr.add(newSimulatedAttrValue);
attributesContainer.add(newSimulatedAttr);
} else {
existingSimulatedAttr.replace(newSimulatedAttrValue);
}
} else if (existingSimulatedAttr != null) {
attributesContainer.remove(existingSimulatedAttr);
}
activation.setAdministrativeStatus(null);
}
}
}
// TODO enable non-string lockout values (MID-3374)
if (activation.getLockoutStatus() != null) {
if (!CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
ActivationLockoutStatusCapabilityType capActStatus = getActivationLockoutStatusFromSimulatedActivation(ctx, activationCapability, shadow, result);
if (capActStatus == null) {
throw new SchemaException("Attempt to change activation/lockout on " + ctx.getResource() + " that has neither native" + " nor simulated activation capability");
}
ResourceAttribute<?> activationSimulateAttribute = getSimulatedActivationLockoutStatusAttribute(ctx, shadow, capActStatus, result);
if (activationSimulateAttribute != null) {
LockoutStatusType status = activation.getLockoutStatus();
String activationRealValue = null;
if (status == LockoutStatusType.NORMAL) {
activationRealValue = getLockoutNormalValue(capActStatus);
} else {
activationRealValue = getLockoutLockedValue(capActStatus);
}
Item existingAttribute = attributesContainer.findItem(activationSimulateAttribute.getElementName());
if (!StringUtils.isBlank(activationRealValue)) {
activationSimulateAttribute.add(new PrismPropertyValue(activationRealValue));
if (attributesContainer.findItem(activationSimulateAttribute.getElementName()) == null) {
attributesContainer.add(activationSimulateAttribute);
} else {
attributesContainer.findItem(activationSimulateAttribute.getElementName()).replace(activationSimulateAttribute.getValue());
}
} else if (existingAttribute != null) {
attributesContainer.remove(existingAttribute);
}
activation.setLockoutStatus(null);
}
}
}
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType in project midpoint by Evolveum.
the class ActivationProcessor method processActivationMappingsFuture.
/**
* We'll evaluate the mappings just to create the triggers.
*/
private <F extends FocusType> void processActivationMappingsFuture(LensContext<F> context, LensProjectionContext accCtx, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
String accCtxDesc = accCtx.toHumanReadableString();
SynchronizationPolicyDecision decision = accCtx.getSynchronizationPolicyDecision();
LOGGER.trace("processActivationUserFuture starting for {}. Existing decision = {}", accCtx, decision);
if (accCtx.isGone() || decision == SynchronizationPolicyDecision.BROKEN || decision == SynchronizationPolicyDecision.IGNORE || decision == SynchronizationPolicyDecision.UNLINK || decision == SynchronizationPolicyDecision.DELETE) {
return;
}
accCtx.recompute();
evaluateExistenceMapping(context, accCtx, now, MappingTimeEval.FUTURE, task, result);
PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
if (focusNew == null) {
// This must be a user delete or something similar. No point in proceeding
LOGGER.trace("focusNew is null, skipping activation processing of {}", accCtxDesc);
return;
}
ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return;
}
ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
if (activationType == null) {
return;
}
ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(accCtx.getResource(), ActivationCapabilityType.class);
if (capActivation == null) {
return;
}
ActivationStatusCapabilityType capStatus = CapabilityUtil.getEnabledActivationStatus(capActivation);
ActivationValidityCapabilityType capValidFrom = CapabilityUtil.getEnabledActivationValidFrom(capActivation);
ActivationValidityCapabilityType capValidTo = CapabilityUtil.getEnabledActivationValidTo(capActivation);
if (capStatus != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(), SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, capActivation, now, MappingTimeEval.FUTURE, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
}
if (capValidFrom != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(), SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM, null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}
if (capValidTo != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(), SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO, null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}
}
Aggregations