Search in sources :

Example 31 with Attribute

use of org.identityconnectors.framework.common.objects.Attribute in project syncope by apache.

the class TaskTest method savePropagationTask.

@Test
public void savePropagationTask() {
    ExternalResource resource = resourceDAO.find("ws-target-resource-1");
    assertNotNull(resource);
    User user = userDAO.find("74cd8ece-715a-44a4-a736-e17b46c4e7e6");
    assertNotNull(user);
    PropagationTask task = entityFactory.newEntity(PropagationTask.class);
    task.setResource(resource);
    task.setAnyTypeKind(AnyTypeKind.USER);
    task.setAnyType(AnyTypeKind.USER.name());
    task.setOperation(ResourceOperation.CREATE);
    task.setConnObjectKey("one@two.com");
    Set<Attribute> attributes = new HashSet<>();
    attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
    attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
    task.setAttributes(attributes);
    task = taskDAO.save(task);
    assertNotNull(task);
    PropagationTask actual = taskDAO.find(task.getKey());
    assertEquals(task, actual);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) Attribute(org.identityconnectors.framework.common.objects.Attribute) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 32 with Attribute

use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertIcFilter.

public static Filter convertIcFilter(IcFilter filter) {
    if (filter == null) {
        return null;
    }
    if (filter instanceof IcAndFilter) {
        List<IcFilter> subFilters = (List<IcFilter>) ((IcAndFilter) filter).getFilters();
        LinkedList<Filter> subFiltersConnId = new LinkedList<>();
        if (!subFilters.isEmpty()) {
            subFilters.forEach(subFilter -> {
                subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
            });
        }
        return new AndFilter(subFiltersConnId);
    }
    if (filter instanceof IcOrFilter) {
        List<IcFilter> subFilters = (List<IcFilter>) ((IcOrFilter) filter).getFilters();
        LinkedList<Filter> subFiltersConnId = new LinkedList<>();
        if (!subFilters.isEmpty()) {
            subFilters.forEach(subFilter -> {
                subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
            });
        }
        return new OrFilter(subFiltersConnId);
    }
    if (filter instanceof IcNotFilter) {
        return new NotFilter(ConnIdIcConvertUtil.convertIcFilter(((IcNotFilter) filter).getFilter()));
    }
    if (filter instanceof IcAttributeFilter) {
        Attribute attr = ConnIdIcConvertUtil.convertIcAttribute(((IcAttributeFilter) filter).getAttribute());
        if (filter instanceof IcEqualsFilter) {
            return new EqualsFilter(attr);
        }
        if (filter instanceof IcContainsFilter) {
            return new ContainsFilter(attr);
        }
        if (filter instanceof IcEndsWithFilter) {
            return new EndsWithFilter(attr);
        }
        if (filter instanceof IcContainsAllValuesFilter) {
            return new ContainsAllValuesFilter(attr);
        }
        if (filter instanceof IcStartsWithFilter) {
            return new StartsWithFilter(attr);
        }
        if (filter instanceof IcGreaterThanFilter) {
            return new GreaterThanFilter(attr);
        }
        if (filter instanceof IcLessThanFilter) {
            return new LessThanFilter(attr);
        }
    }
    return null;
}
Also used : IcEnabledAttribute(eu.bcvsolutions.idm.ic.api.IcEnabledAttribute) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcLoginAttribute(eu.bcvsolutions.idm.ic.api.IcLoginAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) ContainsFilter(org.identityconnectors.framework.common.objects.filter.ContainsFilter) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EqualsFilter(org.identityconnectors.framework.common.objects.filter.EqualsFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) IcAttributeFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAttributeFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) OrFilter(org.identityconnectors.framework.common.objects.filter.OrFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) EndsWithFilter(org.identityconnectors.framework.common.objects.filter.EndsWithFilter) LinkedList(java.util.LinkedList) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) AndFilter(org.identityconnectors.framework.common.objects.filter.AndFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) LessThanFilter(org.identityconnectors.framework.common.objects.filter.LessThanFilter) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) Filter(org.identityconnectors.framework.common.objects.filter.Filter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) ContainsAllValuesFilter(org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) NotFilter(org.identityconnectors.framework.common.objects.filter.NotFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) IcAttributeFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAttributeFilter) EqualsFilter(org.identityconnectors.framework.common.objects.filter.EqualsFilter) EndsWithFilter(org.identityconnectors.framework.common.objects.filter.EndsWithFilter) StartsWithFilter(org.identityconnectors.framework.common.objects.filter.StartsWithFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) LessThanFilter(org.identityconnectors.framework.common.objects.filter.LessThanFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) AndFilter(org.identityconnectors.framework.common.objects.filter.AndFilter) ContainsFilter(org.identityconnectors.framework.common.objects.filter.ContainsFilter) GreaterThanFilter(org.identityconnectors.framework.common.objects.filter.GreaterThanFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) OrFilter(org.identityconnectors.framework.common.objects.filter.OrFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) StartsWithFilter(org.identityconnectors.framework.common.objects.filter.StartsWithFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) NotFilter(org.identityconnectors.framework.common.objects.filter.NotFilter) GreaterThanFilter(org.identityconnectors.framework.common.objects.filter.GreaterThanFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) ContainsAllValuesFilter(org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter)

