Search in sources :

Example 6 with IcConnectorConfiguration

use of eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method process.

@Override
public AbstractSysSyncConfigDto process(UUID synchronizationConfigId) {
    // Clear cache
    this.clearCache();
    // Validate and create basic context
    SynchronizationContext context = this.validate(synchronizationConfigId);
    AbstractSysSyncConfigDto config = context.getConfig();
    SystemEntityType entityType = context.getEntityType();
    SysSystemDto system = context.getSystem();
    IcConnectorConfiguration connectorConfig = context.getConnectorConfig();
    SysSystemMappingDto systemMapping = systemMappingService.get(config.getSystemMapping());
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(systemMapping.getObjectClass());
    IcObjectClass objectClass = new IcObjectClassImpl(schemaObjectClassDto.getObjectClassName());
    // Load last token
    Object lastToken = config.isReconciliation() ? null : config.getToken();
    IcSyncToken lastIcToken = lastToken != null ? new IcSyncTokenImpl(lastToken) : null;
    // Create basic synchronization log
    SysSyncLogDto log = new SysSyncLogDto();
    log.setSynchronizationConfig(config.getId());
    log.setStarted(LocalDateTime.now());
    log.setRunning(true);
    log.setToken(lastToken != null ? lastToken.toString() : null);
    log.addToLog(MessageFormat.format("Synchronization was started in {0}.", log.getStarted()));
    // List of all accounts keys (used in reconciliation)
    Set<String> systemAccountsList = new HashSet<>();
    // TODO: Export is not fully implemented (FE, configuration and Groovy
    // part missing)
    boolean export = false;
    longRunningTaskExecutor.setCounter(0L);
    try {
        log = synchronizationLogService.save(log);
        List<SysSyncActionLogDto> actionsLog = new ArrayList<>();
        // add logs to context
        context.addLog(log).addActionLogs(actionsLog);
        if (export) {
            // Start exporting entities to resource
            log.addToLog("Exporting entities to resource started...");
            this.startExport(entityType, config, context.getMappedAttributes(), log, actionsLog);
        } else if (config.isCustomFilter() || config.isReconciliation()) {
            // Custom filter Sync
            log.addToLog("Synchronization will use custom filter (not synchronization implemented in connector).");
            AttributeMapping tokenAttribute = null;
            if (config.getTokenAttribute() != null) {
                tokenAttribute = systemAttributeMappingService.get(config.getTokenAttribute());
            }
            if (tokenAttribute == null && !config.isReconciliation()) {
                throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TOKEN_ATTRIBUTE_NOT_FOUND);
            }
            context.addTokenAttribute(tokenAttribute);
            // Resolve filter for custom search
            IcFilter filter = resolveSynchronizationFilter(config);
            log.addToLog(MessageFormat.format("Start search with filter {0}.", filter != null ? filter : "NONE"));
            connectorFacade.search(system.getConnectorInstance(), connectorConfig, objectClass, filter, new DefaultResultHandler(context, systemAccountsList));
        } else {
            // Inner Sync
            log.addToLog("Synchronization will use inner connector synchronization implementation.");
            DefalutSyncResultHandler syncResultsHandler = new DefalutSyncResultHandler(context, systemAccountsList);
            connectorFacade.synchronization(system.getConnectorInstance(), connectorConfig, objectClass, lastIcToken, syncResultsHandler);
        }
        // We do reconciliation (find missing account)
        if (config.isReconciliation() && log.isRunning()) {
            startReconciliation(entityType, systemAccountsList, config, system, log, actionsLog);
        }
        // Sync is correctly ends if wasn't cancelled
        if (log.isRunning()) {
            log = syncCorrectlyEnded(log, context);
        }
        config = synchronizationConfigService.save(config);
    } catch (Exception e) {
        String message = "Error during synchronization";
        log.addToLog(message);
        log.setContainsError(true);
        log.addToLog(Throwables.getStackTraceAsString(e));
        LOG.error(message, e);
    } finally {
        log.setRunning(false);
        log.setEnded(LocalDateTime.now());
        log = synchronizationLogService.save(log);
        // 
        longRunningTaskExecutor.setCount(longRunningTaskExecutor.getCounter());
        longRunningTaskExecutor.updateState();
        // Clear cache
        this.clearCache();
    }
    return config;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) ArrayList(java.util.ArrayList) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) IcSyncTokenImpl(eu.bcvsolutions.idm.ic.impl.IcSyncTokenImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) HashSet(java.util.HashSet) IcSyncToken(eu.bcvsolutions.idm.ic.api.IcSyncToken) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter)

