Search in sources :

Example 36 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method doProvisioning.

@Override
public void doProvisioning(AccAccountDto account) {
    Assert.notNull(account);
    EntityAccountFilter filter = createEntityAccountFilter();
    filter.setAccountId(account.getId());
    List<? extends EntityAccountDto> entityAccoutnList = getEntityAccountService().find(filter, null).getContent();
    if (entityAccoutnList == null) {
        return;
    }
    entityAccoutnList.stream().filter(entityAccount -> {
        return entityAccount.isOwnership();
    }).forEach((entityAccount) -> {
        doProvisioning(account, getService().get(entityAccount.getEntity()));
    });
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntity_(eu.bcvsolutions.idm.acc.entity.SysSystemEntity_) Map(java.util.Map) ProvisioningEntityExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningEntityExecutor) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.ReadWriteDtoService) Set(java.util.Set) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) List(java.util.List) EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) CollectionUtils(org.springframework.util.CollectionUtils) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) Optional(java.util.Optional) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ProvisioningEvent(eu.bcvsolutions.idm.acc.event.ProvisioningEvent) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) HashMap(java.util.HashMap) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ImmutableList(com.google.common.collect.ImmutableList) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) LinkedHashSet(java.util.LinkedHashSet) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) SysSchemaObjectClass_(eu.bcvsolutions.idm.acc.entity.SysSchemaObjectClass_) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) Collections(java.util.Collections) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Assert(org.springframework.util.Assert) EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter)

Example 37 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method getAccountSystemEntity.

protected AccAccountDto getAccountSystemEntity(UUID systemEntity) {
    AccAccountFilter filter = new AccAccountFilter();
    filter.setSystemEntityId(systemEntity);
    List<AccAccountDto> accounts = this.accountService.find(filter, null).getContent();
    if (accounts.isEmpty()) {
        return null;
    } else {
        // We assume that system entity has only one account!
        return accounts.get(0);
    }
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto)

Example 38 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method updateAccountUid.

/**
 * Update account UID from system. UID mapped attribute must exist and returned
 * value must be not null and must be String
 *
 * @param logItem
 * @param account
 * @param mappedAttributes
 * @param icAttributes
 * @param system
 */
private void updateAccountUid(SynchronizationContext context) {
    Assert.notNull(context, "Context is required!");
    SysSyncItemLogDto logItem = context.getLogItem();
    AccAccountDto account = context.getAccount();
    // Generate UID value from mapped attribute marked as UID (Unique ID).
    // UID mapped attribute must exist and returned value must be not null
    // and must be String
    String attributeUid = this.generateUID(context);
    if (!account.getUid().equals(attributeUid)) {
        addToItemLog(logItem, MessageFormat.format("IdM Account UID ({0}) is different ({1}). We will update him.", account.getUid(), attributeUid));
        account.setUid(attributeUid);
        account = accountService.save(account);
    }
}
Also used : SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 39 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto 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 40 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method resolveLinkedSituation.

/**
 * Method for resolve linked situation for one item.
 */
@Override
public void resolveLinkedSituation(SynchronizationLinkedActionType action, SynchronizationContext context) {
    SystemEntityType entityType = context.getEntityType();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    AccAccountDto account = context.getAccount();
    addToItemLog(logItem, MessageFormat.format("IdM Account ({0}) exists in IDM (LINKED)", account.getUid()));
    addToItemLog(logItem, MessageFormat.format("Linked action is {0}", action));
    switch(action) {
        case IGNORE:
            // Linked action is IGNORE. We will do nothing
            initSyncActionLog(SynchronizationActionType.LINKED, OperationResultType.IGNORE, logItem, log, actionLogs);
            return;
        case UNLINK:
            // Linked action is UNLINK
            updateAccountUid(context);
            doUnlink(account, false, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.UNLINK, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case UNLINK_AND_REMOVE_ROLE:
            // Linked action is UNLINK_AND_REMOVE_ROLE
            updateAccountUid(context);
            doUnlink(account, true, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.UNLINK, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case UPDATE_ENTITY:
            // Linked action is UPDATE_ENTITY
            updateAccountUid(context);
            doUpdateEntity(context);
            initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case UPDATE_ACCOUNT:
            // Linked action is UPDATE_ACCOUNT
            updateAccountUid(context);
            doUpdateAccount(account, entityType, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.UPDATE_ACCOUNT, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        default:
            break;
    }
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Aggregations

AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)90 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)47 Test (org.junit.Test)45 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)33 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)29 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)25 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)19 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)18 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)18 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)16 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)16 ArrayList (java.util.ArrayList)16 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)14 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)14 UUID (java.util.UUID)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)13 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)13