use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccAuthenticatorTest method logInAgainstSystem.
private void logInAgainstSystem(IdmIdentityDto identity, IdmRoleDto role, String username) {
IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
irdto.setRole(role.getId());
// This evokes IdentityRole SAVE event. On this event will be start
// account management and provisioning
irdto = identityRoleService.save(irdto);
//
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> accounts = identityAccountService.find(filter, null).getContent();
assertEquals(1, accounts.size());
List<String> accs = new ArrayList<>();
accs.add(accounts.get(0).getId().toString());
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setAccounts(accs);
passwordChangeDto.setAll(true);
passwordChangeDto.setNewPassword(new GuardedString("test"));
// change password for system
provisioningService.changePassword(identity, passwordChangeDto);
LoginDto loginDto = new LoginDto();
loginDto.setUsername(username);
loginDto.setPassword(new GuardedString("test"));
loginDto = authenticationManager.authenticate(loginDto);
//
assertNotNull(loginDto);
assertNotNull(loginDto.getAuthentication());
assertEquals("acc", loginDto.getAuthenticationModule());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class AccountProtectionSystemTest method protectedIdentityAccountDeleteTest.
/**
* When is account in protection mode, then cannot be identity account deleted.
*/
@Test(expected = ResultCodeException.class)
public void protectedIdentityAccountDeleteTest() {
IdmIdentityDto identity = helper.createIdentity();
SysSystemDto system = initSystem();
IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
// Set system to protected mode
SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
mapping.setProtectionEnabled(Boolean.TRUE);
mapping.setProtectionInterval(null);
systemMappingService.save(mapping);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleOne);
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
// Remove role from identity
identityRoleService.deleteById(identityRole.getId());
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setAccountId(account.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
Assert.assertEquals(1, identityAccounts.size());
// Remove identity account again. Now must end on the exception (account is
// already in protection)
identityAccountService.delete(identityAccounts.get(0));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testAcmPerformanceAdd200Two.
@Ignore
@Test
public void testAcmPerformanceAdd200Two() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_PERFORMANCE);
boolean first = false;
if (identity == null) {
identity = helper.createIdentity(IDENTITY_PERFORMANCE);
first = true;
}
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("testAcmPerformance200Two - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
if (first) {
Assert.assertEquals(200, identityAccounts.size());
} else {
Assert.assertEquals(400, identityAccounts.size());
}
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance100.
@Ignore
@Test
@Transactional
public void testDeletePerformance100() {
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("testDeletePerformance100 - 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();
IdmRoleRequestDto requestDel = helper.createRoleRequest(identity);
identityRoles.forEach(identityRole -> {
IdmConceptRoleRequestDto conceptRoleRequest = new IdmConceptRoleRequestDto();
conceptRoleRequest.setRoleRequest(requestDel.getId());
conceptRoleRequest.setIdentityContract(primeContract.getId());
conceptRoleRequest.setIdentityRole(identityRole.getId());
conceptRoleRequest.setOperation(ConceptRoleRequestOperation.REMOVE);
conceptRoleRequestService.save(conceptRoleRequest);
});
Date startAcmDelete = new Date();
helper.executeRequest(requestDel, false, true);
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance100 - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(0, identityAccounts.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testAcmPerformance100WithoutRequest.
@Ignore
@Test
@Transactional
public void testAcmPerformance100WithoutRequest() {
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, 100);
UUID primeContract = identityContractService.getPrimeContract(identity.getId()).getId();
Date startAcm = new Date();
roles.forEach(role -> {
IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
identityRole.setIdentityContract(primeContract);
identityRole.setRole(role.getId());
identityRole = identityRoleService.save(identityRole);
// Call hard hibernate session flush and clear
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcm = new Date();
System.out.println("testAcmPerformance100 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(100, identityAccounts.size());
}
Aggregations