Search in sources :

Example 11 with IcConnectorInstance

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

the class ProvisioningDeleteProcessor method processInternal.

@Override
public IcUidAttribute processInternal(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig) {
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    IcConnectorInstance connectorInstance = systemService.getConnectorInstance(system);
    String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    // 
    IcConnectorObject connectorObject = connectorFacade.readObject(connectorInstance, connectorConfig, objectClass, uidAttribute);
    if (connectorObject != null) {
        connectorFacade.deleteObject(connectorInstance, connectorConfig, objectClass, uidAttribute);
    }
    return null;
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 12 with IcConnectorInstance

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

the class MssqlConnectorTypeTest method testAdditionalMSSQLAttributes.

@Test
public void testAdditionalMSSQLAttributes() {
    // If not, whole test will be skipped.
    if (!getJdbcConnectorTypeDriverName().equals(getDriver())) {
    // Skip test.
    // return;
    }
    ConnectorTypeDto connectorTypeDto = getConnectorTypeDto();
    connectorTypeDto.setReopened(false);
    ConnectorTypeDto jdbcConnectorTypeDto = connectorManager.load(connectorTypeDto);
    assertNotNull(jdbcConnectorTypeDto);
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.HOST, this.getHost());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PORT, this.getPort());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.DATABASE, this.getDatabase());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.USER, this.getUsername());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PASSWORD, this.getPassword());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.TABLE, "idm_identity");
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.KEY_COLUMN, "username");
    jdbcConnectorTypeDto.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.AUTHENTICATION_TYPE_KEY, MsSqlConnectorType.WINDOWS_AUTHENTICATION_TYPE);
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.TRUST_SERVER_CRT_SWITCH, Boolean.TRUE.toString());
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.NTLM_SWITCH, Boolean.TRUE.toString());
    String domain = getHelper().createName();
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.DOMAIN_KEY, domain);
    String instanceName = getHelper().createName();
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.INSTANCE_NAME_KEY, instanceName);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(jdbcConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(AbstractJdbcConnectorType.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("net.tirasa.connid.bundles.db.table.DatabaseTableConnector", connectorInstance.getConnectorKey().getConnectorName());
    IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(systemDto);
    String jdbcUrlTemplate = getValueFromConnectorInstance(AbstractJdbcConnectorType.JDBC_URL_TEMPLATE, systemDto, connectorFormDef);
    // Check Windows auth.
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.WINDOWS_AUTHENTICATION_TYPE_TEMPLATE));
    // Check trust CRT.
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.TRUST_SERVER_CRT_TEMPLATE));
    // Check NTLM.
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.NTLM_TEMPLATE));
    // Check Domain.
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.DOMAIN_TEMPLATE + domain));
    // Check instance name.
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.INSTANCE_NAME_TEMPLATE + instanceName));
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test)

Example 13 with IcConnectorInstance

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

the class MssqlConnectorTypeTest method testUpdateAdditionalMSSQLAttributes.

