Search in sources :

Example 1 with AccAccountFilter

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

the class AbstractSynchronizationExecutor method startReconciliation.

/**
 * Start reconciliation. Is call after synchronization. Main purpose is find and
 * resolve missing accounts
 *
 * @param entityType
 * @param allAccountsSet
 * @param config
 * @param system
 * @param log
 * @param actionsLog
 */
protected void startReconciliation(SystemEntityType entityType, Set<String> allAccountsSet, AbstractSysSyncConfigDto config, SysSystemDto system, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
    if (!log.isRunning()) {
        return;
    }
    AccAccountFilter accountFilter = new AccAccountFilter();
    accountFilter.setSystemId(system.getId());
    List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
    for (AccAccountDto account : accounts) {
        if (!log.isRunning()) {
            return;
        }
        String uid = account.getRealUid();
        if (!allAccountsSet.contains(uid)) {
            SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
            try {
                // Default setting for log item
                itemLog.setIdentification(uid);
                itemLog.setDisplayName(uid);
                itemLog.setType(entityType.getEntityType().getSimpleName());
                // Do reconciliation for one item (produces event)
                // Start in new Transaction
                SynchronizationContext builder = new SynchronizationContext();
                builder.addUid(uid).addType(IcSyncDeltaTypeEnum.DELETE).addConfig(config).addSystem(system).addEntityType(entityType).addAccount(account).addLog(log).addLogItem(itemLog).addActionLogs(actionsLog);
                CoreEvent<SysSyncItemLogDto> event = new CoreEvent<>(SynchronizationEventType.START_ITEM, itemLog);
                event.getProperties().put(SynchronizationService.WRAPPER_SYNC_ITEM, builder);
                EventResult<SysSyncItemLogDto> lastResult = entityEventManager.process(event).getLastResult();
                boolean result = false;
                if (lastResult != null && lastResult.getEvent().getProperties().containsKey(SynchronizationService.RESULT_SYNC_ITEM)) {
                    result = (boolean) lastResult.getEvent().getProperties().get(SynchronizationService.RESULT_SYNC_ITEM);
                }
                // Update (increased counter) and check state of sync (maybe was cancelled from
                // sync or LRT)
                updateAndCheckState(result, log);
            } catch (Exception ex) {
                String message = MessageFormat.format("Reconciliation - error for uid [{0}]", uid);
                log.addToLog(message);
                log.addToLog(Throwables.getStackTraceAsString(ex));
                LOG.error(message, ex);
            } finally {
                config = synchronizationConfigService.save(config);
                boolean existingItemLog = existItemLogInActions(actionsLog, itemLog);
                actionsLog = saveActionLogs(actionsLog, log.getId());
                // 
                if (!existingItemLog) {
                    addToItemLog(itemLog, MessageFormat.format("Missing action log for UID [{0}]!", uid));
                    initSyncActionLog(SynchronizationActionType.UNKNOWN, OperationResultType.ERROR, itemLog, log, actionsLog);
                    syncItemLogService.save(itemLog);
                }
            }
        }
    }
}
Also used : SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException)

Example 2 with AccAccountFilter

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

the class DefaultPasswordFilterManager method getAccountsForPasswordChange.

/**
 * Return accounts that exists in given uniform password definitions. Second parameter supportPasswordFilter
 * return only managed system with password filter (echo support).
 *
 * @param passwordDefinitions
 * @param identityId
 * @param supportPasswordFilter
 * @return
 */
private List<AccAccountDto> getAccountsForPasswordChange(List<AccUniformPasswordDto> passwordDefinitions, UUID identityId, Boolean supportPasswordFilter) {
    Assert.notNull(identityId, "Identity cannot be null!");
    List<AccAccountDto> accounts = Lists.newArrayList();
    AccAccountFilter filter = new AccAccountFilter();
    filter.setSupportPasswordFilter(supportPasswordFilter);
    filter.setIdentityId(identityId);
    for (AccUniformPasswordDto definition : passwordDefinitions) {
        filter.setUniformPasswordId(definition.getId());
        accounts.addAll(accountService.find(filter, null).getContent());
    }
    return accounts;
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccUniformPasswordDto(eu.bcvsolutions.idm.acc.dto.AccUniformPasswordDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto)

Example 3 with AccAccountFilter

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

the class DefaultAccAccountService method getAccount.

@Override
public AccAccountDto getAccount(String uid, UUID systemId) {
    Assert.notNull(uid, "UID cannot be null!");
    Assert.notNull(systemId, "System ID cannot be null!");
    AccAccountFilter filter = new AccAccountFilter();
    filter.setUid(uid);
    filter.setSystemId(systemId);
    List<AccAccountDto> accounts = this.find(filter, null).getContent();
    if (accounts.isEmpty()) {
        return null;
    }
    return accounts.get(0);
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto)

Example 4 with AccAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter 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 5 with AccAccountFilter

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

the class AbstractProvisioningProcessor method getAccounts.

/**
 * Get accounts for system id and system edntity id
 *
 * @param systemId
 * @param systemEntityId
 * @return
 */
private List<UUID> getAccounts(UUID systemId, UUID systemEntityId) {
    AccAccountFilter filter = new AccAccountFilter();
    filter.setSystemEntityId(systemEntityId);
    filter.setEntityType(SystemEntityType.IDENTITY);
    filter.setSystemId(systemId);
    return accountService.findIds(filter, null).getContent();
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)

Aggregations

AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)45 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)33 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)25 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)21 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)18 Test (org.junit.Test)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)12 UUID (java.util.UUID)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)9 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)6 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)6 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)6 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)6 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)4 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)4 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)4