Search in sources :

Example 31 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class IdentitySyncTest method initData.

private SysSystemDto initData() {
    // create test system
    SysSystemDto system = helper.createSystem(TestResource.TABLE_NAME);
    Assert.assertNotNull(system);
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create synchronization mapping
    SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
    syncSystemMapping.setName("default_" + System.currentTimeMillis());
    syncSystemMapping.setEntityType(SystemEntityType.IDENTITY);
    syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
    syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
    createMapping(system, syncMapping);
    this.getBean().initIdentityData();
    return system;
}
Also used : SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 32 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class TreeProvisioningExecutor method findSystemMappingsForEntityType.

@Override
protected List<SysSystemMappingDto> findSystemMappingsForEntityType(IdmTreeNodeDto entity, SystemEntityType entityType) {
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setEntityType(entityType);
    mappingFilter.setTreeTypeId(entity.getTreeType());
    mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
    List<SysSystemMappingDto> systemMappings = systemMappingService.find(mappingFilter, null).getContent();
    return systemMappings;
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 33 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class TreeSynchronizationExecutor method getValueByMappedAttribute.

@Override
protected Object getValueByMappedAttribute(AttributeMapping attribute, List<IcAttribute> icAttributes, SynchronizationContext context) {
    Object transformedValue = super.getValueByMappedAttribute(attribute, icAttributes, context);
    if (transformedValue != null && PARENT_FIELD.equals(attribute.getIdmPropertyName())) {
        String parentUid = transformedValue.toString();
        SysSystemMappingDto systemMapping = systemMappingService.get(((SysSystemAttributeMappingDto) attribute).getSystemMapping());
        SysSchemaObjectClassDto schemaObjectClass = schemaObjectClassService.get(systemMapping.getObjectClass());
        UUID systemId = schemaObjectClass.getSystem();
        // Find account by UID from parent field
        AccAccountFilter accountFilter = new AccAccountFilter();
        accountFilter.setUid(parentUid);
        accountFilter.setSystemId(systemId);
        transformedValue = null;
        List<AccAccountDto> parentAccounts = accountService.find(accountFilter, null).getContent();
        if (!parentAccounts.isEmpty()) {
            UUID parentAccount = parentAccounts.get(0).getId();
            // Find relation between tree and account
            AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
            treeAccountFilter.setAccountId(parentAccount);
            List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
            if (!treeAccounts.isEmpty()) {
                // Find parent tree node by ID
                // TODO: resolve more treeAccounts situations
                // parent uuid - we are working with dtos
                transformedValue = treeAccounts.get(0).getTreeNode();
            } else {
                LOG.warn("For parent UID: [{}] on system ID [{}] and acc account: [{}], was not found tree accounts! Return null value in parent!!", parentUid, systemId, parentAccount);
                throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_TREE_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId, "parentAccount", parentAccount));
            }
        } else {
            LOG.warn("For parent UID: [{}] on system ID [{}], was not found parents account! Return null value in parent!!", parentUid, systemId);
            throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId));
        }
    }
    return transformedValue;
}
Also used : AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) UUID(java.util.UUID)

Example 34 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class DefaultTestHelper method createMappingSystem.

@Override
public SysSystemMappingDto createMappingSystem(SystemEntityType type, SysSchemaObjectClassDto objectClass) {
    // system mapping
    SysSystemMappingDto mapping = new SysSystemMappingDto();
    mapping.setName(createName());
    mapping.setEntityType(type);
    mapping.setObjectClass(objectClass.getId());
    mapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
    // 
    return mappingService.save(mapping);
}
Also used : SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 35 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.

the class AsynchronousAccountManagementIntegrationTest method testAsynchronousAccountManagementError.

@Test
public void testAsynchronousAccountManagementError() {
    // add error to some script
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSystemMappingDto mapping = helper.getDefaultMapping(system);
    SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(mapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
    // username is transformed with error
    attributeHandlingUserName.setTransformToResourceScript("returan \"" + "error" + "\";");
    attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
    IdmIdentityDto identity = helper.createIdentity();
    IdmRoleDto role = helper.createRole();
    helper.createRoleSystem(role, system);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    try {
        helper.waitForResult(res -> {
            return !(entityEventService.findByState(configurationService.getInstanceId(), OperationState.CREATED).isEmpty() && entityEventService.findByState(configurationService.getInstanceId(), OperationState.RUNNING).isEmpty());
        });
        AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
        Assert.assertNull(account);
        // 
        // find event result with exception
        IdmEntityEventFilter eventFilter = new IdmEntityEventFilter();
        eventFilter.setOwnerId(identityRole.getId());
        eventFilter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
        List<IdmEntityEventDto> failedEvents = entityEventService.find(eventFilter, null).getContent();
        // 
        Assert.assertEquals(1, failedEvents.size());
        Assert.assertEquals(CoreResultCode.GROOVY_SCRIPT_EXCEPTION.getCode(), failedEvents.get(0).getResult().getCode());
    } finally {
        identityService.delete(identity);
        systemService.delete(system);
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)112 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)78 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)50 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)50 Test (org.junit.Test)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)44 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)28 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)28 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)24 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)23 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)23 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)22 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)21 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)15 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)14 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)14 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)13 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)13 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)12