Search in sources :

Example 16 with Attribute

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

the class DefaultPullCorrelationRule method getSearchCond.

@Override
public SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision) {
    Map<String, Item> mappingItems = provision.getMapping().getItems().stream().collect(Collectors.toMap(Item::getIntAttrName, Function.identity()));
    // search for anys by attribute(s) specified in the policy
    SearchCond searchCond = null;
    for (String schema : conf.getSchemas()) {
        Item mappingItem = mappingItems.get(schema);
        Attribute attr = mappingItem == null ? null : connObj.getAttributeByName(mappingItem.getExtAttrName());
        if (attr == null) {
            throw new IllegalArgumentException("Connector object does not contains the attributes to perform the search: " + schema);
        }
        AttributeCond.Type type;
        String expression = null;
        if (attr.getValue() == null || attr.getValue().isEmpty() || (attr.getValue().size() == 1 && attr.getValue().get(0) == null)) {
            type = AttributeCond.Type.ISNULL;
        } else {
            type = AttributeCond.Type.EQ;
            expression = attr.getValue().size() > 1 ? attr.getValue().toString() : attr.getValue().get(0).toString();
        }
        SearchCond nodeCond;
        // any objects: just key or name can be selected
        if ("key".equalsIgnoreCase(schema) || "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema)) {
            AnyCond cond = new AnyCond();
            cond.setSchema(schema);
            cond.setType(type);
            cond.setExpression(expression);
            nodeCond = SearchCond.getLeafCond(cond);
        } else {
            AttributeCond cond = new AttributeCond();
            cond.setSchema(schema);
            cond.setType(type);
            cond.setExpression(expression);
            nodeCond = SearchCond.getLeafCond(cond);
        }
        searchCond = searchCond == null ? nodeCond : SearchCond.getAndCond(searchCond, nodeCond);
    }
    return searchCond;
}
Also used : Item(org.apache.syncope.core.persistence.api.entity.resource.Item) Attribute(org.identityconnectors.framework.common.objects.Attribute) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond)

Example 17 with Attribute

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

the class MigrationPullActions method after.

@Transactional
@Override
public void after(final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final EntityTO entity, final ProvisioningReport result) throws JobExecutionException {
    if (entity instanceof UserTO) {
        // handles ciphered password import
        CipherAlgorithm cipherAlgorithm = null;
        Attribute cipherAlgorithmAttr = delta.getObject().getAttributeByName(CIPHER_ALGORITHM_ATTR);
        if (cipherAlgorithmAttr != null && cipherAlgorithmAttr.getValue() != null && !cipherAlgorithmAttr.getValue().isEmpty()) {
            cipherAlgorithm = CipherAlgorithm.valueOf(cipherAlgorithmAttr.getValue().get(0).toString());
        }
        GuardedString passwordValue = AttributeUtil.getPasswordValue(delta.getObject().getAttributes());
        if (cipherAlgorithm != null && passwordValue != null) {
            User user = userDAO.find(entity.getKey());
            LOG.debug("Setting encoded password for {}", user);
            user.setEncodedPassword(SecurityUtil.decrypt(passwordValue), cipherAlgorithm);
        }
    } else if (entity instanceof GroupTO) {
        // handles group membership
        Attribute membershipsAttr = delta.getObject().getAttributeByName(MEMBERSHIPS_ATTR);
        if (membershipsAttr != null && membershipsAttr.getValue() != null && !membershipsAttr.getValue().isEmpty()) {
            LOG.debug("Found {} for group {}", MEMBERSHIPS_ATTR, entity.getKey());
            for (Object membership : membershipsAttr.getValue()) {
                User member = userDAO.findByUsername(membership.toString());
                if (member == null) {
                    LOG.warn("Could not find member {} for group {}", membership, entity.getKey());
                } else {
                    Set<String> memb = memberships.get(member.getKey());
                    if (memb == null) {
                        memb = new HashSet<>();
                        memberships.put(member.getKey(), memb);
                    }
                    memb.add(entity.getKey());
                }
            }
        }
    } else {
        super.after(profile, delta, entity, result);
    }
}
Also used : CipherAlgorithm(org.apache.syncope.common.lib.types.CipherAlgorithm) User(org.apache.syncope.core.persistence.api.entity.user.User) HashSet(java.util.HashSet) Set(java.util.Set) Attribute(org.identityconnectors.framework.common.objects.Attribute) UserTO(org.apache.syncope.common.lib.to.UserTO) GuardedString(org.identityconnectors.common.security.GuardedString) GroupTO(org.apache.syncope.common.lib.to.GroupTO) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Attribute

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

