Search in sources :

Example 1 with ConfigurationProperty

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

the class ConnIdConfigurationTransformer method transformConnectorConfigurationProperties.

private void transformConnectorConfigurationProperties(ConfigurationProperties configProps, PrismContainer<?> configurationPropertiesContainer, String connectorConfNs) throws ConfigurationException, SchemaException {
    if (configurationPropertiesContainer == null || configurationPropertiesContainer.getValue() == null) {
        throw new SchemaException("No configuration properties container in " + connectorType);
    }
    int numConfingProperties = 0;
    List<QName> wrongNamespaceProperties = new ArrayList<>();
    for (PrismProperty prismProperty : configurationPropertiesContainer.getValue().getProperties()) {
        QName propertyQName = prismProperty.getElementName();
        // namespace.
        if (propertyQName.getNamespaceURI() == null || !propertyQName.getNamespaceURI().equals(connectorConfNs)) {
            LOGGER.warn("Found element with a wrong namespace ({}) in {}", propertyQName.getNamespaceURI(), connectorType);
            wrongNamespaceProperties.add(propertyQName);
        } else {
            numConfingProperties++;
            // Local name of the element is the same as the name
            // of ConnId configuration property
            String propertyName = propertyQName.getLocalPart();
            ConfigurationProperty property = configProps.getProperty(propertyName);
            if (property == null) {
                throw new ConfigurationException("Unknown configuration property " + propertyName);
            }
            Class<?> type = property.getType();
            if (type.isArray()) {
                Object[] connIdArray = convertToConnIdArray(prismProperty, type.getComponentType());
                if (connIdArray != null && connIdArray.length != 0) {
                    property.setValue(connIdArray);
                }
            } else {
                Object connIdValue = convertToConnIdSingle(prismProperty, type);
                if (connIdValue != null) {
                    property.setValue(connIdValue);
                }
            }
        }
    }
    // empty configuration is OK e.g. when creating a new resource using wizard
    if (numConfingProperties == 0 && !wrongNamespaceProperties.isEmpty()) {
        throw new SchemaException("No configuration properties found. Wrong namespace? (expected: " + connectorConfNs + ", present e.g. " + wrongNamespaceProperties.get(0) + ")");
    }
}
Also used : ConfigurationProperty(org.identityconnectors.framework.api.ConfigurationProperty) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GuardedString(org.identityconnectors.common.security.GuardedString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with ConfigurationProperty

use of org.identityconnectors.framework.api.ConfigurationProperty 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);
    dto.setOperationOptions(Collections.emptyMap());
    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)

Aggregations

GuardedString (org.identityconnectors.common.security.GuardedString)2 ConfigurationProperty (org.identityconnectors.framework.api.ConfigurationProperty)2 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)1 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)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 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 ConfigurationProperties (org.identityconnectors.framework.api.ConfigurationProperties)1