use of eu.bcvsolutions.idm.acc.dto.AccUniformPasswordSystemDto 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.AccUniformPasswordSystemDto in project CzechIdMng by bcvsolutions.
the class UniformPasswordSystemSaveProcessor method process.
@Override
public EventResult<AccUniformPasswordSystemDto> process(EntityEvent<AccUniformPasswordSystemDto> event) {
AccUniformPasswordSystemDto dto = event.getContent();
dto = uniformPasswordSystemService.saveInternal(dto);
event.setContent(dto);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.AccUniformPasswordSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultAccUniformPasswordService method findOptionsForPasswordChange.
@Override
public List<AccPasswordChangeOptionDto> findOptionsForPasswordChange(IdmIdentityDto identity, BasePermission... permissions) {
List<AccPasswordChangeOptionDto> result = Lists.newArrayList();
AccUniformPasswordSystemFilter filter = new AccUniformPasswordSystemFilter();
filter.setIdentityId(identity.getId());
filter.setUniformPasswordDisabled(Boolean.FALSE);
List<AccUniformPasswordSystemDto> uniformPasswordSystems = this.uniformPasswordSystemService.find(filter, null).getContent();
// Group uniform password system by uniform password definition
Map<AccUniformPasswordDto, List<AccAccountDto>> accountsForUniformPassword = Maps.newHashMap();
// Same behavior as previous versions
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setOwnership(Boolean.TRUE);
accountFilter.setSupportChangePassword(Boolean.TRUE);
accountFilter.setIdentityId(identity.getId());
accountFilter.setInProtection(Boolean.FALSE);
// Include given permissions
List<AccAccountDto> accounts = accountService.find(accountFilter, null, permissions).getContent();
for (AccAccountDto account : accounts) {
// One system can be place more than one in uniform password systems
List<AccUniformPasswordSystemDto> uniformBySystem = uniformPasswordSystems.stream().filter(pfs -> {
return pfs.getSystem().equals(account.getSystem());
}).collect(Collectors.toList());
if (CollectionUtils.isEmpty(uniformBySystem)) {
// Simple account as option
AccPasswordChangeOptionDto optionDto = new AccPasswordChangeOptionDto(account);
optionDto.setNiceLabel(getNiceLabelForOption(account));
result.add(optionDto);
continue;
}
for (AccUniformPasswordSystemDto uniformPasswordSystemDto : uniformBySystem) {
AccUniformPasswordDto definition = DtoUtils.getEmbedded(uniformPasswordSystemDto, AccUniformPasswordSystem_.uniformPassword, AccUniformPasswordDto.class, null);
if (accountsForUniformPassword.containsKey(definition)) {
accountsForUniformPassword.get(definition).add(account);
} else {
accountsForUniformPassword.put(definition, Lists.newArrayList(account));
}
}
}
// Check if exists account for uniform password and process options for them
if (!accountsForUniformPassword.isEmpty()) {
for (Entry<AccUniformPasswordDto, List<AccAccountDto>> entry : accountsForUniformPassword.entrySet()) {
// There is also needed
AccUniformPasswordDto uniformPasswordDto = entry.getKey();
AccPasswordChangeOptionDto optionDto = new AccPasswordChangeOptionDto(uniformPasswordDto, entry.getValue());
optionDto.setNiceLabel(getNiceLabelForOption(uniformPasswordDto));
optionDto.setChangeInIdm(uniformPasswordDto.isChangeInIdm());
result.add(optionDto);
}
}
return result;
}
use of eu.bcvsolutions.idm.acc.dto.AccUniformPasswordSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultAccUniformPasswordServiceTest method testFilterByDisabledWithTrue.
@Test
public void testFilterByDisabledWithTrue() {
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);
assignSystem(createUniformDefinition(true), system, systemTwo, systemThree);
assignSystem(createUniformDefinition, systemTwo);
assignSystem(createUniformDefinition(true), system);
AccUniformPasswordSystemFilter filter = new AccUniformPasswordSystemFilter();
filter.setSystemId(systemTwo.getId());
filter.setUniformPasswordDisabled(true);
List<AccUniformPasswordSystemDto> content = uniformPasswordSystemService.find(filter, null).getContent();
assertEquals(1, content.size());
AccUniformPasswordSystemDto accUniformPasswordSystemDto = content.get(0);
assertEquals(createUniformDefinition.getId(), accUniformPasswordSystemDto.getUniformPassword());
}
Aggregations