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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations