Search in sources :

Example 31 with IcAttribute

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

the class IdentitySynchronizationExecutor method doUpdateEntity.

/**
 * Fill data from IC attributes to entity (EAV and confidential storage too)
 *
 * @param account
 * @param entityType
 * @param uid
 * @param icAttributes
 * @param mappedAttributes
 * @param log
 * @param logItem
 * @param actionLogs
 */
protected void doUpdateEntity(SynchronizationContext context) {
    String uid = context.getUid();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    List<SysSystemAttributeMappingDto> mappedAttributes = context.getMappedAttributes();
    AccAccountDto account = context.getAccount();
    List<IcAttribute> icAttributes = context.getIcObject().getAttributes();
    SystemEntityType entityType = context.getEntityType();
    UUID entityId = getEntityByAccount(account.getId());
    IdmIdentityDto identity = null;
    if (entityId != null) {
        identity = identityService.get(entityId);
    }
    if (identity != null) {
        // Update identity
        identity = fillEntity(mappedAttributes, uid, icAttributes, identity, false, context);
        identity = this.save(identity, true);
        // Update extended attribute (entity must be persisted first)
        updateExtendedAttributes(mappedAttributes, uid, icAttributes, identity, false, context);
        // Update confidential attribute (entity must be persisted
        // first)
        updateConfidentialAttributes(mappedAttributes, uid, icAttributes, identity, false, context);
        // Identity Updated
        addToItemLog(logItem, MessageFormat.format("Identity with id {0} was updated", identity.getId()));
        if (logItem != null) {
            logItem.setDisplayName(identity.getUsername());
        }
        // Call provisioning for entity
        this.callProvisioningForEntity(identity, entityType, logItem);
        return;
    } else {
        addToItemLog(logItem, "Identity account relation (with ownership = true) was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 32 with IcAttribute

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

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

the class IcAttributeFilter method isPresent.

/**
 * Determines if the attribute provided is present in the
 * {@link IcConnectorObject}.
 */
public boolean isPresent(IcConnectorObject obj) {
    Optional<IcAttribute> optionalAttr = obj.getAttributes().stream().filter(attribute -> {
        return getName().equals(this.attr.getName());
    }).findFirst();
    IcAttribute attr = optionalAttr.isPresent() ? optionalAttr.get() : null;
    return attr != null;
}
Also used : IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Optional(java.util.Optional) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute)

Example 34 with IcAttribute

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

the class IcStringFilter method accept.

/**
 * @throws ClassCastException
 *             if the value from the {@link IcConnectorObject}'s attribute of
 *             the same name as provided is not a string.
 */
@Override
public boolean accept(IcConnectorObject obj) {
    boolean ret = false;
    IcAttribute attr = obj.getAttributeByName(getName());
    if (attr != null) {
        ret = accept((String) attr.getValues().get(0));
    }
    return ret;
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute)

Example 35 with IcAttribute

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

the class BasicVirtualConnector method create.

@Override
public IcUidAttribute create(IcObjectClass objectClass, List<IcAttribute> attributes) {
    Assert.notNull(objectClass, "Object class cannot be null!");
    Assert.notNull(attributes, "Attributes cannot be null!");
    if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
        throw new IcException("Only ACCOUNT object class is supported now!");
    }
    IcAttribute uidAttribute = geAttribute(attributes, IcAttributeInfo.NAME);
    if (uidAttribute == null) {
        throw new IcException("UID attribute was not found!");
    }
    Object uidValue = uidAttribute.getValue();
    if (!(uidValue instanceof String)) {
        throw new IcException(MessageFormat.format("UID attribute value [{0}] must be String!", uidValue));
    }
    // Create and execute request
    VsRequestDto request = createRequest(objectClass, attributes, (String) uidValue, VsOperationType.CREATE);
    return requestService.execute(request);
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto)

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