Example 7 with IcConnectorConfiguration

use of eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method validate.

/**
 * Validate synchronization on: Exist, enable, running, has mapping, has
 * connector key, has connector configuration
 *
 * @param synchronizationConfigId
 * @return
 */
protected SynchronizationContext validate(UUID synchronizationConfigId) {
    SynchronizationContext context = new SynchronizationContext();
    AbstractSysSyncConfigDto config = synchronizationConfigService.get(synchronizationConfigId);
    // 
    if (config == null) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_NOT_FOUND, ImmutableMap.of("id", synchronizationConfigId));
    }
    // Synchronization must be enabled
    if (!config.isEnabled()) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName()));
    }
    // Synchronization can not be running twice
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(config.getId());
    logFilter.setRunning(Boolean.TRUE);
    if (!synchronizationLogService.find(logFilter, null).getContent().isEmpty()) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_RUNNING, ImmutableMap.of("name", config.getName()));
    }
    SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
    Assert.notNull(mapping);
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
    Assert.notNull(system);
    // System must be enabled
    if (system.isDisabled()) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_SYSTEM_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName(), "system", system.getName()));
    }
    SystemEntityType entityType = mapping.getEntityType();
    SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
    attributeHandlingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> mappedAttributes = systemAttributeMappingService.find(attributeHandlingFilter, null).getContent();
    // Find connector identification persisted in system
    IcConnectorKey connectorKey = system.getConnectorKey();
    if (connectorKey == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Find connector configuration persisted in system
    IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    context.addConfig(config).addSystem(system).addEntityType(entityType).addMappedAttributes(mappedAttributes).addConnectorConfig(connectorConfig);
    return context;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 8 with IcConnectorConfiguration

use of eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method generateSchema.

@Override
@Transactional
public List<SysSchemaObjectClassDto> generateSchema(SysSystemDto system) {
    Assert.notNull(system);
    Assert.notNull(system.getId());
    // Find connector identification persisted in system
    IcConnectorKey connectorKey = system.getConnectorKey();
    if (connectorKey == null) {
        throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Find connector configuration persisted in system
    IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Call IC module and find schema for given connector key and
    // configuration
    IcSchema icSchema = icConfigurationFacade.getSchema(system.getConnectorInstance(), connectorConfig);
    if (icSchema == null) {
        throw new ResultCodeException(AccResultCode.CONNECTOR_SCHEMA_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Load existing object class from system
    SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
    objectClassFilter.setSystemId(system.getId());
    List<SysSchemaObjectClassDto> sysObjectClassesInSystem = null;
    Page<SysSchemaObjectClassDto> page = objectClassService.find(objectClassFilter, null);
    sysObjectClassesInSystem = page.getContent();
    // Convert IC schema to ACC entities
    List<SysSchemaObjectClassDto> sysObjectClasses = new ArrayList<SysSchemaObjectClassDto>();
    List<SysSchemaAttributeDto> sysAttributes = new ArrayList<SysSchemaAttributeDto>();
    for (IcObjectClassInfo objectClass : icSchema.getDeclaredObjectClasses()) {
        // __ACCOUNT__ and __GROUP__
        if (!(objectClass.getType().startsWith("__") && objectClass.getType().endsWith("__"))) {
            continue;
        }
        SysSchemaObjectClassDto sysObjectClass = null;
        // values from resource
        if (sysObjectClassesInSystem != null) {
            Optional<SysSchemaObjectClassDto> objectClassSame = sysObjectClassesInSystem.stream().filter(objectClassInSystem -> {
                // 
                return objectClassInSystem.getObjectClassName().equals(objectClass.getType());
            }).findFirst();
            if (objectClassSame.isPresent()) {
                sysObjectClass = objectClassSame.get();
            }
        }
        // Convert IC object class to ACC (if is null, then will be created
        // new instance)
        sysObjectClass = convertIcObjectClassInfo(objectClass, sysObjectClass);
        sysObjectClass.setSystem(system.getId());
        // object class may not exist
        sysObjectClass = schemaObjectClassService.save(sysObjectClass);
        sysObjectClasses.add(sysObjectClass);
        List<SysSchemaAttributeDto> attributesInSystem = null;
        // Load existing attributes for existing object class in system
        if (sysObjectClass.getId() != null) {
            SysSchemaAttributeFilter attFilter = new SysSchemaAttributeFilter();
            attFilter.setSystemId(system.getId());
            attFilter.setObjectClassId(sysObjectClass.getId());
            Page<SysSchemaAttributeDto> attributesInSystemPage = attributeService.find(attFilter, null);
            attributesInSystem = attributesInSystemPage.getContent();
        }
        for (IcAttributeInfo attribute : objectClass.getAttributeInfos()) {
            // If will be IC and ACC attribute same (same name), then we
            // will do only refresh object values from resource
            SysSchemaAttributeDto sysAttribute = null;
            if (attributesInSystem != null) {
                Optional<SysSchemaAttributeDto> sysAttributeOptional = attributesInSystem.stream().filter(a -> {
                    return a.getName().equals(attribute.getName());
                }).findFirst();
                if (sysAttributeOptional.isPresent()) {
                    sysAttribute = sysAttributeOptional.get();
                }
            }
            sysAttribute = convertIcAttributeInfo(attribute, sysAttribute);
            sysAttribute.setObjectClass(sysObjectClass.getId());
            sysAttributes.add(sysAttribute);
        }
    }
    // Persist generated schema to system
    sysObjectClasses = (List<SysSchemaObjectClassDto>) objectClassService.saveAll(sysObjectClasses);
    attributeService.saveAll(sysAttributes);
    return sysObjectClasses;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) SysSystem_(eu.bcvsolutions.idm.acc.entity.SysSystem_) FormPropertyManager(eu.bcvsolutions.idm.acc.service.api.FormPropertyManager) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) Asserts(org.apache.http.util.Asserts) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) Predicate(javax.persistence.criteria.Predicate) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcConfigurationFacade(eu.bcvsolutions.idm.ic.service.api.IcConfigurationFacade) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IcConnectorKeyImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) Serializable(java.io.Serializable) List(java.util.List) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Optional(java.util.Optional) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) HashMap(java.util.HashMap) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemRepository(eu.bcvsolutions.idm.acc.repository.SysSystemRepository) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IdmPasswordPolicy_(eu.bcvsolutions.idm.core.model.entity.IdmPasswordPolicy_) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) IcObjectClassInfo(eu.bcvsolutions.idm.ic.api.IcObjectClassInfo) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) Service(org.springframework.stereotype.Service) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) SysSystemFormValueService(eu.bcvsolutions.idm.acc.service.api.SysSystemFormValueService) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) Root(javax.persistence.criteria.Root) IcAttributeInfo(eu.bcvsolutions.idm.ic.api.IcAttributeInfo) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IcAttributeInfo(eu.bcvsolutions.idm.ic.api.IcAttributeInfo) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ArrayList(java.util.ArrayList) IcObjectClassInfo(eu.bcvsolutions.idm.ic.api.IcObjectClassInfo) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IcConnectorConfiguration

