use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance200WithoutRequest.
@Ignore
@Test
@Transactional
public void testDeletePerformance200WithoutRequest() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 200);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testDeletePerformance200WithoutRequest - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(200, identityAccounts.size());
// Delete
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(primeContract.getId());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Date startAcmDelete = new Date();
identityRoles.forEach(identityRole -> {
identityRoleService.delete(identityRole);
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance200WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testAcmPerformance1000.
@Ignore
@Test
@Transactional
public void testAcmPerformance1000() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
roleAccountFilter.setSystemId(system.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
// None role assigned
Assert.assertEquals(0, identityAccounts.size());
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 1000);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testAcmPerformance1000 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(1000, identityAccounts.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testAcmPerformance200.
@Ignore
@Test
@Transactional
public void testAcmPerformance200() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
roleAccountFilter.setSystemId(system.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
// None role assigned
Assert.assertEquals(0, identityAccounts.size());
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 200);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testAcmPerformance200 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(200, identityAccounts.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance100WithoutRequest.
@Ignore
@Test
@Transactional
public void testDeletePerformance100WithoutRequest() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 100);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testDeletePerformance100WithoutRequest - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(100, identityAccounts.size());
// Delete
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(primeContract.getId());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Date startAcmDelete = new Date();
identityRoles.forEach(identityRole -> {
identityRoleService.delete(identityRole);
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance100WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class IdentityAccountDeleteProcessor method process.
@Override
public EventResult<AccIdentityAccountDto> process(EntityEvent<AccIdentityAccountDto> event) {
AccIdentityAccountDto entity = event.getContent();
UUID account = entity.getAccount();
AccAccountDto accountDto = accountService.get(account);
Assert.notNull(accountDto, "Account cannot be null!");
// We check if exists another (ownership) identity-accounts, if not
// then we will delete account
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setAccountId(account);
identityAccountFilter.setOwnership(Boolean.TRUE);
identityAccountFilter.setNotIdentityAccount(entity.getId());
boolean moreIdentityAccounts = service.find(identityAccountFilter, PageRequest.of(0, 1)).getTotalElements() > 0;
boolean deleteTargetAccount = (boolean) event.getProperties().get(AccIdentityAccountService.DELETE_TARGET_ACCOUNT_KEY);
boolean deleteAccAccount = true;
// If is account in protection, then we will not delete
// identity-account
// But is here exception from this. When is presented
// attribute FORCE_DELETE_OF_IDENTITY_ACCOUNT_KEY, then
// we will do delete of identity-account (it is important
// for integrity ... for example during delete of whole
// identity).
boolean forceDeleteIdentityAccount = isForceDeleteAttributePresent(event.getProperties());
if (!moreIdentityAccounts && entity.isOwnership()) {
if (accountDto.isAccountProtectedAndValid()) {
if (forceDeleteIdentityAccount) {
// Target account and AccAccount will NOT be deleted!
deleteAccAccount = false;
} else {
throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_BE_DELETED_IS_PROTECTED, ImmutableMap.of("uid", accountDto.getUid()));
}
// Is account protection activated on system mapping?
// Set account as protected we can only on account without protection (event has already invalid protection)!
} else if (!accountDto.isInProtection() && systemMappingService.isEnabledProtection(accountDto)) {
// This identity account is last ... protection will be
// activated
activateProtection(accountDto);
accountDto = accountService.save(accountDto);
entity.setRoleSystem(null);
entity.setIdentityRole(null);
service.save(entity);
doProvisioningSkipAccountProtection(accountDto, entity.getEntity());
// identity-account
if (forceDeleteIdentityAccount) {
// Target account and AccAccount will NOT be deleted!
deleteAccAccount = false;
} else {
return new DefaultEventResult<>(event, this);
}
}
}
service.deleteInternal(entity);
// Finally we can delete AccAccount
if (!moreIdentityAccounts && entity.isOwnership() && deleteAccAccount) {
// We delete all NOT ownership identity accounts first
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setAccountId(account);
filter.setOwnership(Boolean.FALSE);
// Find NOT ownership identity accounts
service.find(filter, null).getContent().stream().filter(identityAccount -> !identityAccount.isOwnership() && !identityAccount.equals(entity)).forEach(identityAccount -> {
service.delete(identityAccount);
});
UUID roleRequestId = this.getRoleRequestIdProperty(event.getProperties());
Map<String, Serializable> properties = new HashMap<String, Serializable>();
properties.put(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY, deleteTargetAccount);
properties.put(AccAccountService.ENTITY_ID_PROPERTY, entity.getEntity());
if (roleRequestId != null) {
properties.put(IdmRoleRequestService.ROLE_REQUEST_ID_KEY, roleRequestId);
}
accountService.publish(new AccountEvent(AccountEventType.DELETE, accountDto, properties));
}
return new DefaultEventResult<>(event, this);
}
Aggregations