use of org.apache.syncope.common.lib.to.ConnInstanceTO 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.to.ConnInstanceTO in project syncope by apache.
the class AbstractITCase method getLdapResourceDirContext.
@SuppressWarnings({ "unchecked", "rawtypes", "UseOfObsoleteCollectionType" })
protected InitialDirContext getLdapResourceDirContext(final String bindDn, final String bindPwd) throws NamingException {
ResourceTO ldapRes = resourceService.read(RESOURCE_NAME_LDAP);
ConnInstanceTO ldapConn = connectorService.read(ldapRes.getConnector(), Locale.ENGLISH.getLanguage());
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://" + ldapConn.getConf("host").get().getValues().get(0) + ":" + ldapConn.getConf("port").get().getValues().get(0) + "/");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, bindDn == null ? ldapConn.getConf("principal").get().getValues().get(0) : bindDn);
env.put(Context.SECURITY_CREDENTIALS, bindPwd == null ? ldapConn.getConf("credentials").get().getValues().get(0) : bindPwd);
return new InitialDirContext(env);
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class ConnectorServiceImpl method create.
@Override
public Response create(final ConnInstanceTO connInstanceTO) {
ConnInstanceTO connInstance = logic.create(connInstanceTO);
URI location = uriInfo.getAbsolutePathBuilder().path(connInstance.getKey()).build();
return Response.created(location).header(RESTHeaders.RESOURCE_KEY, connInstance.getKey()).build();
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class ConnectorDetails method details.
public void details() {
if (input.parameterNumber() == 0) {
try {
final Map<String, String> details = new LinkedHashMap<>();
final List<ConnInstanceTO> connInstanceTOs = connectorSyncopeOperations.list();
int withCreateCapability = 0;
int withDeleteCapability = 0;
int withSearchCapability = 0;
int withSyncCapability = 0;
int withUpdateCapability = 0;
for (final ConnInstanceTO connInstanceTO : connInstanceTOs) {
if (connInstanceTO.getCapabilities().contains(ConnectorCapability.CREATE)) {
withCreateCapability++;
}
if (connInstanceTO.getCapabilities().contains(ConnectorCapability.DELETE)) {
withDeleteCapability++;
}
if (connInstanceTO.getCapabilities().contains(ConnectorCapability.SEARCH)) {
withSearchCapability++;
}
if (connInstanceTO.getCapabilities().contains(ConnectorCapability.SYNC)) {
withSyncCapability++;
}
if (connInstanceTO.getCapabilities().contains(ConnectorCapability.UPDATE)) {
withUpdateCapability++;
}
}
details.put("Total number", String.valueOf(connInstanceTOs.size()));
details.put("With create capability", String.valueOf(withCreateCapability));
details.put("With delete capability", String.valueOf(withDeleteCapability));
details.put("With search capability", String.valueOf(withSearchCapability));
details.put("With sync capability", String.valueOf(withSyncCapability));
details.put("With update capability", String.valueOf(withUpdateCapability));
details.put("Bundles number", String.valueOf(connectorSyncopeOperations.getBundles().size()));
connectorResultManager.printDetails(details);
} catch (final SyncopeClientException ex) {
LOG.error("Error reading details about connector", ex);
connectorResultManager.genericError(ex.getMessage());
}
} else {
connectorResultManager.unnecessaryParameters(input.listParameters(), DETAILS_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class HistoryConfDetails method addCurrentInstanceConf.
@SuppressWarnings("unchecked")
private void addCurrentInstanceConf() {
T conf = null;
if (selectedHistoryConfTO instanceof ConnInstanceHistoryConfTO) {
ConnInstanceTO current = new ConnectorRestClient().read(ConnInstanceHistoryConfTO.class.cast(selectedHistoryConfTO).getConnInstanceTO().getKey());
conf = (T) new ConnInstanceHistoryConfTO();
((ConnInstanceHistoryConfTO) conf).setConnInstanceTO(current);
} else if (selectedHistoryConfTO instanceof ResourceHistoryConfTO) {
ResourceTO current = new ResourceRestClient().read(ResourceHistoryConfTO.class.cast(selectedHistoryConfTO).getResourceTO().getKey());
conf = (T) new ResourceHistoryConfTO();
((ResourceHistoryConfTO) conf).setResourceTO(current);
}
if (conf != null) {
conf.setCreator(selectedHistoryConfTO.getCreator());
conf.setKey("current");
availableHistoryConfTOs.add(conf);
}
}
Aggregations