the class ConnIdUtil method dump.

private static void dump(Filter filter, StringBuilder sb, int indent) {
    DebugUtil.indentDebugDump(sb, indent);
    if (filter == null) {
        sb.append("null");
        return;
    }
    sb.append(filter.toString());
    if (filter instanceof AttributeFilter) {
        sb.append("(");
        Attribute attribute = ((AttributeFilter) filter).getAttribute();
        sb.append(attribute.getName());
        sb.append(": ");
        List<Object> value = attribute.getValue();
        sb.append(value);
        // if (value != null && !value.isEmpty()) {
        // sb.append(" :").append(attribute.getValue().iterator().next().getClass().getSimpleName());
        // }
        sb.append(")");
    }
    if (filter instanceof CompositeFilter) {
        for (Filter subfilter : ((CompositeFilter) filter).getFilters()) {
            sb.append("\n");
            dump(subfilter, sb, indent + 1);
        }
    }
}
Also used : CompositeFilter(org.identityconnectors.framework.common.objects.filter.CompositeFilter) Attribute(org.identityconnectors.framework.common.objects.Attribute) Filter(org.identityconnectors.framework.common.objects.filter.Filter) CompositeFilter(org.identityconnectors.framework.common.objects.filter.CompositeFilter) AttributeFilter(org.identityconnectors.framework.common.objects.filter.AttributeFilter) AttributeFilter(org.identityconnectors.framework.common.objects.filter.AttributeFilter)

Example 19 with Attribute

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

the class ConnIdIcConnectorService method createObject.

@Override
public IcUidAttribute createObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, List<IcAttribute> attributes) {
    Assert.notNull(connectorInstance, "Connector instance is required.");
    Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
    Assert.notNull(connectorConfiguration, "Configuration is required.");
    Assert.notNull(attributes, "Attributes are required.");
    LOG.debug("Create object - ConnId ({} {})", connectorInstance.getConnectorKey().toString(), attributes.toString());
    ConnectorFacade conn = facadeFactory.getConnectorFacade(connectorInstance, connectorConfiguration);
    Set<Attribute> connIdAttributes = new HashSet<>(attributes.size());
    for (IcAttribute icAttribute : attributes) {
        connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
    }
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    Uid uid = conn.create(objectClassConnId, connIdAttributes, new OperationOptions(connectorConfiguration.getSystemOperationOptions()));
    LOG.debug("Created object - ConnId ({} {}) Uid= {}", connectorInstance.getConnectorKey().toString(), attributes.toString(), uid);
    return ConnIdIcConvertUtil.convertConnIdUid(uid);
}
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 20 with Attribute

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

the class ConnIdIcConvertUtil method convertConnIdConnectorObject.

public static IcConnectorObject convertConnIdConnectorObject(ConnectorObject connObject) {
    if (connObject == null) {
        return null;
    }
    IcObjectClass icClass = ConnIdIcConvertUtil.convertConnIdObjectClass(connObject.getObjectClass());
    Set<Attribute> attributes = connObject.getAttributes();
    List<IcAttribute> icAttributes = new ArrayList<>();
    if (attributes != null) {
        for (Attribute a : attributes) {
            icAttributes.add(ConnIdIcConvertUtil.convertConnIdAttribute(a));
        }
    }
    return new IcConnectorObjectImpl(connObject.getUid().getUidValue(), icClass, icAttributes);
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) 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) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) ArrayList(java.util.ArrayList) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

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