Example 33 with Attribute

use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.

the class ConnIdIcConnectorService method updateObject.

@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
    Assert.notNull(connectorInstance, "Connector instance is required.");
    Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
    Assert.notNull(connectorConfiguration, "Configuration is required.");
    Assert.notNull(replaceAttributes, "Replace attributes are required.");
    Assert.notNull(uid, "Uid is required.");
    LOG.debug("Update object - ConnId (Uid= {} {} {})", uid, connectorInstance.getConnectorKey().toString(), replaceAttributes.toString());
    ConnectorFacade conn = facadeFactory.getConnectorFacade(connectorInstance, connectorConfiguration);
    Set<Attribute> connIdAttributes = new HashSet<>(replaceAttributes.size());
    for (IcAttribute icAttribute : replaceAttributes) {
        connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
    }
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    Uid updatedUid = conn.update(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), connIdAttributes, new OperationOptions(connectorConfiguration.getSystemOperationOptions()));
    LOG.debug("Updated object - ConnId ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
    return ConnIdIcConvertUtil.convertConnIdUid(updatedUid);
}
Also used : OperationOptions(org.identityconnectors.framework.common.objects.OperationOptions) Uid(org.identityconnectors.framework.common.objects.Uid) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade) HashSet(java.util.HashSet)

Example 34 with Attribute

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

the class ConnIdUtil method dump.

public static String dump(Set<Attribute> attributes) {
    StringBuilder sb = new StringBuilder();
    for (Attribute attr : attributes) {
        DebugUtil.indentDebugDump(sb, 1);
        sb.append(attr.getClass().getSimpleName()).append("(");
        sb.append("name=").append(attr.getName());
        List<Object> value = attr.getValue();
        sb.append(", value=").append(value);
        if (value != null && !value.isEmpty()) {
            sb.append(", type=").append(value.iterator().next().getClass().getSimpleName());
        }
        sb.append(")\n");
    }
    return sb.toString();
}
Also used : Attribute(org.identityconnectors.framework.common.objects.Attribute)

Example 35 with Attribute

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

the class ValueOperation method interpret.

