Search in sources :

Example 1 with IcConfigurationProperties

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

the class ConnIdIcConvertUtil method convertIcConnectorConfiguration.

public static APIConfiguration convertIcConnectorConfiguration(IcConnectorConfiguration icConf, APIConfiguration defaultConnIdConf) {
    if (icConf == null) {
        return null;
    }
    ((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolingSupported(icConf.isConnectorPoolingSupported());
    defaultConnIdConf.setProducerBufferSize(icConf.getProducerBufferSize());
    IcConfigurationProperties properties = icConf.getConfigurationProperties();
    ConfigurationProperties connIdProperties = defaultConnIdConf.getConfigurationProperties();
    if (properties != null && properties.getProperties() != null) {
        for (IcConfigurationProperty icProperty : properties.getProperties()) {
            if (connIdProperties != null) {
                connIdProperties.setPropertyValue(icProperty.getName(), icProperty.getValue());
            }
        }
    }
    ObjectPoolConfiguration connectorPoolConfiguration = convertIcPoolConfiguration(icConf.getConnectorPoolConfiguration());
    ((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolConfiguration(connectorPoolConfiguration);
    Map<String, Object> systemOperationOptions = icConf.getSystemOperationOptions();
    boolean disableFilterValidation = false;
    if (systemOperationOptions != null && systemOperationOptions.containsKey(IcConnectorConfiguration.DISABLE_FILTER_VALIDATION_KEY)) {
        Object valueObj = systemOperationOptions.get(IcConnectorConfiguration.DISABLE_FILTER_VALIDATION_KEY);
        if (Boolean.TRUE.equals(valueObj)) {
            disableFilterValidation = true;
        }
    }
    // Filter authentication can be turned off because it does not work properly in some cases.
    // This option must be enabled for pagination purpose.
    defaultConnIdConf.getResultsHandlerConfiguration().setEnableFilteredResultsHandler(!disableFilterValidation);
    defaultConnIdConf.getResultsHandlerConfiguration().setFilteredResultsHandlerInValidationMode(!disableFilterValidation);
    return defaultConnIdConf;
}
Also used : IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) APIConfigurationImpl(org.identityconnectors.framework.impl.api.APIConfigurationImpl) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)

Example 2 with IcConfigurationProperties

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

the class DefaultSysSystemService method getConnectorConfiguration.

@Override
@Transactional
public IcConnectorConfiguration getConnectorConfiguration(SysSystemDto system) {
    Assert.notNull(system, "System is required.");
    if (system.getConnectorKey() == null) {
        return null;
    }
    IcConnectorConfiguration connectorConfig = null;
    // load connector properties, different between local and remote
    IcConnectorInstance connectorInstance = getConnectorInstance(system);
    connectorConfig = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
    // load filled form values
    IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(connectorInstance);
    IdmFormInstanceDto formInstance = getFormService().getFormInstance(system, formDefinition);
    Map<String, List<IdmFormValueDto>> attributeValues = formInstance.toValueMap();
    // fill connector configuration from form values
    IcConnectorConfigurationImpl configuration = null;
    if (SysSystemService.CONNECTOR_FRAMEWORK_CZECHIDM.equals(connectorInstance.getConnectorKey().getFramework())) {
        // For CzechIdM connector framework is needs system ID (exactly for virtual systems).
        configuration = new IcConnectorConfigurationCzechIdMImpl();
        ((IcConnectorConfigurationCzechIdMImpl) configuration).setSystemId(system.getId());
    } else {
        configuration = new IcConnectorConfigurationImpl();
    }
    // Create configuration for pool
    fillPoolingConnectorConfiguration(configuration, connectorInstance, system);
    // Load operation options
    configuration.setOperationOptions(getOperationOptionsForSystem(connectorInstance, system));
    IcConfigurationProperties properties = new IcConfigurationPropertiesImpl();
    configuration.setConfigurationProperties(properties);
    // 
    for (short seq = 0; seq < connectorConfig.getConfigurationProperties().getProperties().size(); seq++) {
        IcConfigurationProperty propertyConfig = connectorConfig.getConfigurationProperties().getProperties().get(seq);
        IdmFormAttributeDto formAttribute = formInstance.getMappedAttributeByCode(propertyConfig.getName());
        List<IdmFormValueDto> eavAttributeValues = attributeValues.get(formAttribute.getCode());
        // create property instance from configuration
        IcConfigurationProperty property = formPropertyManager.toConnectorProperty(propertyConfig, eavAttributeValues);
        if (property.getValue() != null) {
            // only filled values to configuration
            properties.getProperties().add(property);
        }
    }
    return configuration;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) List(java.util.List) ArrayList(java.util.ArrayList) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with IcConfigurationProperties

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

the class CsvConnectorTypeTest method testCsvSecondStep.

@Test
public void testCsvSecondStep() {
    ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
    mockCsvConnectorTypeDto.setReopened(false);
    mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
    mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
    ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
    assertNotNull(csvConnectorTypeDto);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(systemDto.getId());
    schemaAttributeFilter.setName("username");
    SysSchemaAttributeDto usernameAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().findFirst().orElse(null);
    assertNotNull(usernameAttributeDto);
    // Set username attribute as primary attribute for second wizard step.
    stepExecutedResult.getMetadata().put(CsvConnectorType.PRIMARY_SCHEMA_ATTRIBUTE, usernameAttributeDto.getId().toString());
    // Execute the second step.
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_TWO_SELECT_PK);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    connectorManager.execute(csvConnectorTypeDto);
    // Load connector properties from created system.
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
    IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
    // Check uid attribute.
    IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(uidProperty);
    // UID attribute have to be "username" now.
    assertEquals(usernameAttributeDto.getName(), uidProperty.getValue());
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with IcConfigurationProperties

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

the class CsvConnectorTypeTest method testCsvFirstStep.

@Test
public void testCsvFirstStep() {
    ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
    mockCsvConnectorTypeDto.setReopened(false);
    mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
    mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
    ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
    assertNotNull(csvConnectorTypeDto);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    // Load connector properties from created system.
    IcConnectorInstance connectorInstance = systemService.getConnectorInstance(systemDto);
    assertEquals("eu.bcvsolutions.idm.connectors.csv.CSVConnConnector", connectorInstance.getConnectorKey().getConnectorName());
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
    IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
    // Check source path of CSV.
    IcConfigurationProperty sourcePathProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(sourcePathProperty);
    assertEquals(CSV_TEST_FILE.replace('/', '\\'), ((String) sourcePathProperty.getValue()).replace('/', '\\'));
    // Check separator.
    IcConfigurationProperty separatorProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(separatorProperty);
    // Check include headers.
    IcConfigurationProperty includeHeadersProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_INCLUDES_HEADERS.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(includeHeadersProperty);
    // Headers have to be always included in CSV file.
    assertEquals(true, includeHeadersProperty.getValue());
    // Check uid attribute (in first step has value "...random...").
    IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(uidProperty);
    // UID attribute have to be filled, but will be selected in the next wizard step -> is use temporary value "...random...".
    assertEquals("...random...", uidProperty.getValue());
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)4 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)4 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)3 ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)2 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)2 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 Test (org.junit.Test)2 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)1 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)1 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)1 IcObjectPoolConfiguration (eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration)1 IcConnectorConfigurationCzechIdMImpl (eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl)1 IcConfigurationPropertiesImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl)1