Search in sources :

Example 11 with IcAttribute

use of eu.bcvsolutions.idm.ic.api.IcAttribute 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);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(attributes);
    LOG.debug("Create object - ConnId ({} {})", connectorInstance.getConnectorKey().toString(), attributes.toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    Set<Attribute> connIdAttributes = new HashSet<>();
    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, null);
    LOG.debug("Created object - ConnId ({} {}) Uid= {}", connectorInstance.getConnectorKey().toString(), attributes.toString(), uid);
    return ConnIdIcConvertUtil.convertConnIdUid(uid);
}
Also used : 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 12 with IcAttribute

use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.

the class IcComparableAttributeFilter method compare.

/**
 * Call compareTo on the attribute values. If the attribute is not present
 * in the {@link IcConnectorObject} return -1.
 */
public int compare(IcConnectorObject obj) {
    int ret = -1;
    IcAttribute attr = obj.getAttributeByName(getName());
    if (attr != null && attr.getValues().size() == 1) {
        // it must be a comparable because that's were testing against
        if (!(attr.getValues().get(0) instanceof Comparable)) {
            throw new IllegalArgumentException("Attribute value must be comparable!");
        }
        // grab this value and the on from the attribute an compare..
        Object o1 = attr.getValues().get(0);
        Object o2 = getValue();
        ret = CollectionUtil.forceCompare(o1, o2);
    }
    return ret;
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject)

Example 13 with IcAttribute

use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.

the class IcEqualsFilter method accept.

/**
 * Determines whether the specified {@link IcConnectorObject} contains an
 * attribute that has the same name and contains a value that is equals the
 * value of the attribute that {@code IcFilterBuilder} placed into this
 * filter.
 * <p>
 * Note that in the case of a multi-valued attribute, equality of values
 * means that:
 * <ul>
 * <li>the value of the attribute in the connector object and the value of
 * the attribute in the filter must contain
 * <em>the same number of elements</em>; and that</li>
 * <li>each element within the value of the attribute in the connector
 * object must <em>equal the element that occupies the same position</em>
 * within the value of the attribute in the filter.</li>
 * </ul>
 *
 * @see IcFilter#accept(IcConnectorObject)
 */
@Override
public boolean accept(IcConnectorObject obj) {
    boolean ret = false;
    IcAttribute thisAttr = getAttribute();
    IcAttribute attr = obj.getAttributeByName(thisAttr.getName());
    if (attr != null) {
        ret = thisAttr.equals(attr);
    }
    return ret;
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute)

Example 14 with IcAttribute

use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method internalUpdate.

@Override
public IcUidAttribute internalUpdate(IcUidAttribute uid, IcObjectClass objectClass, List<IcAttribute> attributes) {
    Assert.notNull(objectClass, "Object class cannot be null!");
    Assert.notNull(attributes, "Attributes cannot be null!");
    Assert.notNull(uid, "UID cannot be null!");
    if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
        throw new IcException("Only ACCOUNT object class is supported now!");
    }
    String uidValue = uid.getUidValue();
    if (uidValue == null) {
        throw new IcException("UID value cannot be null!");
    }
    // Find account by UID and System ID
    VsAccountDto account = accountService.findByUidSystem(uidValue, systemId);
    if (account == null) {
        throw new IcException(MessageFormat.format("Vs account was not found for UID [{0}] and system ID [{1}]!", uidValue, systemId));
    }
    // Update UID - if is different
    IcAttribute uidAttribute = geAttribute(attributes, IcAttributeInfo.NAME);
    if (uidAttribute != null) {
        Object attributeUidValue = uidAttribute.getValue();
        if (!(attributeUidValue instanceof String)) {
            throw new IcException(MessageFormat.format("UID attribute value [{0}] must be String!", attributeUidValue));
        }
        if (!uidValue.equals(attributeUidValue)) {
            // TODO: Connector not supported more entity types!
            LOG.info("Update account - UID is different (old: {} new: {})", uidValue, attributeUidValue);
            account.setUid((String) attributeUidValue);
            account = accountService.save(account);
            // We have to change system entity directly from VS module
            // (request can be started/executed async => standard
            // process update UID in system entity (ACC module) will not
            // works!)
            updateSystemEntity(uidValue, attributeUidValue, true);
        }
    }
    // Update ENABLE - if is different
    IcAttribute enableAttribute = geAttribute(attributes, IcAttributeInfo.ENABLE);
    if (enableAttribute != null && this.virtualConfiguration.isDisableSupported()) {
        Object attributeEnableValue = enableAttribute.getValue();
        if (!(attributeEnableValue instanceof Boolean)) {
            throw new IcException(MessageFormat.format("ENABLE attribute value [{0}] must be Boolean!", attributeEnableValue));
        }
        if (account.isEnable() != (Boolean) attributeEnableValue) {
            account.setEnable((Boolean) attributeEnableValue);
            account = accountService.save(account);
        }
    }
    UUID accountId = account.getId();
    // Update extended attributes
    Arrays.asList(virtualConfiguration.getAttributes()).forEach(virtualAttirbute -> {
        updateFormAttributeValue(uidValue, virtualAttirbute, accountId, attributes);
    });
    return new IcUidAttributeImpl(IcAttributeInfo.NAME, account.getUid(), null);
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) UUID(java.util.UUID)

Example 15 with IcAttribute

use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method updateFormAttributeValue.

private void updateFormAttributeValue(Object uidValue, String virtualAttirbute, UUID accountId, List<IcAttribute> attributes) {
    IcAttribute attribute = geAttribute(attributes, virtualAttirbute);
    if (attribute == null) {
        return;
    }
    List<Object> values = attribute.getValues();
    List<Serializable> serializableValues = new ArrayList<>();
    if (values != null) {
        values.forEach(value -> {
            if (!(value instanceof Serializable)) {
                throw new IcException(MessageFormat.format("Ic attribute value [{0}] is not Serializable! For account with UID [{1}].", value, uidValue));
            }
            serializableValues.add((Serializable) value);
        });
    }
    formService.saveValues(accountId, VsAccount.class, this.formDefinition, virtualAttirbute, serializableValues);
}
Also used : Serializable(java.io.Serializable) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) ArrayList(java.util.ArrayList) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcException(eu.bcvsolutions.idm.ic.exception.IcException)

Aggregations

IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)36 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 ArrayList (java.util.ArrayList)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 UUID (java.util.UUID)12 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)11 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)10 IcConnectorFacade (eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade)10 List (java.util.List)10 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)9 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)9 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)9 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)9 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)8