Search in sources :

Example 6 with ActivationStatusCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType 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);
            }
        }
    }
}
Also used : ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 7 with ActivationStatusCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType in project midpoint by Evolveum.

the class AbstractManualConnectorInstance method fetchCapabilities.

@Override
public Collection<Object> fetchCapabilities(OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException {
    Collection<Object> capabilities = new ArrayList<>();
    // caching-only read capabilities
    ReadCapabilityType readCap = new ReadCapabilityType();
    readCap.setCachingOnly(true);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(readCap));
    CreateCapabilityType createCap = new CreateCapabilityType();
    setManual(createCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(createCap));
    UpdateCapabilityType updateCap = new UpdateCapabilityType();
    setManual(updateCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(updateCap));
    DeleteCapabilityType deleteCap = new DeleteCapabilityType();
    setManual(deleteCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(deleteCap));
    ActivationCapabilityType activationCap = new ActivationCapabilityType();
    ActivationStatusCapabilityType activationStatusCap = new ActivationStatusCapabilityType();
    activationCap.setStatus(activationStatusCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createActivation(activationCap));
    CredentialsCapabilityType credentialsCap = new CredentialsCapabilityType();
    PasswordCapabilityType passwordCapabilityType = new PasswordCapabilityType();
    credentialsCap.setPassword(passwordCapabilityType);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createCredentials(credentialsCap));
    return capabilities;
}
Also used : UpdateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType) ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) DeleteCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType) PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ArrayList(java.util.ArrayList) PrismObject(com.evolveum.midpoint.prism.PrismObject) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType) CreateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)

Example 8 with ActivationStatusCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method parseResourceSchema.

