use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorITCase method validate.
@Test
public void validate() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
connectorTO.setLocation(connectorServerLocation);
connectorTO.setVersion(connIdDbVersion);
connectorTO.setConnectorName("net.tirasa.connid.bundles.db.table.DatabaseTableConnector");
connectorTO.setBundleName("net.tirasa.connid.bundles.db.table");
connectorTO.setDisplayName("H2Test");
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<>();
ConnConfPropSchema jdbcDriverSchema = new ConnConfPropSchema();
jdbcDriverSchema.setName("jdbcDriver");
jdbcDriverSchema.setType(String.class.getName());
jdbcDriverSchema.setRequired(true);
ConnConfProperty jdbcDriver = new ConnConfProperty();
jdbcDriver.setSchema(jdbcDriverSchema);
jdbcDriver.getValues().add("org.h2.Driver");
conf.add(jdbcDriver);
ConnConfPropSchema jdbcUrlTemplateSchema = new ConnConfPropSchema();
jdbcUrlTemplateSchema.setName("jdbcUrlTemplate");
jdbcUrlTemplateSchema.setType(String.class.getName());
jdbcUrlTemplateSchema.setRequired(true);
ConnConfProperty jdbcUrlTemplate = new ConnConfProperty();
jdbcUrlTemplate.setSchema(jdbcUrlTemplateSchema);
jdbcUrlTemplate.getValues().add(testJDBCURL);
conf.add(jdbcUrlTemplate);
ConnConfPropSchema userSchema = new ConnConfPropSchema();
userSchema.setName("user");
userSchema.setType(String.class.getName());
userSchema.setRequired(false);
ConnConfProperty user = new ConnConfProperty();
user.setSchema(userSchema);
user.getValues().add("sa");
conf.add(user);
ConnConfPropSchema passwordSchema = new ConnConfPropSchema();
passwordSchema.setName("password");
passwordSchema.setType(GuardedString.class.getName());
passwordSchema.setRequired(true);
ConnConfProperty password = new ConnConfProperty();
password.setSchema(passwordSchema);
password.getValues().add("sa");
conf.add(password);
ConnConfPropSchema tableSchema = new ConnConfPropSchema();
tableSchema.setName("table");
tableSchema.setType(String.class.getName());
tableSchema.setRequired(true);
ConnConfProperty table = new ConnConfProperty();
table.setSchema(tableSchema);
table.getValues().add("test");
conf.add(table);
ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
keyColumnSchema.setName("keyColumn");
keyColumnSchema.setType(String.class.getName());
keyColumnSchema.setRequired(true);
ConnConfProperty keyColumn = new ConnConfProperty();
keyColumn.setSchema(keyColumnSchema);
keyColumn.getValues().add("id");
conf.add(keyColumn);
ConnConfPropSchema passwordColumnSchema = new ConnConfPropSchema();
passwordColumnSchema.setName("passwordColumn");
passwordColumnSchema.setType(String.class.getName());
passwordColumnSchema.setRequired(true);
ConnConfProperty passwordColumn = new ConnConfProperty();
passwordColumn.setSchema(passwordColumnSchema);
passwordColumn.getValues().add("password");
conf.add(passwordColumn);
// set connector configuration
connectorTO.getConf().addAll(conf);
try {
connectorService.check(connectorTO);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
}
conf.remove(password);
password.getValues().clear();
password.getValues().add("password");
conf.add(password);
try {
connectorService.check(connectorTO);
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorITCase method checkHiddenProperty.
@Test
public void checkHiddenProperty() {
ConnInstanceTO connInstanceTO = connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage());
boolean check = false;
for (ConnConfProperty prop : connInstanceTO.getConf()) {
if ("receiveTimeout".equals(prop.getSchema().getName())) {
check = true;
}
}
assertTrue(check);
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorITCase method create.
@Test
public void create() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
connectorTO.setLocation(connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage()).getLocation());
connectorTO.setVersion(connIdSoapVersion);
connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
connectorTO.setDisplayName("Display name");
connectorTO.setConnRequestTimeout(15);
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<>();
ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
endpointSchema.setName("endpoint");
endpointSchema.setType(String.class.getName());
endpointSchema.setRequired(true);
ConnConfProperty endpoint = new ConnConfProperty();
endpoint.setSchema(endpointSchema);
endpoint.getValues().add("http://localhost:8888/syncope-fit-build-tools/cxf/soap");
endpoint.getValues().add("Provisioning");
conf.add(endpoint);
ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
servicenameSchema.setName("servicename");
servicenameSchema.setType(String.class.getName());
servicenameSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(servicenameSchema);
conf.add(servicename);
// set connector configuration
connectorTO.getConf().addAll(conf);
// set connector capabilities
connectorTO.getCapabilities().add(ConnectorCapability.CREATE);
connectorTO.getCapabilities().add(ConnectorCapability.UPDATE);
// set connector pool conf
ConnPoolConfTO cpc = new ConnPoolConfTO();
cpc.setMaxObjects(1534);
connectorTO.setPoolConf(cpc);
Response response = connectorService.create(connectorTO);
if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
}
ConnInstanceTO actual = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
assertNotNull(actual);
assertEquals(actual.getBundleName(), connectorTO.getBundleName());
assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
assertEquals(actual.getVersion(), connectorTO.getVersion());
assertEquals("Display name", actual.getDisplayName());
assertEquals(Integer.valueOf(15), actual.getConnRequestTimeout());
assertEquals(connectorTO.getCapabilities(), actual.getCapabilities());
assertNotNull(actual.getPoolConf());
assertEquals(1534, actual.getPoolConf().getMaxObjects().intValue());
assertEquals(10, actual.getPoolConf().getMaxIdle().intValue());
Throwable t = null;
// check update
actual.getCapabilities().remove(ConnectorCapability.UPDATE);
actual.getPoolConf().setMaxObjects(null);
try {
connectorService.update(actual);
actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
} catch (SyncopeClientException e) {
LOG.error("update failed", e);
t = e;
}
assertNull(t);
assertNotNull(actual);
assertEquals(EnumSet.of(ConnectorCapability.CREATE), actual.getCapabilities());
assertEquals(10, actual.getPoolConf().getMaxObjects().intValue());
// check also for the deletion of the created object
try {
connectorService.delete(actual.getKey());
} catch (SyncopeClientException e) {
LOG.error("delete failed", e);
t = e;
}
assertNull(t);
// check the non existence
try {
connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
} catch (SyncopeClientException e) {
assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
}
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorManager method buildConnInstanceOverride.
@Override
public ConnInstance buildConnInstanceOverride(final ConnInstanceTO connInstance, final Collection<ConnConfProperty> confOverride, final Collection<ConnectorCapability> capabilitiesOverride) {
synchronized (this) {
if (entityFactory == null) {
entityFactory = ApplicationContextProvider.getApplicationContext().getBean(EntityFactory.class);
}
}
ConnInstance override = entityFactory.newEntity(ConnInstance.class);
override.setAdminRealm(realmDAO.findByFullPath(connInstance.getAdminRealm()));
override.setConnectorName(connInstance.getConnectorName());
override.setDisplayName(connInstance.getDisplayName());
override.setBundleName(connInstance.getBundleName());
override.setVersion(connInstance.getVersion());
override.setLocation(connInstance.getLocation());
override.setConf(connInstance.getConf());
override.getCapabilities().addAll(connInstance.getCapabilities());
override.setConnRequestTimeout(connInstance.getConnRequestTimeout());
Map<String, ConnConfProperty> overridable = new HashMap<>();
Set<ConnConfProperty> conf = new HashSet<>();
for (ConnConfProperty prop : override.getConf()) {
if (prop.isOverridable()) {
overridable.put(prop.getSchema().getName(), prop);
} else {
conf.add(prop);
}
}
// add override properties
for (ConnConfProperty prop : confOverride) {
if (overridable.containsKey(prop.getSchema().getName()) && !prop.getValues().isEmpty()) {
conf.add(prop);
overridable.remove(prop.getSchema().getName());
}
}
// add override properties not substituted
conf.addAll(overridable.values());
override.setConf(conf);
// replace capabilities
if (capabilitiesOverride != null) {
override.getCapabilities().clear();
override.getCapabilities().addAll(capabilitiesOverride);
}
return override;
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorRestClient method filterProperties.
private List<ConnConfProperty> filterProperties(final Collection<ConnConfProperty> properties) {
List<ConnConfProperty> newProperties = new ArrayList<>();
properties.stream().map(property -> {
ConnConfProperty prop = new ConnConfProperty();
prop.setSchema(property.getSchema());
prop.setOverridable(property.isOverridable());
final List<Object> parsed = new ArrayList<>();
if (property.getValues() != null) {
property.getValues().stream().filter(obj -> (obj != null && !obj.toString().isEmpty())).forEachOrdered((obj) -> {
parsed.add(obj);
});
}
prop.getValues().addAll(parsed);
return prop;
}).forEachOrdered(prop -> {
newProperties.add(prop);
});
return newProperties;
}
Aggregations