use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.
the class VsSystemGeneratorTaskExecutorIntegrationTest method generate10Sys10Role1User.
@Test
public void generate10Sys10Role1User() {
final String TEST_PREFIX = "testPrefix2";
VsSystemGeneratorTaskExecutor taskExecutor = new VsSystemGeneratorTaskExecutor();
AutowireHelper.autowire(taskExecutor);
Map<String, Object> properties = new HashMap<>();
properties.put(VsSystemGeneratorTaskExecutor.IDNENTITY_COUNT, 1);
properties.put(VsSystemGeneratorTaskExecutor.ROLE_COUNT, 10);
properties.put(VsSystemGeneratorTaskExecutor.SYSTEM_COUNT, 10);
properties.put(VsSystemGeneratorTaskExecutor.ITEM_PREFIX_KEY, TEST_PREFIX);
taskExecutor.init(properties);
longRunningTaskManager.execute(taskExecutor);
// expected number of identities was created
IdmIdentityFilter identityFilt = new IdmIdentityFilter();
identityFilt.setText(TEST_PREFIX);
List<IdmIdentityDto> identities = identityService.find(identityFilt, null).getContent();
Assert.assertEquals(1, identities.size());
// expected number of roles was created
IdmRoleFilter roleFilt = new IdmRoleFilter();
roleFilt.setText(TEST_PREFIX);
List<IdmRoleDto> roles = roleService.find(roleFilt, null).getContent();
Set<UUID> roleIds = roles.stream().map(IdmRoleDto::getId).collect(Collectors.toSet());
Assert.assertEquals(10, roles.size());
// expected number of systems was created
SysSystemFilter systemFilt = new SysSystemFilter();
systemFilt.setText(TEST_PREFIX);
List<SysSystemDto> systems = systemService.find(systemFilt, null).getContent();
Set<UUID> sysIds = systems.stream().map(SysSystemDto::getId).collect(Collectors.toSet());
Assert.assertEquals(10, systems.size());
// systems are connected with roles
Set<UUID> sysIdForRoles = new HashSet<UUID>();
SysRoleSystemFilter roleSystemFilt = new SysRoleSystemFilter();
for (IdmRoleDto role : roles) {
roleSystemFilt.setRoleId(role.getId());
List<SysRoleSystemDto> roleSystems = roleSystemService.find(roleSystemFilt, null).getContent();
Assert.assertEquals(1, roleSystems.size());
sysIdForRoles.add(roleSystems.get(0).getSystem());
}
Assert.assertTrue(Objects.equals(sysIds, sysIdForRoles));
// roles are connected with identities
Set<UUID> roleIdForIdentity = identityRoleService.findAllByIdentity(identities.get(0).getId()).stream().map(IdmIdentityRoleDto::getRole).collect(Collectors.toSet());
Assert.assertTrue(Objects.equals(roleIdForIdentity, roleIds));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.
the class VsSystemGeneratorTaskExecutorIntegrationTest method generate10Sys1Role1User.
@Test
public void generate10Sys1Role1User() {
final String TEST_PREFIX = "testPrefix1";
VsSystemGeneratorTaskExecutor taskExecutor = new VsSystemGeneratorTaskExecutor();
AutowireHelper.autowire(taskExecutor);
Map<String, Object> properties = new HashMap<>();
properties.put(VsSystemGeneratorTaskExecutor.IDNENTITY_COUNT, 1);
properties.put(VsSystemGeneratorTaskExecutor.ROLE_COUNT, 1);
properties.put(VsSystemGeneratorTaskExecutor.SYSTEM_COUNT, 10);
properties.put(VsSystemGeneratorTaskExecutor.ITEM_PREFIX_KEY, TEST_PREFIX);
taskExecutor.init(properties);
longRunningTaskManager.execute(taskExecutor);
// expected number of identities was created
IdmIdentityFilter identityFilt = new IdmIdentityFilter();
identityFilt.setText(TEST_PREFIX);
List<IdmIdentityDto> identities = identityService.find(identityFilt, null).getContent();
Assert.assertEquals(1, identities.size());
// expected number of roles was created
IdmRoleFilter roleFilt = new IdmRoleFilter();
roleFilt.setText(TEST_PREFIX);
List<IdmRoleDto> roles = roleService.find(roleFilt, null).getContent();
Set<UUID> roleIds = roles.stream().map(IdmRoleDto::getId).collect(Collectors.toSet());
Assert.assertEquals(1, roles.size());
// expected number of systems was created
SysSystemFilter systemFilt = new SysSystemFilter();
systemFilt.setText(TEST_PREFIX);
List<SysSystemDto> systems = systemService.find(systemFilt, null).getContent();
Set<UUID> sysIds = systems.stream().map(SysSystemDto::getId).collect(Collectors.toSet());
Assert.assertEquals(10, systems.size());
// systems are connected with roles
SysRoleSystemFilter roleSystemFilt = new SysRoleSystemFilter();
roleSystemFilt.setRoleId(roles.get(0).getId());
List<SysRoleSystemDto> roleSystems = roleSystemService.find(roleSystemFilt, null).getContent();
Set<UUID> sysIdForRoles = roleSystems.stream().map(SysRoleSystemDto::getSystem).collect(Collectors.toSet());
Assert.assertTrue(Objects.equals(sysIds, sysIdForRoles));
// roles are connected with identities
Set<UUID> roleIdForIdentity = identityRoleService.findAllByIdentity(identities.get(0).getId()).stream().map(IdmIdentityRoleDto::getRole).collect(Collectors.toSet());
Assert.assertTrue(Objects.equals(roleIdForIdentity, roleIds));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.
the class PasswordPolicyDeleteProcessor method process.
@Override
public EventResult<IdmPasswordPolicyDto> process(EntityEvent<IdmPasswordPolicyDto> event) {
// cascade set to null all references in sysSystem to remove password policy
IdmPasswordPolicyDto dto = event.getContent();
Assert.notNull(dto.getId(), "Password policy identifier is required.");
// remove references to password policy
SysSystemFilter filter = new SysSystemFilter();
filter.setPasswordPolicyGenerationId(dto.getId());
systemService.find(filter, null).forEach(system -> {
system.setPasswordPolicyGenerate(null);
systemService.save(system);
});
filter.setPasswordPolicyGenerationId(null);
filter.setPasswordPolicyValidationId(dto.getId());
systemService.find(filter, null).forEach(system -> {
system.setPasswordPolicyValidate(null);
systemService.save(system);
});
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.
the class RemoteServerSaveProcessor method process.
@Override
public EventResult<SysConnectorServerDto> process(EntityEvent<SysConnectorServerDto> event) {
SysConnectorServerDto dto = event.getContent();
GuardedString password = dto.getPassword();
SysConnectorServerDto remoteServer = service.saveInternal(dto);
// save password from remote connector server to confidential storage
if (password != null) {
// save for newSystem
confidentialStorage.save(remoteServer.getId(), SysRemoteServer.class, SysSystemService.REMOTE_SERVER_PASSWORD, password.asString());
//
// set asterisks
remoteServer.setPassword(new GuardedString(GuardedString.SECRED_PROXY_STRING));
}
//
// update all systems => we need to be backward compatible (see SysSystemDto.getConnectorInstance() + password is loaded direcly from confidential storage for systems)
SysSystemFilter systemFilter = new SysSystemFilter();
systemFilter.setRemoteServerId(remoteServer.getId());
systemService.find(systemFilter, null).forEach(system -> {
SysConnectorServerDto connectorServer = new SysConnectorServerDto(remoteServer);
// usable password
connectorServer.setPassword(password);
//
system.setConnectorServer(connectorServer);
systemService.save(system);
});
//
event.setContent(remoteServer);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.
the class RemoteServerDeleteProcessor method process.
@Override
public EventResult<SysConnectorServerDto> process(EntityEvent<SysConnectorServerDto> event) {
SysConnectorServerDto remoteServer = event.getContent();
UUID remoteServerId = remoteServer.getId();
Assert.notNull(remoteServerId, "Remove server identifier is required.");
//
// Check system not exists
SysSystemFilter systemFilter = new SysSystemFilter();
systemFilter.setRemoteServerId(remoteServerId);
if (systemService.count(systemFilter) > 0) {
throw new ResultCodeException(AccResultCode.REMOTE_SYSTEM_DELETE_FAILED_HAS_SYSTEMS, ImmutableMap.of("remoteServer", remoteServer.getFullServerName()));
}
//
// deletes all confidential values
confidentialStorage.deleteAll(remoteServerId, SysRemoteServer.class);
//
// deletes server
service.deleteInternal(remoteServer);
//
return new DefaultEventResult<>(event, this);
}
Aggregations