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