use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createAndSaveRoleSystem.
private SysRoleSystemDto createAndSaveRoleSystem(IdmRoleDto role, SysSystemDto system) {
SysRoleSystemDto entity = new SysRoleSystemDto();
entity.setRole(role.getId());
entity.setSystem(system.getId());
entity.setSystemMapping(systemMapping.getId());
return saveInTransaction(entity, sysRoleSystemService);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class IdentityProvisioningExecutor method findOverloadingAttributes.
/**
* Return list of all overloading attributes for given identity, system and
* uid
*
* @param identityAccount
* @param idenityAccoutnList
* @param operationType
* @param entityType
* @return
*/
@Override
protected List<SysRoleSystemAttributeDto> findOverloadingAttributes(IdmIdentityDto entity, SysSystemDto system, List<? extends EntityAccountDto> idenityAccoutnList, SystemEntityType entityType) {
List<SysRoleSystemAttributeDto> roleSystemAttributesAll = new ArrayList<>();
idenityAccoutnList.stream().filter(ia -> {
AccAccountDto account = DtoUtils.getEmbedded((AccIdentityAccountDto) ia, AccIdentityAccount_.account, AccAccountDto.class);
return ((AccIdentityAccountDto) ia).getIdentityRole() != null && account.getSystem() != null && account.getSystem().equals(system.getId()) && ia.isOwnership();
}).forEach((identityAccountInner) -> {
AbstractDto identityAccount = (AbstractDto) identityAccountInner;
// All identity account with same system and with filled
// identityRole
AccAccountDto account = DtoUtils.getEmbedded(identityAccount, AccIdentityAccount_.account, AccAccountDto.class);
IdmIdentityRoleDto identityRole = DtoUtils.getEmbedded(identityAccount, AccIdentityAccount_.identityRole, IdmIdentityRoleDto.class);
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setRoleId(identityRole.getRole());
roleSystemFilter.setSystemId(account.getSystem());
List<SysRoleSystemDto> roleSystems = roleSystemService.find(roleSystemFilter, null).getContent();
if (roleSystems.size() > 1) {
SysRoleSystemDto roleSystem = roleSystems.get(0);
IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
SysSystemDto systemDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.system, SysSystemDto.class);
throw new ProvisioningException(AccResultCode.PROVISIONING_DUPLICATE_ROLE_MAPPING, ImmutableMap.of("role", roleDto.getName(), "system", systemDto.getName(), "entityType", entityType));
}
if (!roleSystems.isEmpty()) {
SysRoleSystemDto roleSystem = roleSystems.get(0);
SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
roleSystemAttributeFilter.setRoleSystemId(roleSystem.getId());
List<SysRoleSystemAttributeDto> roleAttributes = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
if (!CollectionUtils.isEmpty(roleAttributes)) {
roleSystemAttributesAll.addAll(roleAttributes);
}
}
});
return roleSystemAttributesAll;
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemService method toDto.
@Override
protected SysRoleSystemDto toDto(SysRoleSystem entity, SysRoleSystemDto dto, SysRoleSystemFilter context) {
SysRoleSystemDto roleSystemDto = super.toDto(entity, dto, context);
if (context != null && Boolean.TRUE.equals(context.getCheckIfIsInCrossDomainGroup()) && roleSystemDto != null && roleSystemDto.getId() != null) {
SysSystemGroupSystemFilter systemGroupSystemFilter = new SysSystemGroupSystemFilter();
systemGroupSystemFilter.setCrossDomainsGroupsForRoleSystemId(roleSystemDto.getId());
if (systemGroupSystemService.count(systemGroupSystemFilter) >= 1) {
// This role-system overriding a merge attribute which is using in
// active cross-domain group. -> We will set this information to the DTO.
roleSystemDto.setInCrossDomainGroup(true);
}
}
return roleSystemDto;
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class AccountManagementTest method testNoRemoveIdentityAccountIfRoleSystemRemovedAndRecreate.
@Test
public /**
* IdentityAccount already exist, but doesn't have relation on RoleSystem. This
* could happen if system mapping was deleted and recreated or if was role use
* as sync default role, but without mapping on this system.
*/
void testNoRemoveIdentityAccountIfRoleSystemRemovedAndRecreate() {
IdmRoleDto roleOne = getHelper().createRole();
// create test system with mapping and link her to role
SysSystemDto systemOne = getHelper().createTestResourceSystem(true);
SysRoleSystemDto roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
IdmIdentityDto identity = getHelper().createIdentity();
IdmRoleRequestDto roleRequestOne = getHelper().createRoleRequest(identity, roleOne);
getHelper().executeRequest(roleRequestOne, false);
// check after create
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, assignedRoles.size());
// check created account
AccAccountDto accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
Assert.assertNotNull(accountOne);
Assert.assertNotNull(getHelper().findResource(accountOne.getRealUid()));
// Delete role-system -> relation on role-system from identity-account will be removed.
roleSystemService.delete(roleSystem);
roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
// Execute ACM and provisioning via bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAccountManagementBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
bulkActionManager.processAction(bulkAction);
// Account must exist
AccAccountDto accountTwo = accountService.getAccount(identity.getUsername(), systemOne.getId());
Assert.assertNotNull(accountTwo);
Assert.assertNotNull(getHelper().findResource(accountTwo.getRealUid()));
// Account must have same ID as original -> must not be deleted
Assert.assertEquals(accountOne.getId(), accountTwo.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class AccountManagementTest method testRemoveIdentityAccountIfRoleSystemRemoved.
@Test
public void testRemoveIdentityAccountIfRoleSystemRemoved() {
IdmRoleDto roleOne = getHelper().createRole();
// create test system with mapping and link her to role
SysSystemDto systemOne = getHelper().createTestResourceSystem(true);
SysRoleSystemDto roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
IdmIdentityDto identity = getHelper().createIdentity();
IdmRoleRequestDto roleRequestOne = getHelper().createRoleRequest(identity, roleOne);
getHelper().executeRequest(roleRequestOne, false);
// check after create
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, assignedRoles.size());
// check created account
AccAccountDto accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
Assert.assertNotNull(accountOne);
Assert.assertNotNull(getHelper().findResource(accountOne.getRealUid()));
roleSystemService.delete(roleSystem);
// Execute ACM and provisioning via bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAccountManagementBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
bulkActionManager.processAction(bulkAction);
// Account must not exist
accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
Assert.assertNull(accountOne);
}
Aggregations