use of eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccUniformPasswordServiceTest method testFilterUniformSystemSystemId.
@Test
public void testFilterUniformSystemSystemId() {
SysSystemDto system = createSystem(true);
SysSystemDto systemTwo = createSystem(true);
AccUniformPasswordDto uniformDefinition = createUniformDefinition(true);
assignSystem(uniformDefinition, system, systemTwo);
AccUniformPasswordDto uniformDefinitionTwo = createUniformDefinition(true);
assignSystem(uniformDefinitionTwo, systemTwo);
AccUniformPasswordSystemFilter filter = new AccUniformPasswordSystemFilter();
filter.setSystemId(system.getId());
List<AccUniformPasswordSystemDto> content = uniformPasswordSystemService.find(filter, null).getContent();
assertEquals(1, content.size());
filter.setSystemId(systemTwo.getId());
content = uniformPasswordSystemService.find(filter, null).getContent();
assertEquals(2, content.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccUniformPasswordServiceTest method testFilterByDisabledWithFalse.
@Test
public void testFilterByDisabledWithFalse() {
SysSystemDto system = createSystem(false);
SysSystemDto systemTwo = createSystem(false);
SysSystemDto systemThree = createSystem(false);
IdmIdentityDto identity = createIdentity(system);
assignSystem(identity, systemTwo);
assignSystem(identity, systemThree);
AccUniformPasswordDto createUniformDefinition = createUniformDefinition(true);
createUniformDefinition.setDisabled(true);
createUniformDefinition = uniformPasswordService.save(createUniformDefinition);
AccUniformPasswordDto createUniformDefinitionSecond = createUniformDefinition(true);
assignSystem(createUniformDefinitionSecond, system, systemTwo, systemThree);
assignSystem(createUniformDefinition, systemTwo);
assignSystem(createUniformDefinition(true), system);
AccUniformPasswordSystemFilter filter = new AccUniformPasswordSystemFilter();
filter.setSystemId(systemTwo.getId());
filter.setUniformPasswordDisabled(false);
List<AccUniformPasswordSystemDto> content = uniformPasswordSystemService.find(filter, null).getContent();
assertEquals(1, content.size());
AccUniformPasswordSystemDto accUniformPasswordSystemDto = content.get(0);
assertEquals(createUniformDefinitionSecond.getId(), accUniformPasswordSystemDto.getUniformPassword());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccUniformPasswordServiceTest method testFilterByDisabledWithNull.
@Test
public void testFilterByDisabledWithNull() {
SysSystemDto system = createSystem(false);
SysSystemDto systemTwo = createSystem(false);
SysSystemDto systemThree = createSystem(false);
IdmIdentityDto identity = createIdentity(system);
assignSystem(identity, systemTwo);
assignSystem(identity, systemThree);
AccUniformPasswordDto createUniformDefinition = createUniformDefinition(true);
createUniformDefinition.setDisabled(true);
createUniformDefinition = uniformPasswordService.save(createUniformDefinition);
AccUniformPasswordDto createUniformDefinitionSecond = createUniformDefinition(true);
assignSystem(createUniformDefinitionSecond, system, systemTwo, systemThree);
assignSystem(createUniformDefinition, systemTwo);
assignSystem(createUniformDefinition(true), system);
AccUniformPasswordSystemFilter filter = new AccUniformPasswordSystemFilter();
filter.setSystemId(systemTwo.getId());
filter.setUniformPasswordDisabled(null);
List<AccUniformPasswordSystemDto> content = uniformPasswordSystemService.find(filter, null).getContent();
assertEquals(2, content.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter in project CzechIdMng by bcvsolutions.
the class UniformPasswordDeleteProcessor method process.
@Override
public EventResult<AccUniformPasswordDto> process(EntityEvent<AccUniformPasswordDto> event) {
AccUniformPasswordDto uniformPasswordFilter = event.getContent();
Assert.notNull(uniformPasswordFilter, "Uniform password cannot be null!");
Assert.notNull(uniformPasswordFilter.getId(), "ID for uniform password must exists!");
// Delete all connections with systems
AccUniformPasswordSystemFilter uniformPasswordSystemFilter = new AccUniformPasswordSystemFilter();
uniformPasswordSystemFilter.setUniformPasswordId(uniformPasswordFilter.getId());
uniformPasswordSystemService.find(uniformPasswordSystemFilter, null).forEach(uniformPasswordSystem -> {
uniformPasswordSystemService.delete(uniformPasswordSystem);
});
uniformPasswordService.deleteInternal(uniformPasswordFilter);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter 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);
}
Aggregations