Search in sources :

Example 11 with SysSystemEntityFilter

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

the class AbstractSynchronizationExecutor method findSystemEntity.

private SysSystemEntityDto findSystemEntity(String uid, SysSystemDto system, SystemEntityType entityType) {
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setEntityType(entityType);
    systemEntityFilter.setSystemId(system.getId());
    systemEntityFilter.setUid(uid);
    List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
    SysSystemEntityDto systemEntity = null;
    if (systemEntities.size() == 1) {
        systemEntity = systemEntities.get(0);
    } else if (systemEntities.size() > 1) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_SYSTEM_ENTITY, uid);
    }
    return systemEntity;
}
Also used : ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)

Example 12 with SysSystemEntityFilter

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

the class IdentityAccountManagementTest method defaultAccountRemovedEntitySystemExist.

@Test
public void defaultAccountRemovedEntitySystemExist() {
    SysSystemEntityFilter filter = new SysSystemEntityFilter();
    filter.setEntityType(SystemEntityType.IDENTITY);
    filter.setUid("x" + IDENTITY_USERNAME);
    Assert.assertEquals("SystemEntity must not be after account was deleted!", 0, systemEntityService.find(filter, null).getContent().size());
}
Also used : SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 13 with SysSystemEntityFilter

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

the class IdentityAccountManagementTest method defaultAccountEntitySystemExist.

@Test
public void defaultAccountEntitySystemExist() {
    SysSystemEntityFilter filter = new SysSystemEntityFilter();
    filter.setEntityType(SystemEntityType.IDENTITY);
    filter.setUid("x" + IDENTITY_USERNAME);
    Assert.assertEquals("SystemEntity must be after account was created!", 1, systemEntityService.find(filter, null).getContent().size());
}
Also used : SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 14 with SysSystemEntityFilter

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

the class SystemDeleteProcessor method process.

@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
    SysSystemDto system = event.getContent();
    Assert.notNull(system, "System is required.");
    // 
    // if exists provisioning operations, then is not possible to delete
    // system
    SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
    operationFilter.setSystemId(system.getId());
    if (provisioningOperationService.count(operationFilter) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_OPERATIONS, ImmutableMap.of("system", system.getName()));
    }
    if (accountRepository.countBySystem_Id(system.getId()) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_ACCOUNTS, ImmutableMap.of("system", system.getName()));
    }
    // Check if system is used in some systems group.
    SysSystemGroupSystemFilter groupSystemFilter = new SysSystemGroupSystemFilter();
    groupSystemFilter.setSystemId(system.getId());
    long count = systemGroupSystemService.count(groupSystemFilter);
    if (count > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_SYSTEM_GROUPS, ImmutableMap.of("system", system.getName(), "count", count));
    }
    // delete system entities
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setSystemId(system.getId());
    systemEntityService.find(systemEntityFilter, null).forEach(systemEntity -> {
        systemEntityService.delete(systemEntity);
    });
    // delete synchronization configs
    SysSyncConfigFilter synchronizationConfigFilter = new SysSyncConfigFilter();
    synchronizationConfigFilter.setSystemId(system.getId());
    synchronizationConfigService.find(synchronizationConfigFilter, null).forEach(config -> {
        synchronizationConfigService.delete(config);
    });
    // delete schema
    SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
    filter.setSystemId(system.getId());
    objectClassService.find(filter, null).forEach(schemaObjectClass -> {
        objectClassService.delete(schemaObjectClass);
    });
    // delete archived provisioning operations
    provisioningArchiveRepository.deleteBySystem_Id(system.getId());
    // 
    // clear provisioning break cache
    clearProvisioningBreakAndCache(system.getId());
    // 
    // deletes all confidential values
    confidentialStorage.deleteAll(system.getId(), SysSystem.class);
    // 
    // Delete connected uniform password. Or throw error at the beginning?
    AccUniformPasswordSystemFilter uniformPasswordSystemFilter = new AccUniformPasswordSystemFilter();
    uniformPasswordSystemFilter.setSystemId(system.getId());
    passwordFilterSystemService.find(uniformPasswordSystemFilter, null).forEach(uniformPasswordSystem -> {
        passwordFilterSystemService.delete(uniformPasswordSystem);
    });
    // 
    // deletes identity
    service.deleteInternal(system);
    return new DefaultEventResult<>(event, this);
}
Also used : SysSystemGroupSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter) AccUniformPasswordSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Aggregations

SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 Test (org.junit.Test)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)7 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)2 VsConnectorObjectDto (eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto)2 VsRequestDto (eu.bcvsolutions.idm.vs.dto.VsRequestDto)2 VsRequestFilter (eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)1 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)1 AccUniformPasswordSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter)1 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)1 SysSchemaObjectClassFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter)1 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)1