Search in sources :

Example 1 with ConfigurationProperties

use of org.identityconnectors.framework.api.ConfigurationProperties in project midpoint by Evolveum.

the class ConnIdConfigurationTransformer method transformConnectorConfiguration.

/**
	 * Transforms midPoint XML configuration of the connector to the ICF
	 * configuration.
	 * <p/>
	 * The "configuration" part of the XML resource definition will be used.
	 * <p/>
	 * The provided ICF APIConfiguration will be modified, some values may be
	 * overwritten.
	 * 
	 * @param apiConfig
	 *            ICF connector configuration
	 * @param resourceType
	 *            midPoint XML configuration
	 * @throws SchemaException
	 * @throws ConfigurationException
	 */
public APIConfiguration transformConnectorConfiguration(PrismContainerValue configuration) throws SchemaException, ConfigurationException {
    APIConfiguration apiConfig = cinfo.createDefaultAPIConfiguration();
    ConfigurationProperties configProps = apiConfig.getConfigurationProperties();
    // The namespace of all the configuration properties specific to the
    // connector instance will have a connector instance namespace. This
    // namespace can be found in the resource definition.
    String connectorConfNs = connectorType.getNamespace();
    PrismContainer configurationPropertiesContainer = configuration.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    if (configurationPropertiesContainer == null) {
        // Also try this. This is an older way.
        configurationPropertiesContainer = configuration.findContainer(new QName(connectorConfNs, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME));
    }
    transformConnectorConfigurationProperties(configProps, configurationPropertiesContainer, connectorConfNs);
    PrismContainer connectorPoolContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME));
    ObjectPoolConfiguration connectorPoolConfiguration = apiConfig.getConnectorPoolConfiguration();
    transformConnectorPoolConfiguration(connectorPoolConfiguration, connectorPoolContainer);
    PrismProperty producerBufferSizeProperty = configuration.findProperty(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME));
    if (producerBufferSizeProperty != null) {
        apiConfig.setProducerBufferSize(parseInt(producerBufferSizeProperty));
    }
    PrismContainer connectorTimeoutsContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME));
    transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer);
    PrismContainer resultsHandlerConfigurationContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME));
    ResultsHandlerConfiguration resultsHandlerConfiguration = apiConfig.getResultsHandlerConfiguration();
    transformResultsHandlerConfiguration(resultsHandlerConfiguration, resultsHandlerConfigurationContainer);
    return apiConfig;
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) ResultsHandlerConfiguration(org.identityconnectors.framework.api.ResultsHandlerConfiguration) QName(javax.xml.namespace.QName) APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with ConfigurationProperties

use of org.identityconnectors.framework.api.ConfigurationProperties in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdConnectorConfiguration.

public static IcConnectorConfiguration convertConnIdConnectorConfiguration(APIConfiguration conf) {
    if (conf == null) {
        return null;
    }
    IcConnectorConfigurationImpl dto = new IcConnectorConfigurationImpl();
    dto.setConnectorPoolingSupported(conf.isConnectorPoolingSupported());
    dto.setProducerBufferSize(conf.getProducerBufferSize());
    ConfigurationProperties properties = conf.getConfigurationProperties();
    IcConfigurationPropertiesImpl propertiesDto = new IcConfigurationPropertiesImpl();
    if (properties != null && properties.getPropertyNames() != null) {
        List<String> propertyNames = properties.getPropertyNames();
        for (String name : propertyNames) {
            ConfigurationProperty property = properties.getProperty(name);
            IcConfigurationPropertyImpl propertyDto = (IcConfigurationPropertyImpl) convertConnIdConfigurationProperty(property);
            if (propertiesDto != null) {
                propertiesDto.getProperties().add(propertyDto);
            }
        }
    }
    dto.setConfigurationProperties(propertiesDto);
    IcObjectPoolConfigurationImpl connectorPoolConfiguration = (IcObjectPoolConfigurationImpl) convertConnIdPoolConfiguration(conf.getConnectorPoolConfiguration());
    dto.setConnectorPoolConfiguration(connectorPoolConfiguration);
    return dto;
}
Also used : ConfigurationProperty(org.identityconnectors.framework.api.ConfigurationProperty) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) IcObjectPoolConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 3 with ConfigurationProperties

use of org.identityconnectors.framework.api.ConfigurationProperties in project midpoint by Evolveum.

the class ConnectorFactoryConnIdImpl method generateConnectorConfigurationSchema.

