use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class AccAccountController method validateDto.
@Override
protected AccAccountDto validateDto(AccAccountDto dto) {
dto = super.validateDto(dto);
// preset entity type
if (dto.getSystemEntity() != null) {
SysSystemEntityDto systemEntity = systemEntityService.get(dto.getSystemEntity());
dto.setEntityType(systemEntity.getEntityType());
}
if (!getService().isNew(dto)) {
AccAccountDto previous = getDto(dto.getId());
if (previous.isInProtection() && !dto.isInProtection()) {
throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_UPDATE_IS_PROTECTED, ImmutableMap.of("uid", dto.getUid()));
}
}
return dto;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class CoreReferentialIntegrityIntegrationTest method testIdentityReferentialIntegrity.
@Test
public void testIdentityReferentialIntegrity() {
IdmIdentityDto identity = new IdmIdentityDto();
String username = "delete_test_" + System.currentTimeMillis();
identity.setUsername(username);
// confidential storage
identity.setPassword(new GuardedString("heslo"));
identity.setFirstName("Test");
identity.setLastName("Identity");
identity = identityService.save(identity);
// accounts
SysSystemDto system = new SysSystemDto();
system.setName("system_" + System.currentTimeMillis());
system = systemService.save(system);
SysSystemEntityDto systemEntity = new SysSystemEntityDto();
systemEntity.setUid("test_uid_" + System.currentTimeMillis());
systemEntity.setEntityType(SystemEntityType.IDENTITY);
systemEntity.setWish(true);
systemEntity.setSystem(system.getId());
systemEntity = systemEntityService.save(systemEntity);
AccAccountDto account = new AccAccountDto();
account.setSystem(system.getId());
account.setSystemEntity(systemEntity.getId());
account.setUid(systemEntity.getUid());
account.setAccountType(AccountType.PERSONAL);
account.setEntityType(SystemEntityType.IDENTITY);
account = accountService.save(account);
AccIdentityAccountDto identityAccount = new AccIdentityAccountDto();
identityAccount.setIdentity(identity.getId());
identityAccount.setAccount(account.getId());
identityAccount.setOwnership(true);
identityAccount = identityAccountService.save(identityAccount);
assertNotNull(identityService.getByUsername(username));
assertNotNull(identityAccountService.get(identityAccount.getId()));
assertNotNull(accountService.get(account.getId()));
identityService.delete(identity);
assertNull(identityService.getByUsername(username));
assertNull(identityAccountService.get(identityAccount.getId()));
assertNull(accountService.get(account.getId()));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultAccTestHelper method createSystemEntity.
@Override
public SysSystemEntityDto createSystemEntity(SysSystemDto system) {
SysSystemEntityDto systemEntity = new SysSystemEntityDto(createName(), SystemEntityType.IDENTITY);
systemEntity.setSystem(system.getId());
systemEntity.setWish(true);
return systemEntityService.save(systemEntity);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method testCreateIdentityRemoveWishSync.
// -------------------------------------- Inactive owner behavior tests end--------------------------------------------------------
// -------------------------------------- System entity wish tests --------------------------------------------------------
// new identity, system entity has "wish" => removed "wish"
// unlinked, system entity has "wish" => removed "wish"
// linked, system entity has "wish", action Ignore => no change
// linked, system entity has "wish", action Update entity, automapping is allowed => removed "wish"
// linked, system entity has "wish", action Update entity, automapping is not allowed => no change + warning
// new identity, system entity has "wish" => removed "wish"
@Test
public void testCreateIdentityRemoveWishSync() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
// Create system entity with "wish"
createSystemEntityWish(system);
IdmIdentityFilter identityFilter = new IdmIdentityFilter();
identityFilter.setUsername(IDENTITY_ONE);
List<IdmIdentityDto> identities = identityService.find(identityFilter, null).getContent();
Assert.assertEquals(0, identities.size());
helper.startSynchronization(config);
// Has to be success
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Identity was created
identities = identityService.find(identityFilter, null).getContent();
Assert.assertEquals(1, identities.size());
// System entity is no longer "wish"
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
Assert.assertFalse(systemEntity.isWish());
// Delete log
syncLogService.delete(log);
syncConfigService.delete(config);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method testUpdateIdentityRemoveWishSync.
// linked, system entity has "wish", action Update entity, automapping is allowed => removed "wish"
@Test
public void testUpdateIdentityRemoveWishSync() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
// Allow automapping
configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT, Boolean.TRUE);
SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
config.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
// Create system entity with "wish"
createSystemEntityWish(system);
// Create identity with account
IdmIdentityDto identity = helper.createIdentity(IDENTITY_ONE);
helper.createIdentityAccount(system, identity);
helper.startSynchronization(config);
// has to be success
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// System entity has no longer "wish"
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
Assert.assertFalse(systemEntity.isWish());
// Delete log
syncLogService.delete(log);
syncConfigService.delete(config);
// Return default
configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT, ProvisioningConfiguration.DEFAULT_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT);
}
Aggregations