Search in sources :

Example 1 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.

the class ConnectorITCase method update.

@Test
public void update() {
    ConnInstanceTO connectorTO = new ConnInstanceTO();
    connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
    // set connector instance key
    connectorTO.setKey("fcf9f2b0-f7d6-42c9-84a6-61b28255a42b");
    // 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");
    connectorTO.setConnRequestTimeout(20);
    // 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");
    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);
    servicename.getValues().add("Provisioning");
    conf.add(servicename);
    // set connector configuration
    connectorTO.getConf().addAll(conf);
    connectorService.update(connectorTO);
    ConnInstanceTO actual = connectorService.read(connectorTO.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(actual);
    actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(actual);
    assertEquals(actual.getBundleName(), connectorTO.getBundleName());
    assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
    assertEquals(actual.getVersion(), connectorTO.getVersion());
    assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 2 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema 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;
}
Also used : ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) URI(java.net.URI) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema)

Example 3 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema 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);
}
Also used : ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) File(java.io.File) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 4 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema 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());
}
Also used : Response(javax.ws.rs.core.Response) MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 5 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.

the class ConnInstanceDataBinderImpl method build.

@Override
public ConnConfPropSchema build(final ConfigurationProperty property) {
    ConnConfPropSchema connConfPropSchema = new ConnConfPropSchema();
    connConfPropSchema.setName(property.getName());
    connConfPropSchema.setDisplayName(property.getDisplayName(property.getName()));
    connConfPropSchema.setHelpMessage(property.getHelpMessage(property.getName()));
    connConfPropSchema.setRequired(property.isRequired());
    connConfPropSchema.setType(property.getType().getName());
    connConfPropSchema.setOrder(((ConfigurationPropertyImpl) property).getOrder());
    connConfPropSchema.setConfidential(property.isConfidential());
    if (property.getValue() != null) {
        if (property.getValue().getClass().isArray()) {
            connConfPropSchema.getDefaultValues().addAll(Arrays.asList((Object[]) property.getValue()));
        } else if (property.getValue() instanceof Collection<?>) {
            connConfPropSchema.getDefaultValues().addAll((Collection<?>) property.getValue());
        } else {
            connConfPropSchema.getDefaultValues().add(property.getValue());
        }
    }
    return connConfPropSchema;
}
Also used : Collection(java.util.Collection) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema)

Aggregations

ConnConfPropSchema (org.apache.syncope.common.lib.types.ConnConfPropSchema)8 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)7 HashSet (java.util.HashSet)6 Test (org.junit.jupiter.api.Test)6 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)5 GuardedString (org.identityconnectors.common.security.GuardedString)4 Response (javax.ws.rs.core.Response)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 IOException (java.io.IOException)2 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)2 ItemTO (org.apache.syncope.common.lib.to.ItemTO)2 MappingTO (org.apache.syncope.common.lib.to.MappingTO)2 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)2 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)2 File (java.io.File)1 URI (java.net.URI)1 Collection (java.util.Collection)1 ConnectorService (org.apache.syncope.common.rest.api.service.ConnectorService)1 ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)1 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)1