@Override
public <T> Filter interpret(ObjectFilter objectFilter, ConnIdNameMapper icfNameMapper) throws SchemaException {
    ValueFilter valueFilter = (ValueFilter) objectFilter;
    if (valueFilter.getParentPath().isEmpty()) {
        throw new UnsupportedOperationException("Empty path is not supported (filter: " + objectFilter + ")");
    }
    if (valueFilter.getParentPath().equivalent(ShadowType.F_ATTRIBUTES)) {
        try {
            QName propName = valueFilter.getDefinition().getItemName();
            String icfName = icfNameMapper.convertAttributeNameToConnId(propName, getInterpreter().getObjectDefinition(), "(attribute in the filter)");
            if (objectFilter instanceof EqualFilter) {
                EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
                Collection<Object> convertedValues = convertValues(propName, eq.getValues());
                if (convertedValues == null || convertedValues.isEmpty()) {
                    Attribute attr = AttributeBuilder.build(icfName);
                    return FilterBuilder.equalTo(attr);
                } else {
                    Attribute attr = AttributeBuilder.build(icfName, convertedValues);
                    if (valueFilter.getDefinition().isSingleValue()) {
                        return FilterBuilder.equalTo(attr);
                    } else {
                        // "Values stored under specified key on the resource contain this single value."
                        return FilterBuilder.containsAllValues(attr);
                    }
                }
            } else if (objectFilter instanceof SubstringFilter) {
                SubstringFilter substring = (SubstringFilter) objectFilter;
                Collection<Object> convertedValues = convertValues(propName, substring.getValues());
                if (convertedValues == null || convertedValues.isEmpty()) {
                    throw new IllegalArgumentException("Substring filter with null value makes no sense");
                } else {
                    if (convertedValues.size() != 1) {
                        throw new IllegalArgumentException("Substring filter with multiple values makes no sense");
                    // maybe it does, through OR clauses
                    }
                    if (substring.isAnchorStart() && !substring.isAnchorEnd()) {
                        return FilterBuilder.startsWith(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
                    } else if (!substring.isAnchorStart() && substring.isAnchorEnd()) {
                        return FilterBuilder.endsWith(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
                    } else if (!substring.isAnchorStart() && !substring.isAnchorEnd()) {
                        return FilterBuilder.contains(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
                    } else {
                        return FilterBuilder.equalTo(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
                    }
                }
            } else if (objectFilter instanceof ComparativeFilter) {
                ComparativeFilter comparativeFilter = (ComparativeFilter) objectFilter;
                Collection<Object> convertedValues = convertValues(propName, comparativeFilter.getValues());
                if (convertedValues == null || convertedValues.isEmpty()) {
                    throw new IllegalArgumentException("Comparative filter with null value makes no sense");
                } else {
                    if (convertedValues.size() != 1) {
                        throw new IllegalArgumentException("Comparative filter with multiple values makes no sense");
                    }
                    Attribute attribute = AttributeBuilder.build(icfName, convertedValues.iterator().next());
                    if (comparativeFilter instanceof GreaterFilter) {
                        if (comparativeFilter.isEquals()) {
                            return FilterBuilder.greaterThanOrEqualTo(attribute);
                        } else {
                            return FilterBuilder.greaterThan(attribute);
                        }
                    } else if (comparativeFilter instanceof LessFilter) {
                        if (comparativeFilter.isEquals()) {
                            return FilterBuilder.lessThanOrEqualTo(attribute);
                        } else {
                            return FilterBuilder.lessThan(attribute);
                        }
                    } else {
                        throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter);
                    }
                }
            } else {
                throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter);
            }
        } catch (SchemaException ex) {
            throw ex;
        }
    } else if (valueFilter.getParentPath().equivalent(ShadowType.F_ACTIVATION)) {
        if (objectFilter instanceof EqualFilter) {
            QName propName = valueFilter.getDefinition().getItemName();
            EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
            List<PrismPropertyValue<T>> values = eq.getValues();
            if (values == null || values.size() != 1) {
                throw new SchemaException("Unexpected number of values in filter " + objectFilter);
            }
            PrismPropertyValue<T> pval = values.get(0);
            String icfName;
            Object convertedValue;
            if (propName.equals(ActivationType.F_ADMINISTRATIVE_STATUS)) {
                icfName = OperationalAttributes.ENABLE_NAME;
                convertedValue = pval.getValue() == ActivationStatusType.ENABLED;
            } else if (propName.equals(ActivationType.F_LOCKOUT_STATUS)) {
                icfName = OperationalAttributes.LOCK_OUT_NAME;
                convertedValue = pval.getValue() == LockoutStatusType.LOCKED;
            } else {
                throw new UnsupportedOperationException("Unsupported activation property " + propName + " in filter: " + objectFilter);
            }
            Attribute attr = AttributeBuilder.build(icfName, convertedValue);
            if (valueFilter.getDefinition().isSingleValue()) {
                return FilterBuilder.equalTo(attr);
            } else {
                return FilterBuilder.containsAllValues(attr);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported filter type in filter: " + objectFilter);
        }
    } else {
        throw new UnsupportedOperationException("Unsupported parent path " + valueFilter.getParentPath() + " in filter: " + objectFilter);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Attribute(org.identityconnectors.framework.common.objects.Attribute) QName(javax.xml.namespace.QName) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

Attribute (org.identityconnectors.framework.common.objects.Attribute)35 HashSet (java.util.HashSet)19 ArrayList (java.util.ArrayList)14 ConnectorObject (org.identityconnectors.framework.common.objects.ConnectorObject)12 Transactional (org.springframework.transaction.annotation.Transactional)12 User (org.apache.syncope.core.persistence.api.entity.user.User)11 List (java.util.List)10 Set (java.util.Set)10 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)10 Uid (org.identityconnectors.framework.common.objects.Uid)10 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)9 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)8 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)8 Name (org.identityconnectors.framework.common.objects.Name)8 AttributeBuilder (org.identityconnectors.framework.common.objects.AttributeBuilder)7 Map (java.util.Map)6 StringUtils (org.apache.commons.lang3.StringUtils)6 GroupDAO (org.apache.syncope.core.persistence.api.dao.GroupDAO)6 UserDAO (org.apache.syncope.core.persistence.api.dao.UserDAO)6 OrgUnitItem (org.apache.syncope.core.persistence.api.entity.resource.OrgUnitItem)6