Search in sources :

Example 21 with SysSystemEntityDto

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;
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 22 with SysSystemEntityDto

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()));
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with SysSystemEntityDto

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);
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 24 with SysSystemEntityDto

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);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 25 with SysSystemEntityDto

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);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Aggregations

SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)69 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)49 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)36 Test (org.junit.Test)36 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)25 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)22 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)15 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)14 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)14 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)13 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)11 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)10 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)10 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)8 SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)8