private PrismSchema generateConnectorConfigurationSchema(ConnectorInfo cinfo, ConnectorType connectorType) {
    LOGGER.trace("Generating configuration schema for {}", this);
    APIConfiguration defaultAPIConfiguration = cinfo.createDefaultAPIConfiguration();
    ConfigurationProperties icfConfigurationProperties = defaultAPIConfiguration.getConfigurationProperties();
    if (icfConfigurationProperties == null || icfConfigurationProperties.getPropertyNames() == null || icfConfigurationProperties.getPropertyNames().isEmpty()) {
        LOGGER.debug("No configuration schema for {}", this);
        return null;
    }
    PrismSchema connectorSchema = new PrismSchemaImpl(connectorType.getNamespace(), prismContext);
    // Create configuration type - the type used by the "configuration"
    // element
    PrismContainerDefinitionImpl<?> configurationContainerDef = ((PrismSchemaImpl) connectorSchema).createPropertyContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_TYPE_LOCAL_NAME);
    // element with "ConfigurationPropertiesType" - the dynamic part of
    // configuration schema
    ComplexTypeDefinition configPropertiesTypeDef = ((PrismSchemaImpl) connectorSchema).createComplexTypeDefinition(new QName(connectorType.getNamespace(), ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_TYPE_LOCAL_NAME));
    // Create definition of "configurationProperties" type
    // (CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_TYPE_LOCAL_NAME)
    int displayOrder = 1;
    for (String icfPropertyName : icfConfigurationProperties.getPropertyNames()) {
        ConfigurationProperty icfProperty = icfConfigurationProperties.getProperty(icfPropertyName);
        QName propXsdType = ConnIdUtil.icfTypeToXsdType(icfProperty.getType(), icfProperty.isConfidential());
        LOGGER.trace("{}: Mapping ICF config schema property {} from {} to {}", new Object[] { this, icfPropertyName, icfProperty.getType(), propXsdType });
        PrismPropertyDefinitionImpl<?> propertyDefinifion = ((ComplexTypeDefinitionImpl) configPropertiesTypeDef).createPropertyDefinition(icfPropertyName, propXsdType);
        propertyDefinifion.setDisplayName(icfProperty.getDisplayName(null));
        propertyDefinifion.setHelp(icfProperty.getHelpMessage(null));
        if (ConnIdUtil.isMultivaluedType(icfProperty.getType())) {
            propertyDefinifion.setMaxOccurs(-1);
        } else {
            propertyDefinifion.setMaxOccurs(1);
        }
        if (icfProperty.isRequired() && icfProperty.getValue() == null) {
            // If ICF says that the property is required it may not be in fact really required if it also has a default value
            propertyDefinifion.setMinOccurs(1);
        } else {
            propertyDefinifion.setMinOccurs(0);
        }
        propertyDefinifion.setDisplayOrder(displayOrder);
        displayOrder++;
    }
    // Create common ICF configuration property containers as a references
    // to a static schema
    configurationContainerDef.createContainerDefinition(ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_ELEMENT, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_TYPE, 0, 1);
    configurationContainerDef.createPropertyDefinition(ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_ELEMENT, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_TYPE, 0, 1);
    configurationContainerDef.createContainerDefinition(ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_ELEMENT, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_TYPE, 0, 1);
    configurationContainerDef.createContainerDefinition(ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_TYPE, 0, 1);
    configurationContainerDef.createPropertyDefinition(ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_ELEMENT, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_TYPE, 0, 1);
    // No need to create definition of "configuration" element.
    // midPoint will look for this element, but it will be generated as part
    // of the PropertyContainer serialization to schema
    configurationContainerDef.createContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME, configPropertiesTypeDef, 1, 1);
    LOGGER.debug("Generated configuration schema for {}: {} definitions", this, connectorSchema.getDefinitions().size());
    return connectorSchema;
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConfigurationProperty(org.identityconnectors.framework.api.ConfigurationProperty) ComplexTypeDefinitionImpl(com.evolveum.midpoint.prism.ComplexTypeDefinitionImpl) PrismSchemaImpl(com.evolveum.midpoint.prism.schema.PrismSchemaImpl) QName(javax.xml.namespace.QName) APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString)

Example 4 with ConfigurationProperties

use of org.identityconnectors.framework.api.ConfigurationProperties in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertIcConnectorConfiguration.

public static APIConfiguration convertIcConnectorConfiguration(IcConnectorConfiguration icConf, APIConfiguration defaultConnIdConf) {
    if (icConf == null) {
        return null;
    }
    ((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolingSupported(icConf.isConnectorPoolingSupported());
    defaultConnIdConf.setProducerBufferSize(icConf.getProducerBufferSize());
    IcConfigurationProperties properties = icConf.getConfigurationProperties();
    ConfigurationProperties connIdProperties = defaultConnIdConf.getConfigurationProperties();
    if (properties != null && properties.getProperties() != null) {
        for (IcConfigurationProperty icProperty : properties.getProperties()) {
            if (connIdProperties != null) {
                connIdProperties.setPropertyValue(icProperty.getName(), icProperty.getValue());
            }
        }
    }
    ObjectPoolConfiguration connectorPoolConfiguration = convertIcPoolConfiguration(icConf.getConnectorPoolConfiguration());
    ((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolConfiguration(connectorPoolConfiguration);
    // This option must be enabled for pagination purpose
    defaultConnIdConf.getResultsHandlerConfiguration().setFilteredResultsHandlerInValidationMode(true);
    return defaultConnIdConf;
}
Also used : IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) APIConfigurationImpl(org.identityconnectors.framework.impl.api.APIConfigurationImpl) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)

Aggregations

ConfigurationProperties (org.identityconnectors.framework.api.ConfigurationProperties)4 GuardedString (org.identityconnectors.common.security.GuardedString)3 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)2 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)2 QName (javax.xml.namespace.QName)2 ObjectPoolConfiguration (org.identityconnectors.common.pooling.ObjectPoolConfiguration)2 APIConfiguration (org.identityconnectors.framework.api.APIConfiguration)2 ConfigurationProperty (org.identityconnectors.framework.api.ConfigurationProperty)2 ComplexTypeDefinition (com.evolveum.midpoint.prism.ComplexTypeDefinition)1 ComplexTypeDefinitionImpl (com.evolveum.midpoint.prism.ComplexTypeDefinitionImpl)1 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)1 PrismSchemaImpl (com.evolveum.midpoint.prism.schema.PrismSchemaImpl)1 IcObjectPoolConfiguration (eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration)1 IcConfigurationPropertiesImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl)1 IcConfigurationPropertyImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)1 IcConnectorConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl)1 IcObjectPoolConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl)1