private void parseResourceSchema(org.identityconnectors.framework.common.objects.Schema icfSchema, List<QName> generateObjectClasses) {
    AttributeInfo passwordAttributeInfo = null;
    AttributeInfo enableAttributeInfo = null;
    AttributeInfo enableDateAttributeInfo = null;
    AttributeInfo disableDateAttributeInfo = null;
    AttributeInfo lockoutAttributeInfo = null;
    AttributeInfo auxiliaryObjectClasseAttributeInfo = null;
    // New instance of midPoint schema object
    setResourceSchema(new ResourceSchemaImpl(getSchemaNamespace(), prismContext));
    if (legacySchema == null) {
        legacySchema = detectLegacySchema(icfSchema);
    }
    LOGGER.trace("Converting resource schema (legacy mode: {})", legacySchema);
    Set<ObjectClassInfo> objectClassInfoSet = icfSchema.getObjectClassInfo();
    // Let's convert every objectclass in the ICF schema ...		
    for (ObjectClassInfo objectClassInfo : objectClassInfoSet) {
        // "Flat" ICF object class names needs to be mapped to QNames
        QName objectClassXsdName = connIdNameMapper.objectClassToQname(new ObjectClass(objectClassInfo.getType()), getSchemaNamespace(), legacySchema);
        if (!shouldBeGenerated(generateObjectClasses, objectClassXsdName)) {
            LOGGER.trace("Skipping object class {} ({})", objectClassInfo.getType(), objectClassXsdName);
            continue;
        }
        LOGGER.trace("Convering object class {} ({})", objectClassInfo.getType(), objectClassXsdName);
        // ResourceObjectDefinition is a midPpoint way how to represent an
        // object class.
        // The important thing here is the last "type" parameter
        // (objectClassXsdName). The rest is more-or-less cosmetics.
        ObjectClassComplexTypeDefinition ocDef = ((ResourceSchemaImpl) resourceSchema).createObjectClassDefinition(objectClassXsdName);
        // objectclass. So mark it appropriately.
        if (ObjectClass.ACCOUNT_NAME.equals(objectClassInfo.getType())) {
            ((ObjectClassComplexTypeDefinitionImpl) ocDef).setKind(ShadowKindType.ACCOUNT);
            ((ObjectClassComplexTypeDefinitionImpl) ocDef).setDefaultInAKind(true);
        }
        ResourceAttributeDefinition<String> uidDefinition = null;
        ResourceAttributeDefinition<String> nameDefinition = null;
        boolean hasUidDefinition = false;
        int displayOrder = ConnectorFactoryConnIdImpl.ATTR_DISPLAY_ORDER_START;
        // Let's iterate over all attributes in this object class ...
        Set<AttributeInfo> attributeInfoSet = objectClassInfo.getAttributeInfo();
        for (AttributeInfo attributeInfo : attributeInfoSet) {
            String icfName = attributeInfo.getName();
            if (OperationalAttributes.PASSWORD_NAME.equals(icfName)) {
                // This attribute will not go into the schema
                // instead a "password" capability is used
                passwordAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            if (OperationalAttributes.ENABLE_NAME.equals(icfName)) {
                enableAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            if (OperationalAttributes.ENABLE_DATE_NAME.equals(icfName)) {
                enableDateAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            if (OperationalAttributes.DISABLE_DATE_NAME.equals(icfName)) {
                disableDateAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            if (OperationalAttributes.LOCK_OUT_NAME.equals(icfName)) {
                lockoutAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            if (PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME.equals(icfName)) {
                auxiliaryObjectClasseAttributeInfo = attributeInfo;
                // Skip this attribute, capability is sufficient
                continue;
            }
            String processedAttributeName = icfName;
            if ((Name.NAME.equals(icfName) || Uid.NAME.equals(icfName)) && attributeInfo.getNativeName() != null) {
                processedAttributeName = attributeInfo.getNativeName();
            }
            QName attrXsdName = connIdNameMapper.convertAttributeNameToQName(processedAttributeName, ocDef);
            QName attrXsdType = ConnIdUtil.icfTypeToXsdType(attributeInfo.getType(), false);
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Attr conversion ICF: {}({}) -> XSD: {}({})", icfName, attributeInfo.getType().getSimpleName(), PrettyPrinter.prettyPrint(attrXsdName), PrettyPrinter.prettyPrint(attrXsdType));
            }
            // Create ResourceObjectAttributeDefinition, which is midPoint
            // way how to express attribute schema.
            ResourceAttributeDefinitionImpl attrDef = new ResourceAttributeDefinitionImpl(attrXsdName, attrXsdType, prismContext);
            attrDef.setMatchingRuleQName(icfAttributeInfoToMatchingRule(attributeInfo));
            if (Name.NAME.equals(icfName)) {
                nameDefinition = attrDef;
                if (uidDefinition != null && attrXsdName.equals(uidDefinition.getName())) {
                    attrDef.setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_ORDER);
                    uidDefinition = attrDef;
                    hasUidDefinition = true;
                } else {
                    if (attributeInfo.getNativeName() == null) {
                        // Set a better display name for __NAME__. The "name" is s very
                        // overloaded term, so let's try to make things
                        // a bit clearer
                        attrDef.setDisplayName(ConnectorFactoryConnIdImpl.ICFS_NAME_DISPLAY_NAME);
                    }
                    attrDef.setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_NAME_DISPLAY_ORDER);
                }
            } else if (Uid.NAME.equals(icfName)) {
                // UID can be the same as other attribute
                ResourceAttributeDefinition existingDefinition = ocDef.findAttributeDefinition(attrXsdName);
                if (existingDefinition != null) {
                    hasUidDefinition = true;
                    ((ResourceAttributeDefinitionImpl) existingDefinition).setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_ORDER);
                    uidDefinition = existingDefinition;
                    continue;
                } else {
                    uidDefinition = attrDef;
                    if (attributeInfo.getNativeName() == null) {
                        attrDef.setDisplayName(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_NAME);
                    }
                    attrDef.setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_ORDER);
                }
            } else {
                // Check conflict with UID definition
                if (uidDefinition != null && attrXsdName.equals(uidDefinition.getName())) {
                    attrDef.setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_ORDER);
                    uidDefinition = attrDef;
                    hasUidDefinition = true;
                } else {
                    attrDef.setDisplayOrder(displayOrder);
                    displayOrder += ConnectorFactoryConnIdImpl.ATTR_DISPLAY_ORDER_INCREMENT;
                }
            }
            attrDef.setNativeAttributeName(attributeInfo.getNativeName());
            attrDef.setFrameworkAttributeName(icfName);
            // Now we are going to process flags such as optional and
            // multi-valued
            Set<Flags> flagsSet = attributeInfo.getFlags();
            // System.out.println(flagsSet);
            attrDef.setMinOccurs(0);
            attrDef.setMaxOccurs(1);
            boolean canCreate = true;
            boolean canUpdate = true;
            boolean canRead = true;
            for (Flags flags : flagsSet) {
                if (flags == Flags.REQUIRED) {
                    attrDef.setMinOccurs(1);
                }
                if (flags == Flags.MULTIVALUED) {
                    attrDef.setMaxOccurs(-1);
                }
                if (flags == Flags.NOT_CREATABLE) {
                    canCreate = false;
                }
                if (flags == Flags.NOT_READABLE) {
                    canRead = false;
                }
                if (flags == Flags.NOT_UPDATEABLE) {
                    canUpdate = false;
                }
                if (flags == Flags.NOT_RETURNED_BY_DEFAULT) {
                    attrDef.setReturnedByDefault(false);
                }
            }
            attrDef.setCanAdd(canCreate);
            attrDef.setCanModify(canUpdate);
            attrDef.setCanRead(canRead);
            if (!Uid.NAME.equals(icfName)) {
                ((ObjectClassComplexTypeDefinitionImpl) ocDef).add(attrDef);
            }
        }
        if (uidDefinition == null) {
            // Every object has UID in ICF, therefore add a default definition if no other was specified
            uidDefinition = new ResourceAttributeDefinitionImpl<>(SchemaConstants.ICFS_UID, DOMUtil.XSD_STRING, prismContext);
            // DO NOT make it mandatory. It must not be present on create hence it cannot be mandatory.
            ((ResourceAttributeDefinitionImpl) uidDefinition).setMinOccurs(0);
            ((ResourceAttributeDefinitionImpl) uidDefinition).setMaxOccurs(1);
            // Make it read-only
            ((ResourceAttributeDefinitionImpl) uidDefinition).setReadOnly();
            // Set a default display name
            ((ResourceAttributeDefinitionImpl) uidDefinition).setDisplayName(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_NAME);
            ((ResourceAttributeDefinitionImpl) uidDefinition).setDisplayOrder(ConnectorFactoryConnIdImpl.ICFS_UID_DISPLAY_ORDER);
        // Uid is a primary identifier of every object (this is the ICF way)
        }
        if (!hasUidDefinition) {
            ((ObjectClassComplexTypeDefinitionImpl) ocDef).add(uidDefinition);
        }
        ((ObjectClassComplexTypeDefinitionImpl) ocDef).addPrimaryIdentifier(uidDefinition);
        if (uidDefinition != nameDefinition) {
            ((ObjectClassComplexTypeDefinitionImpl) ocDef).addSecondaryIdentifier(nameDefinition);
        }
        // Add schema annotations
        ((ObjectClassComplexTypeDefinitionImpl) ocDef).setNativeObjectClass(objectClassInfo.getType());
        ((ObjectClassComplexTypeDefinitionImpl) ocDef).setDisplayNameAttribute(nameDefinition.getName());
        ((ObjectClassComplexTypeDefinitionImpl) ocDef).setNamingAttribute(nameDefinition.getName());
        ((ObjectClassComplexTypeDefinitionImpl) ocDef).setAuxiliary(objectClassInfo.isAuxiliary());
    }
    // This is the default for all resources.
    // (Currently there is no way how to obtain it from the connector.)
    // It can be disabled manually.
    AddRemoveAttributeValuesCapabilityType addRemove = new AddRemoveAttributeValuesCapabilityType();
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createAddRemoveAttributeValues(addRemove));
    ActivationCapabilityType capAct = null;
    if (enableAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationStatusCapabilityType capActStatus = new ActivationStatusCapabilityType();
        capAct.setStatus(capActStatus);
        if (!enableAttributeInfo.isReturnedByDefault()) {
            capActStatus.setReturnedByDefault(false);
        }
    }
    if (enableDateAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationValidityCapabilityType capValidFrom = new ActivationValidityCapabilityType();
        capAct.setValidFrom(capValidFrom);
        if (!enableDateAttributeInfo.isReturnedByDefault()) {
            capValidFrom.setReturnedByDefault(false);
        }
    }
    if (disableDateAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationValidityCapabilityType capValidTo = new ActivationValidityCapabilityType();
        capAct.setValidTo(capValidTo);
        if (!disableDateAttributeInfo.isReturnedByDefault()) {
            capValidTo.setReturnedByDefault(false);
        }
    }
    if (lockoutAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationLockoutStatusCapabilityType capActStatus = new ActivationLockoutStatusCapabilityType();
        capAct.setLockoutStatus(capActStatus);
        if (!lockoutAttributeInfo.isReturnedByDefault()) {
            capActStatus.setReturnedByDefault(false);
        }
    }
    if (capAct != null) {
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createActivation(capAct));
    }
    if (passwordAttributeInfo != null) {
        CredentialsCapabilityType capCred = new CredentialsCapabilityType();
        PasswordCapabilityType capPass = new PasswordCapabilityType();
        if (!passwordAttributeInfo.isReturnedByDefault()) {
            capPass.setReturnedByDefault(false);
        }
        if (passwordAttributeInfo.isReadable()) {
            capPass.setReadable(true);
        }
        capCred.setPassword(capPass);
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createCredentials(capCred));
    }
    if (auxiliaryObjectClasseAttributeInfo != null) {
        AuxiliaryObjectClassesCapabilityType capAux = new AuxiliaryObjectClassesCapabilityType();
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createAuxiliaryObjectClasses(capAux));
    }
    boolean canPageSize = false;
    boolean canPageOffset = false;
    boolean canSort = false;
    for (OperationOptionInfo searchOption : icfSchema.getSupportedOptionsByOperation(SearchApiOp.class)) {
        switch(searchOption.getName()) {
            case OperationOptions.OP_PAGE_SIZE:
                canPageSize = true;
                break;
            case OperationOptions.OP_PAGED_RESULTS_OFFSET:
                canPageOffset = true;
                break;
            case OperationOptions.OP_SORT_KEYS:
                canSort = true;
                break;
            case OperationOptions.OP_RETURN_DEFAULT_ATTRIBUTES:
                supportsReturnDefaultAttributes = true;
                break;
        }
    }
    if (canPageSize || canPageOffset || canSort) {
        PagedSearchCapabilityType capPage = new PagedSearchCapabilityType();
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createPagedSearch(capPage));
    }
}
Also used : PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) GuardedString(org.identityconnectors.common.security.GuardedString) AuxiliaryObjectClassesCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AuxiliaryObjectClassesCapabilityType) PagedSearchCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType) OperationOptionInfo(org.identityconnectors.framework.common.objects.OperationOptionInfo) ActivationValidityCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) AddRemoveAttributeValuesCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType) ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) ObjectClassInfo(org.identityconnectors.framework.common.objects.ObjectClassInfo) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) QName(javax.xml.namespace.QName) Flags(org.identityconnectors.framework.common.objects.AttributeInfo.Flags) AttributeInfo(org.identityconnectors.framework.common.objects.AttributeInfo)

