use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorITCase method history.
@Test
public void history() {
List<ConnInstanceHistoryConfTO> history = connectorHistoryService.list("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
assertNotNull(history);
int pre = history.size();
ConnInstanceTO ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
String originalDisplayName = ldapConn.getDisplayName();
Set<ConnectorCapability> originalCapabilities = new HashSet<>(ldapConn.getCapabilities());
ConnConfProperty originalConfProp = SerializationUtils.clone(ldapConn.getConf("maintainPosixGroupMembership").get());
assertEquals(1, originalConfProp.getValues().size());
assertEquals("false", originalConfProp.getValues().get(0));
ldapConn.setDisplayName(originalDisplayName + " modified");
ldapConn.getCapabilities().clear();
ldapConn.getConf("maintainPosixGroupMembership").get().getValues().set(0, "true");
connectorService.update(ldapConn);
ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
assertNotEquals(originalDisplayName, ldapConn.getDisplayName());
assertNotEquals(originalCapabilities, ldapConn.getCapabilities());
assertNotEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership"));
history = connectorHistoryService.list("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
assertEquals(pre + 1, history.size());
connectorHistoryService.restore(history.get(0).getKey());
ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
assertEquals(originalDisplayName, ldapConn.getDisplayName());
assertEquals(originalCapabilities, ldapConn.getCapabilities());
assertEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership").get());
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnInstanceDataBinderImpl method getConnInstanceTO.
@Override
public ConnInstanceTO getConnInstanceTO(final ConnInstance connInstance) {
ConnInstanceTO connInstanceTO = new ConnInstanceTO();
Pair<URI, ConnectorInfo> info = connIdBundleManager.getConnectorInfo(connInstance);
BeanUtils.copyProperties(connInstance, connInstanceTO, IGNORE_PROPERTIES);
connInstanceTO.setAdminRealm(connInstance.getAdminRealm().getFullPath());
connInstanceTO.setLocation(info.getLeft().toASCIIString());
connInstanceTO.getConf().addAll(connInstance.getConf());
// refresh stored properties in the given connInstance with direct information from underlying connector
ConfigurationProperties properties = connIdBundleManager.getConfigurationProperties(info.getRight());
properties.getPropertyNames().forEach(propName -> {
ConnConfPropSchema schema = build(properties.getProperty(propName));
Optional<ConnConfProperty> property = connInstanceTO.getConf(propName);
if (!property.isPresent()) {
property = Optional.of(new ConnConfProperty());
connInstanceTO.getConf().add(property.get());
}
property.get().setSchema(schema);
});
Collections.sort(connInstanceTO.getConf());
// pool configuration
if (connInstance.getPoolConf() != null && (connInstance.getPoolConf().getMaxIdle() != null || connInstance.getPoolConf().getMaxObjects() != null || connInstance.getPoolConf().getMaxWait() != null || connInstance.getPoolConf().getMinEvictableIdleTimeMillis() != null || connInstance.getPoolConf().getMinIdle() != null)) {
ConnPoolConfTO poolConf = new ConnPoolConfTO();
BeanUtils.copyProperties(connInstance.getPoolConf(), poolConf);
connInstanceTO.setPoolConf(poolConf);
}
return connInstanceTO;
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnInstanceTest method save.
@Test
public void save() throws ClassNotFoundException {
ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class);
connInstance.setLocation(new File(System.getProperty("java.io.tmpdir")).toURI().toString());
// set connector version
connInstance.setVersion("1.0");
// set connector name
connInstance.setConnectorName("WebService");
// set bundle name
connInstance.setBundleName("org.apache.syncope.core.persistence.test.util");
connInstance.setDisplayName("New");
connInstance.setConnRequestTimeout(60);
// 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://host.domain");
ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
servicenameSchema.setName("servicename");
servicenameSchema.setType(String.class.getName());
servicenameSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(servicenameSchema);
endpoint.getValues().add("Provisioning");
conf.add(endpoint);
conf.add(servicename);
// set connector configuration
connInstance.setConf(conf);
assertFalse(connInstance.getConf().isEmpty());
// perform save operation
ConnInstance actual = connInstanceDAO.save(connInstance);
assertNotNull("save did not work", actual.getKey());
assertEquals("WebService", actual.getConnectorName());
assertEquals("org.apache.syncope.core.persistence.test.util", actual.getBundleName());
assertEquals("1.0", connInstance.getVersion());
assertEquals("New", actual.getDisplayName());
assertEquals(60, actual.getConnRequestTimeout().intValue());
conf = connInstance.getConf();
assertFalse(conf.isEmpty());
assertNotNull(conf);
assertTrue(conf.size() == 2);
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ResourceITCase method createOverridingProps.
@Test
public void createOverridingProps() {
String resourceKey = "overriding-conn-conf-target-resource-create";
ResourceTO resourceTO = new ResourceTO();
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
resourceTO.getProvisions().add(provisionTO);
MappingTO mapping = new MappingTO();
provisionTO.setMapping(mapping);
ItemTO item = new ItemTO();
item.setExtAttrName("uid");
item.setIntAttrName("userId");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
item = new ItemTO();
item.setExtAttrName("username");
item.setIntAttrName("key");
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
item = new ItemTO();
item.setExtAttrName("fullname");
item.setIntAttrName("cn");
item.setConnObjectKey(false);
item.setPurpose(MappingPurpose.PROPAGATION);
mapping.add(item);
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
ConnConfProperty prop = new ConnConfProperty();
ConnConfPropSchema schema = new ConnConfPropSchema();
schema.setType("java.lang.String");
schema.setName("endpoint");
schema.setRequired(true);
prop.setSchema(schema);
prop.getValues().add("http://invalidurl/");
Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<>(Arrays.asList(prop));
resourceTO.getConfOverride().addAll(connectorConfigurationProperties);
Response response = resourceService.create(resourceTO);
ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
assertNotNull(actual);
// check the existence
actual = resourceService.read(resourceKey);
assertNotNull(actual);
assertNull(actual.getPropagationPriority());
}
use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.
the class ConnectorITCase method issueSYNCOPE112.
@Test
public void issueSYNCOPE112() {
// ----------------------------------------
// Create a new connector
// ----------------------------------------
ConnInstanceTO connectorTO = new ConnInstanceTO();
connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
connectorTO.setLocation(connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage()).getLocation());
// set connector version
connectorTO.setVersion(connIdSoapVersion);
// set connector name
connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
// set bundle name
connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
// set display name
connectorTO.setDisplayName("WSSoap");
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<>();
ConnConfPropSchema userSchema = new ConnConfPropSchema();
userSchema.setName("endpoint");
userSchema.setType(String.class.getName());
userSchema.setRequired(true);
ConnConfProperty endpoint = new ConnConfProperty();
endpoint.setSchema(userSchema);
endpoint.getValues().add("http://localhost:9080/does_not_work");
endpoint.setOverridable(true);
ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
keyColumnSchema.setName("servicename");
keyColumnSchema.setType(String.class.getName());
keyColumnSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(keyColumnSchema);
servicename.getValues().add("net.tirasa.connid.bundles.soap.provisioning.interfaces.Provisioning");
servicename.setOverridable(false);
conf.add(endpoint);
conf.add(servicename);
// set connector configuration
connectorTO.getConf().addAll(conf);
try {
try {
connectorService.check(connectorTO);
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
Response response = connectorService.create(connectorTO);
if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
}
connectorTO = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
assertNotNull(connectorTO);
// ----------------------------------------
// ----------------------------------------
// create a resourceTO
// ----------------------------------------
String resourceName = "checkForPropOverriding";
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
resourceTO.setConnector(connectorTO.getKey());
conf = new HashSet<>();
endpoint.getValues().clear();
endpoint.getValues().add("http://localhost:9080/syncope-fit-build-tools/cxf/soap/provisioning");
conf.add(endpoint);
resourceTO.getConfOverride().addAll(conf);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
resourceTO.getProvisions().add(provisionTO);
MappingTO mapping = new MappingTO();
provisionTO.setMapping(mapping);
ItemTO mapItem = new ItemTO();
mapItem.setExtAttrName("uid");
mapItem.setIntAttrName("userId");
mapItem.setConnObjectKey(true);
mapping.setConnObjectKeyItem(mapItem);
// ----------------------------------------
try {
resourceService.check(resourceTO);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
}
// ----------------------------------------
} finally {
// Remove connector from db to make test re-runnable
connectorService.delete(connectorTO.getKey());
}
}
Aggregations