Search in sources :

Example 1 with AttributeDeltaBuilder

use of org.identityconnectors.framework.common.objects.AttributeDeltaBuilder in project midpoint by Evolveum.

the class DeltaModificationConverter method collect.

@Override
protected <T> void collect(String connIdAttrName, PropertyDelta<T> delta, PlusMinusZero isInModifiedAuxilaryClass, CollectorValuesConverter<T> valuesConverter) throws SchemaException {
    AttributeDeltaBuilder deltaBuilder = new AttributeDeltaBuilder();
    deltaBuilder.setName(connIdAttrName);
    if (delta.isAdd()) {
        List<Object> connIdAttributeValues = valuesConverter.covertAttributeValuesToConnId(delta.getValuesToAdd(), delta.getElementName());
        if (delta.getDefinition().isMultiValue()) {
            deltaBuilder.addValueToAdd(connIdAttributeValues);
        } else {
            // Force "update" for single-valued attributes instead of "add". This is saving one
            // read in some cases. It should also make no substantial difference in such case.
            // But it is working around some connector bugs.
            deltaBuilder.addValueToReplace(connIdAttributeValues);
        }
    }
    if (delta.isDelete()) {
        if (delta.getDefinition().isMultiValue() || isInModifiedAuxilaryClass == PlusMinusZero.MINUS) {
            List<Object> connIdAttributeValues = valuesConverter.covertAttributeValuesToConnId(delta.getValuesToDelete(), delta.getElementName());
            deltaBuilder.addValueToRemove(connIdAttributeValues);
        } else {
            // Force "update" for single-valued attributes instead of "add". This is saving one
            // read in some cases.
            // Update attribute to no values. This will efficiently clean up the attribute.
            // It should also make no substantial difference in such case.
            // But it is working around some connector bugs.
            // update with EMPTY value. The connIdAttributeValues is NOT used in this branch
            // Explicitly replace with empty list. Passing null here would mean "no replace in this delta".
            deltaBuilder.addValueToReplace(Collections.EMPTY_LIST);
        }
    }
    if (delta.isReplace()) {
        List<Object> connIdAttributeValues = valuesConverter.covertAttributeValuesToConnId(delta.getValuesToReplace(), delta.getElementName());
        if (isInModifiedAuxilaryClass == PlusMinusZero.PLUS) {
            deltaBuilder.addValueToAdd(connIdAttributeValues);
        } else {
            deltaBuilder.addValueToReplace(connIdAttributeValues);
        }
    }
    attributesDelta.add(deltaBuilder.build());
}
Also used : AttributeDeltaBuilder(org.identityconnectors.framework.common.objects.AttributeDeltaBuilder)

Example 2 with AttributeDeltaBuilder

use of org.identityconnectors.framework.common.objects.AttributeDeltaBuilder in project midpoint by Evolveum.

the class DeltaModificationConverter method collectPasswordDelta.

protected void collectPasswordDelta(String connIdAttrName, PropertyDelta<ProtectedStringType> delta, PlusMinusZero isInModifiedAuxilaryClass, CollectorValuesConverter<ProtectedStringType> valuesConverter) throws SchemaException {
    AttributeDeltaBuilder deltaBuilder = new AttributeDeltaBuilder();
    deltaBuilder.setName(connIdAttrName);
    List<Object> newPasswordConnIdValues = valuesConverter.covertAttributeValuesToConnId(delta.getValuesToReplace(), delta.getElementName());
    if (isSelfPasswordChange(delta)) {
        // Self-service password *change*
        List<Object> oldPasswordConnIdValues = valuesConverter.covertAttributeValuesToConnId(delta.getEstimatedOldValues(), delta.getElementName());
        deltaBuilder.addValueToAdd(newPasswordConnIdValues);
        deltaBuilder.addValueToRemove(oldPasswordConnIdValues);
    } else {
        // Password *reset*
        deltaBuilder.addValueToReplace(newPasswordConnIdValues);
    }
    attributesDelta.add(deltaBuilder.build());
}
Also used : AttributeDeltaBuilder(org.identityconnectors.framework.common.objects.AttributeDeltaBuilder)

Example 3 with AttributeDeltaBuilder

use of org.identityconnectors.framework.common.objects.AttributeDeltaBuilder in project midpoint by Evolveum.

the class DeltaModificationConverter method collectPassword.

@Override
protected void collectPassword(PropertyDelta<ProtectedStringType> passwordDelta) throws SchemaException {
    if (isSelfPasswordChange(passwordDelta)) {
        AttributeDeltaBuilder deltaBuilder = new AttributeDeltaBuilder();
        deltaBuilder.setName(OperationalAttributes.PASSWORD_NAME);
        PrismProperty<ProtectedStringType> newPasswordProperty = passwordDelta.getPropertyNewMatchingPath();
        GuardedString newPasswordGs = passwordToGuardedString(newPasswordProperty.getRealValue(), "new password");
        deltaBuilder.addValueToAdd(newPasswordGs);
        ProtectedStringType oldPasswordPs = passwordDelta.getEstimatedOldValues().iterator().next().getRealValue();
        GuardedString oldPasswordGs = passwordToGuardedString(oldPasswordPs, "old password");
        deltaBuilder.addValueToRemove(oldPasswordGs);
        attributesDelta.add(deltaBuilder.build());
    } else {
        super.collectPassword(passwordDelta);
    }
}
Also used : AttributeDeltaBuilder(org.identityconnectors.framework.common.objects.AttributeDeltaBuilder) GuardedString(org.identityconnectors.common.security.GuardedString) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Aggregations

AttributeDeltaBuilder (org.identityconnectors.framework.common.objects.AttributeDeltaBuilder)3 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)1 GuardedString (org.identityconnectors.common.security.GuardedString)1