Search in sources :

Example 11 with IcConnectorObject

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

the class AbstractSynchronizationExecutor method doItemSynchronization.

@Override
public boolean doItemSynchronization(SynchronizationContext context) {
    Assert.notNull(context);
    String uid = context.getUid();
    IcConnectorObject icObject = context.getIcObject();
    IcSyncDeltaTypeEnum type = context.getType();
    AbstractSysSyncConfigDto config = context.getConfig();
    SysSystemDto system = context.getSystem();
    SystemEntityType entityType = context.getEntityType();
    AccAccountDto account = context.getAccount();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    // Set default unknown action type
    context.addActionType(SynchronizationActionType.UNKNOWN);
    try {
        // Find system entity for uid
        SysSystemEntityDto systemEntity = findSystemEntity(uid, system, entityType);
        context.addSystemEntity(systemEntity);
        // Find acc account for uid or system entity
        if (account == null) {
            account = findAccount(context);
            if (systemEntity == null) {
                addToItemLog(logItem, "SystemEntity for this uid doesn't exist. We will create it.");
                systemEntity = createSystemEntity(uid, entityType, system);
            }
        }
        context.addSystemEntity(systemEntity).addAccount(account);
        if (IcSyncDeltaTypeEnum.CREATE == type || IcSyncDeltaTypeEnum.UPDATE == type || IcSyncDeltaTypeEnum.CREATE_OR_UPDATE == type) {
            // Update or create
            Assert.notNull(icObject);
            List<IcAttribute> icAttributes = icObject.getAttributes();
            if (account == null) {
                // Account doesn't exist in IDM
                resolveAccountNotExistSituation(context, systemEntity, icAttributes);
            } else {
                // Account exist in IdM (LINKED)
                context.addActionType(config.getLinkedAction().getAction());
                SynchronizationSituationType situation = SynchronizationSituationType.LINKED;
                if (StringUtils.hasLength(config.getLinkedActionWfKey())) {
                    SynchronizationLinkedActionType linkedAction = config.getLinkedAction();
                    SynchronizationActionType action = linkedAction.getAction();
                    // We will start specific workflow
                    startWorkflow(config.getLinkedActionWfKey(), situation, action, null, context);
                } else {
                    resolveLinkedSituation(config.getLinkedAction(), context);
                }
                addToItemLog(logItem, "Account exist in IdM (LINKED) - ended");
            }
        } else if (IcSyncDeltaTypeEnum.DELETE == type) {
            // Missing account situation, can be call from connector
            // (support delete account event) and from reconciliation
            context.addActionType(config.getMissingAccountAction().getAction());
            SynchronizationSituationType situation = SynchronizationSituationType.MISSING_ACCOUNT;
            if (StringUtils.hasLength(config.getMissingAccountActionWfKey())) {
                ReconciliationMissingAccountActionType missingAccountActionType = config.getMissingAccountAction();
                SynchronizationActionType action = missingAccountActionType.getAction();
                // We will start specific workflow
                startWorkflow(config.getMissingAccountActionWfKey(), situation, action, null, context);
            } else {
                // Resolve missing account situation for one item
                this.resolveMissingAccountSituation(config.getMissingAccountAction(), context);
            }
        } else if (context.isExportAction()) {
            // Export situation - create account to system
            this.resolveUnlinkedSituation(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ACCOUNT, context);
        }
        // Call hard hibernate session flush and clear
        if (getHibernateSession().isOpen()) {
            getHibernateSession().flush();
            getHibernateSession().clear();
        }
        return true;
    } catch (Exception e) {
        loggingException(context.getActionType(), log, logItem, actionLogs, uid, e);
        throw e;
    }
}
Also used : SynchronizationSituationType(eu.bcvsolutions.idm.acc.domain.SynchronizationSituationType) SynchronizationLinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ReconciliationMissingAccountActionType(eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) SynchronizationActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationActionType) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 12 with IcConnectorObject

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

the class DefaultAccAccountService method getConnectorObject.

@Override
public IcConnectorObject getConnectorObject(AccAccountDto account, BasePermission... permissions) {
    Assert.notNull(account, "Account cannot be null!");
    this.checkAccess(account, permissions);
    List<SysSchemaAttributeDto> schemaAttributes = this.getSchemaAttributes(account.getSystem(), null);
    if (schemaAttributes == null) {
        return null;
    }
    IcConnectorObject fullObject = this.systemService.readConnectorObject(account.getSystem(), account.getRealUid(), null);
    return this.getConnectorObjectForSchema(fullObject, schemaAttributes);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject)

Example 13 with IcConnectorObject

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

the class DefaultSysProvisioningOperationService method getFullConnectorObject.

/**
 * Returns fully loaded ConnectorObject with guarded strings.
 *
 * TODO: don't update connectorObject in provisioningOperation (needs attribute defensive clone)
 *
 * @param provisioningOperation
 * @return
 */
@Override
public IcConnectorObject getFullConnectorObject(SysProvisioningOperationDto provisioningOperation) {
    if (provisioningOperation == null || provisioningOperation.getProvisioningContext() == null || provisioningOperation.getProvisioningContext().getConnectorObject() == null) {
        return null;
    }
    List<IcAttribute> attributes = new ArrayList<>();
    // 
    IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
    connectorObject.getAttributes().forEach(attribute -> {
        IcAttribute attributeCopy = null;
        if (attribute.isMultiValue()) {
            List<Object> values = (List<Object>) attribute.getValues();
            attributeCopy = new IcAttributeImpl(attribute.getName(), values, true);
        } else if (attribute instanceof IcPasswordAttribute && attribute.getValue() != null) {
            attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), confidentialStorage.getGuardedString(provisioningOperation.getId(), SysProvisioningOperation.class, ((ConfidentialString) attribute.getValue()).getKey()));
        } else if (attribute instanceof IcPasswordAttribute && attribute.getValue() == null) {
            attributeCopy = new IcPasswordAttributeImpl(attribute.getName(), (GuardedString) null);
        } else {
            attributeCopy = new IcAttributeImpl(attribute.getName(), attribute.getValue());
        }
        attributes.add(attributeCopy);
    });
    IcConnectorObject newConnectorObject = new IcConnectorObjectImpl(connectorObject.getUidValue(), connectorObject.getObjectClass(), attributes);
    return newConnectorObject;
}
Also used : ArrayList(java.util.ArrayList) SysProvisioningOperation(eu.bcvsolutions.idm.acc.entity.SysProvisioningOperation) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) List(java.util.List) ArrayList(java.util.ArrayList) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 14 with IcConnectorObject

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

the class ConnIdIcConnectorService method readObject.

@Override
public IcConnectorObject readObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(uid);
    LOG.debug("Read object - ConnId (Uid= {} {})", uid, connectorInstance.getConnectorKey().toString());
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
    if (objectClassConnId == null) {
        objectClassConnId = ObjectClass.ACCOUNT;
    }
    ConnectorObject connObject = conn.getObject(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), null);
    LOG.debug("Readed object - ConnId ({}) Uid= {}", connObject, uid);
    return ConnIdIcConvertUtil.convertConnIdConnectorObject(connObject);
}
Also used : IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade)

Example 15 with IcConnectorObject

use of eu.bcvsolutions.idm.ic.api.IcConnectorObject 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)

Aggregations

IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)39 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)21 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)17 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)13 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)12 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)12 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)11 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)11 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)9 ArrayList (java.util.ArrayList)9 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)8 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)8 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 Test (org.junit.Test)8 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)7 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)7 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)7