@Test
public void testUpdateAdditionalMSSQLAttributes() {
    // If not, whole test will be skipped.
    if (!getJdbcConnectorTypeDriverName().equals(getDriver())) {
    // Skip test.
    // return;
    }
    ConnectorTypeDto connectorTypeDto = getConnectorTypeDto();
    connectorTypeDto.setReopened(false);
    ConnectorTypeDto jdbcConnectorTypeDto = connectorManager.load(connectorTypeDto);
    assertNotNull(jdbcConnectorTypeDto);
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.HOST, this.getHost());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PORT, this.getPort());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.DATABASE, this.getDatabase());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.USER, this.getUsername());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PASSWORD, this.getPassword());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.TABLE, "idm_identity");
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.KEY_COLUMN, "username");
    jdbcConnectorTypeDto.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.AUTHENTICATION_TYPE_KEY, MsSqlConnectorType.WINDOWS_AUTHENTICATION_TYPE);
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.TRUST_SERVER_CRT_SWITCH, Boolean.TRUE.toString());
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.NTLM_SWITCH, Boolean.TRUE.toString());
    String domain = getHelper().createName();
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.DOMAIN_KEY, domain);
    String instanceName = getHelper().createName();
    jdbcConnectorTypeDto.getMetadata().put(MsSqlConnectorType.INSTANCE_NAME_KEY, instanceName);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(jdbcConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(AbstractJdbcConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    connectorManager.findConnectorTypeBySystem(systemDto);
    ConnectorTypeDto reopenSystem = getConnectorTypeDto();
    reopenSystem.setReopened(true);
    reopenSystem.getEmbedded().put(PostgresqlConnectorType.SYSTEM_DTO_KEY, systemDto);
    reopenSystem.getMetadata().put(PostgresqlConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    reopenSystem = connectorManager.load(reopenSystem);
    assertNotNull(reopenSystem);
    reopenSystem.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Change addition attributes
    reopenSystem.getMetadata().put(MsSqlConnectorType.AUTHENTICATION_TYPE_KEY, MsSqlConnectorType.SQL_SERVER_AUTHENTICATION_TYPE);
    reopenSystem.getMetadata().put(MsSqlConnectorType.TRUST_SERVER_CRT_SWITCH, Boolean.FALSE.toString());
    reopenSystem.getMetadata().put(MsSqlConnectorType.NTLM_SWITCH, Boolean.FALSE.toString());
    String domainTwo = getHelper().createName();
    reopenSystem.getMetadata().put(MsSqlConnectorType.DOMAIN_KEY, domainTwo);
    String instanceNameTwo = getHelper().createName();
    reopenSystem.getMetadata().put(MsSqlConnectorType.INSTANCE_NAME_KEY, instanceNameTwo);
    // Execute the first step again.
    connectorManager.execute(reopenSystem);
    // Load connector properties from created system.
    IcConnectorInstance connectorInstance = systemService.getConnectorInstance(systemDto);
    assertEquals("net.tirasa.connid.bundles.db.table.DatabaseTableConnector", connectorInstance.getConnectorKey().getConnectorName());
    IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(systemDto);
    String jdbcUrlTemplate = getValueFromConnectorInstance(AbstractJdbcConnectorType.JDBC_URL_TEMPLATE, systemDto, connectorFormDef);
    // Check Windows auth.
    Assert.assertFalse(jdbcUrlTemplate.contains(MsSqlConnectorType.WINDOWS_AUTHENTICATION_TYPE_TEMPLATE));
    // Check trust CRT.
    Assert.assertFalse(jdbcUrlTemplate.contains(MsSqlConnectorType.TRUST_SERVER_CRT_TEMPLATE));
    // Check NTLM.
    Assert.assertFalse(jdbcUrlTemplate.contains(MsSqlConnectorType.NTLM_TEMPLATE));
    // Check Domain.
    Assert.assertFalse(jdbcUrlTemplate.contains(MsSqlConnectorType.DOMAIN_TEMPLATE + domain));
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.DOMAIN_TEMPLATE + domainTwo));
    // Check instance name.
    Assert.assertFalse(jdbcUrlTemplate.contains(MsSqlConnectorType.INSTANCE_NAME_TEMPLATE + instanceName));
    Assert.assertTrue(jdbcUrlTemplate.contains(MsSqlConnectorType.INSTANCE_NAME_TEMPLATE + instanceNameTwo));
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test)

Example 14 with IcConnectorInstance

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

the class AbstractJdbcConnectorTypeTest method testJdbcFirstStep.

public void testJdbcFirstStep() {
    // If not, whole test will be skipped.
    if (!getJdbcConnectorTypeDriverName().equals(getDriver())) {
        // Skip test.
        return;
    }
    ConnectorTypeDto mockPostgresqlConnectorTypeDto = getConnectorTypeDto();
    mockPostgresqlConnectorTypeDto.setReopened(false);
    mockPostgresqlConnectorTypeDto.setId(this.getJdbcConnectorType());
    ConnectorTypeDto jdbcConnectorTypeDto = connectorManager.load(mockPostgresqlConnectorTypeDto);
    assertNotNull(jdbcConnectorTypeDto);
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.HOST, this.getHost());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PORT, this.getPort());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.DATABASE, this.getDatabase());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.USER, this.getUsername());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PASSWORD, this.getPassword());
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.TABLE, "idm_identity");
    jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.KEY_COLUMN, "username");
    jdbcConnectorTypeDto.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(jdbcConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(AbstractJdbcConnectorType.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("net.tirasa.connid.bundles.db.table.DatabaseTableConnector", connectorInstance.getConnectorKey().getConnectorName());
    IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(systemDto);
    // Check host.
    Assert.assertEquals(this.getHost(), getValueFromConnectorInstance(AbstractJdbcConnectorType.HOST, systemDto, connectorFormDef));
    // Check port.
    Assert.assertEquals(this.getPort(), getValueFromConnectorInstance(AbstractJdbcConnectorType.PORT, systemDto, connectorFormDef));
    // Check database.
    Assert.assertEquals(this.getDatabase(), getValueFromConnectorInstance(AbstractJdbcConnectorType.DATABASE, systemDto, connectorFormDef));
    // Check user.
    Assert.assertEquals(this.getUsername(), getValueFromConnectorInstance(AbstractJdbcConnectorType.USER, systemDto, connectorFormDef));
    // Check password.
    assertEquals("idm_identity", getValueFromConnectorInstance(AbstractJdbcConnectorType.TABLE, systemDto, connectorFormDef));
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 15 with IcConnectorInstance

use of eu.bcvsolutions.idm.ic.api.IcConnectorInstance 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

IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)10 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)9 IcConnectorInstanceImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl)6 Test (org.junit.Test)6 ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 IcConnectorKey (eu.bcvsolutions.idm.ic.api.IcConnectorKey)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)4 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)4 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)4 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)4 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)4