Search in sources :

Example 1 with IcConfigurationPropertiesImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl 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 2 with IcConfigurationPropertiesImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl in project CzechIdMng by bcvsolutions.

the class CzechIdMIcConfigurationService method initDefaultConfiguration.

/**
 * Create instance of default connector configuration
 *
 * @param configurationClass
 * @return
 */
private IcConnectorConfiguration initDefaultConfiguration(Class<? extends ConfigurationClass> configurationClass) {
    try {
        ConfigurationClass configurationClassInstance = configurationClass.newInstance();
        List<IcConfigurationProperty> properties = new ArrayList<>();
        PropertyDescriptor[] descriptors = Introspector.getBeanInfo(configurationClass).getPropertyDescriptors();
        Lists.newArrayList(descriptors).stream().forEach(descriptor -> {
            Method readMethod = descriptor.getReadMethod();
            String propertyName = descriptor.getName();
            ConfigurationClassProperty property = readMethod.getAnnotation(ConfigurationClassProperty.class);
            if (property != null) {
                IcConfigurationPropertyImpl icProperty = (IcConfigurationPropertyImpl) CzechIdMIcConvertUtil.convertConfigurationProperty(property);
                icProperty.setName(propertyName);
                icProperty.setType(readMethod.getGenericReturnType().getTypeName());
                try {
                    icProperty.setValue(readMethod.invoke(configurationClassInstance));
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                    throw new CoreException("Cannot read value of connector configuration property!", e);
                }
                properties.add(icProperty);
            }
        });
        // Sort by order
        properties.sort(Comparator.comparing(IcConfigurationProperty::getOrder));
        IcConfigurationPropertiesImpl icProperties = new IcConfigurationPropertiesImpl();
        icProperties.setProperties(properties);
        IcConnectorConfigurationImpl configuration = new IcConnectorConfigurationImpl();
        configuration.setConnectorPoolingSupported(false);
        configuration.setConfigurationProperties(icProperties);
        return configuration;
    } catch (IntrospectionException | InstantiationException | IllegalAccessException e) {
        throw new CoreException("Cannot read connector configuration property!", e);
    }
}
Also used : ConfigurationClass(eu.bcvsolutions.idm.core.api.domain.ConfigurationClass) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) PropertyDescriptor(java.beans.PropertyDescriptor) ArrayList(java.util.ArrayList) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConfigurationClassProperty(eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 3 with IcConfigurationPropertiesImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method getConnectorConfiguration.

@Override
@Transactional
public IcConnectorConfiguration getConnectorConfiguration(SysSystemDto system) {
    Assert.notNull(system);
    if (system.getConnectorKey() == null) {
        return null;
    }
    IcConnectorConfiguration connectorConfig = null;
    // load connector properties, different between local and remote
    IcConnectorInstance connectorInstance = system.getConnectorInstance();
    if (system.isRemote() && connectorInstance.getConnectorServer() != null) {
        connectorInstance.getConnectorServer().setPassword(confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
    }
    connectorConfig = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
    // load filled form values
    IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(system.getConnectorInstance());
    IdmFormInstanceDto formValues = getFormService().getFormInstance(system, formDefinition);
    Map<String, List<IdmFormValueDto>> attributeValues = formValues.toValueMap();
    // fill connector configuration from form values
    IcConnectorConfigurationImpl icConf = null;
    if (SysSystemService.CONNECTOR_FRAMEWORK_CZECHIDM.equals(connectorInstance.getConnectorKey().getFramework())) {
        // For CzechIdM connector framework is needs system ID (exactly for virtual systems).
        icConf = new IcConnectorConfigurationCzechIdMImpl();
        ((IcConnectorConfigurationCzechIdMImpl) icConf).setSystemId(system.getId());
    } else {
        icConf = new IcConnectorConfigurationImpl();
    }
    IcConfigurationProperties properties = new IcConfigurationPropertiesImpl();
    icConf.setConfigurationProperties(properties);
    // 
    for (short seq = 0; seq < connectorConfig.getConfigurationProperties().getProperties().size(); seq++) {
        IcConfigurationProperty propertyConfig = connectorConfig.getConfigurationProperties().getProperties().get(seq);
        IdmFormAttributeDto formAttribute = formDefinition.getMappedAttributeByCode(propertyConfig.getName());
        List<IdmFormValueDto> eavAttributeValues = attributeValues.get(formAttribute.getCode());
        // create property instance from configuration
        IcConfigurationProperty property = formPropertyManager.toConnectorProperty(propertyConfig, eavAttributeValues);
        if (property.getValue() != null) {
            // only filled values to configuration
            properties.getProperties().add(property);
        }
    }
    return icConf;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) List(java.util.List) ArrayList(java.util.ArrayList) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)3 IcConfigurationPropertiesImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl)3 IcConnectorConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl)3 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)2 IcConfigurationPropertyImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)2 ArrayList (java.util.ArrayList)2 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)1 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 ConfigurationClassProperty (eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)1 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)1 IcConnectorConfigurationCzechIdMImpl (eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl)1 IcObjectPoolConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl)1 IntrospectionException (java.beans.IntrospectionException)1