Example 9 with ActivationStatusCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method getTransformedValue.

private boolean getTransformedValue(ProvisioningContext ctx, ActivationCapabilityType activationCapabilityType, ShadowType shadow, Object simulatedValue, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapabilityType, shadow, result);
    // TODO MID-3374: implement correctly (convert value list to native objects before comparison)
    String simulatedAttributeStringValue = String.valueOf(simulatedValue);
    List<String> disableValues = capActStatus.getDisableValue();
    for (String disable : disableValues) {
        if (disable.equals(simulatedAttributeStringValue)) {
            return false;
        }
    }
    List<String> enableValues = capActStatus.getEnableValue();
    for (String enable : enableValues) {
        if (enable.equals(simulatedAttributeStringValue)) {
            return true;
        }
    }
    throw new SchemaException("Could not map value for simulated activation: " + simulatedValue + " neither to enable nor disable values.");
}
Also used : ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 10 with ActivationStatusCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType in project midpoint by Evolveum.

the class ResourceObjectConverter method convertToSimulatedActivationAdministrativeStatusAttribute.

private PropertyModificationOperation convertToSimulatedActivationAdministrativeStatusAttribute(ProvisioningContext ctx, PropertyDelta activationDelta, ShadowType shadow, ActivationStatusType status, ActivationCapabilityType activationCapabilityType, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ResourceType resource = ctx.getResource();
    ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapabilityType, shadow, result);
    if (capActStatus == null) {
        throw new SchemaException("Attempt to modify activation on " + resource + " which does not have activation capability");
    }
    ResourceAttribute<?> simulatedAttribute = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result);
    if (simulatedAttribute == null) {
        return null;
    }
    Class<?> simulatedAttrValueClass = getAttributeValueClass(ctx, shadow, simulatedAttribute, capActStatus);
    PropertyDelta<?> simulatedAttrDelta;
    if (status == null && activationDelta.isDelete()) {
        LOGGER.trace("deleting activation property.");
        simulatedAttrDelta = PropertyDelta.createModificationDeleteProperty(new ItemPath(ShadowType.F_ATTRIBUTES, simulatedAttribute.getElementName()), simulatedAttribute.getDefinition(), simulatedAttribute.getRealValue());
    } else if (status == ActivationStatusType.ENABLED) {
        Object enableValue = getEnableValue(capActStatus, simulatedAttrValueClass);
        simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), enableValue);
    } else {
        Object disableValue = getDisableValue(capActStatus, simulatedAttrValueClass);
        simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), disableValue);
    }
    PropertyModificationOperation attributeChange = new PropertyModificationOperation(simulatedAttrDelta);
    return attributeChange;
}
Also used : ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)10 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)5 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)3 ActivationValidityCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType)3 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)2 SynchronizationIntent (com.evolveum.midpoint.model.impl.lens.SynchronizationIntent)2 ResourceActivationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType)2 ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)2 CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)2 PasswordCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType)2 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)1 ResourceBidirectionalMappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType)1 AddRemoveAttributeValuesCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType)1 AuxiliaryObjectClassesCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AuxiliaryObjectClassesCapabilityType)1 CreateCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)1 DeleteCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType)1 PagedSearchCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType)1