Search in sources :

Example 6 with AccAccountFilter

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

the class DefaultAccAccountServiceFilterTest method testIdentityId.

@Test
public void testIdentityId() {
    IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system = helper.createTestResourceSystem(true);
    createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    IdmIdentityDto identity2 = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    createAccount(system2.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    AccAccountDto account3 = createAccount(system2.getId(), identity2.getId(), identity2.getUsername(), AccountType.PERSONAL, false);
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setIdentityId(identity2.getId());
    Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(account3.getId(), pages.getContent().get(0).getId());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with AccAccountFilter

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

the class DefaultAccAccountServiceFilterTest method testEventType.

@Test
public void testEventType() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    AccAccountDto accountOne = new AccAccountDto();
    accountOne.setSystem(system.getId());
    accountOne.setUid(UUID.randomUUID().toString());
    accountOne.setAccountType(AccountType.PERSONAL);
    accountOne.setEntityType(SystemEntityType.IDENTITY);
    accountOne = accAccountService.save(accountOne);
    AccAccountDto accountTwo = new AccAccountDto();
    accountTwo.setSystem(system.getId());
    accountTwo.setUid(UUID.randomUUID().toString());
    accountTwo.setAccountType(AccountType.PERSONAL);
    accountTwo.setEntityType(SystemEntityType.ROLE);
    accountTwo = accAccountService.save(accountTwo);
    // 
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setId(accountOne.getId());
    testFilter.setEntityType(SystemEntityType.IDENTITY);
    List<AccAccountDto> accounts = accAccountService.find(testFilter, null).getContent();
    // 
    Assert.assertEquals(1, accounts.size());
    Assert.assertEquals(accountOne.getUid(), accounts.get(0).getUid());
    // 
    testFilter.setId(accountTwo.getId());
    accounts = accAccountService.find(testFilter, null).getContent();
    Assert.assertTrue(accounts.isEmpty());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with AccAccountFilter

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

the class DefaultAccAccountServiceFilterTest method testSupportChangePassword.

@Test
public void testSupportChangePassword() {
    IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system = helper.createTestResourceSystem(true);
    AccAccountDto account = createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    IdmIdentityDto identity2 = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    createAccount(system2.getId(), identity2.getId(), identity2.getUsername(), AccountType.PERSONAL, false);
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setUid(identity.getUsername());
    testFilter.setSupportChangePassword(true);
    Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(account.getId(), pages.getContent().get(0).getId());
    // 
    SysSystemMappingDto defaultMapping = helper.getDefaultMapping(system);
    List<SysSystemAttributeMappingDto> attributes = attributeMappingService.findBySystemMapping(defaultMapping);
    // 
    for (SysSystemAttributeMappingDto attr : attributes) {
        if (attr.getName().equals(IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME)) {
            attributeMappingService.delete(attr);
        }
    }
    // 
    testFilter = new AccAccountFilter();
    testFilter.setUid(identity.getUsername());
    testFilter.setSupportChangePassword(true);
    pages = accAccountService.find(testFilter, null);
    assertEquals(0, pages.getTotalElements());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 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 10 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 systemAccountsMap
 * @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) {
        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<SysSyncItemLogDto>(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);
                }
                // We reload log (maybe was synchronization canceled)
                log.setRunning(synchronizationLogService.get(log.getId()).isRunning());
                if (!log.isRunning()) {
                    result = false;
                }
                if (!result) {
                    log.setRunning(false);
                    log.addToLog(MessageFormat.format("Synchronization canceled during resolve UID [{0}]", uid));
                    addToItemLog(itemLog, "Canceled!");
                    initSyncActionLog(SynchronizationActionType.UNKNOWN, OperationResultType.WARNING, itemLog, log, actionsLog);
                }
            } 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);
                    itemLog = 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) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException)

Aggregations

AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)19 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)16 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)10 Test (org.junit.Test)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)5 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 UUID (java.util.UUID)4 AccountType (eu.bcvsolutions.idm.acc.domain.AccountType)3 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)3 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)3 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)3 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)3 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)2 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)2