use of eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method checkSystem.

@Override
@Transactional
public void checkSystem(SysSystemDto system) {
    Assert.notNull(system);
    // Find connector identification persisted in system
    IcConnectorKey connectorKey = system.getConnectorKey();
    if (connectorKey == null) {
        throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Find connector configuration persisted in system
    IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Call IC module
    icConfigurationFacade.test(system.getConnectorInstance(), connectorConfig);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with IcConnectorConfiguration

use of eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration in project CzechIdMng by bcvsolutions.

the class VsReqeustServiceTest method systemAccountFilterTest.

@Test
public void systemAccountFilterTest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    // We try realize the request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    request = requestService.realize(request);
    Assert.assertEquals(VsRequestState.REALIZED, request.getState());
    account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNotNull("Account cannot be null, because request was realized!", account);
    IcConnectorConfiguration configuration = systemService.getConnectorConfiguration(system);
    IcObjectClass objectClass = new IcObjectClassImpl("__ACCOUNT__");
    List<String> uids = new ArrayList<>();
    connectorFacade.search(system.getConnectorInstance(), configuration, objectClass, null, new IcResultsHandler() {

        @Override
        public boolean handle(IcConnectorObject connectorObject) {
            uids.add(connectorObject.getUidValue());
            return true;
        }
    });
    Assert.assertEquals(1, uids.size());
    Assert.assertEquals(USER_ONE_NAME, uids.get(0));
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcResultsHandler(eu.bcvsolutions.idm.ic.filter.api.IcResultsHandler) ArrayList(java.util.ArrayList) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)16 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)8 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)8 ArrayList (java.util.ArrayList)8 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)7 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)6 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 IcConnectorKey (eu.bcvsolutions.idm.ic.api.IcConnectorKey)5 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)4 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)4 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)4 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)4 SynchronizationContext (eu.bcvsolutions.idm.acc.domain.SynchronizationContext)3 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)3 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)3