Search in sources :

Example 1 with IcConnectorConfigurationCzechIdMImpl

use of eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method init.

@Override
public void init(IcConnectorConfiguration configuration) {
    Assert.notNull(configuration);
    this.configuration = configuration;
    if (!(configuration instanceof IcConnectorConfigurationCzechIdMImpl)) {
        throw new IcException(MessageFormat.format("Connector configuration for virtual system must be instance of [{0}]", IcConnectorConfigurationCzechIdMImpl.class.getName()));
    }
    systemId = ((IcConnectorConfigurationCzechIdMImpl) configuration).getSystemId();
    if (systemId == null) {
        throw new IcException("System ID cannot be null (for virtual system)");
    }
    SysSystemDto system = this.systemService.get(systemId);
    if (system == null) {
        throw new IcException("System cannot be null (for virtual system)");
    }
    // TODO: This is workaround how mark SysSystem as virtual
    if (!system.isVirtual()) {
        system.setVirtual(true);
        system = this.systemService.save(system);
    }
    IcConnectorClass connectorAnnotation = this.getClass().getAnnotation(IcConnectorClass.class);
    IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, this.getClass());
    // Load configuration object
    virtualConfiguration = (BasicVirtualConfiguration) CzechIdMIcConvertUtil.convertIcConnectorConfiguration(configuration, connectorAnnotation.configurationClass());
    // Validate configuration
    virtualConfiguration.validate();
    connectorKey = info.getConnectorKey().getFullName();
    String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", connectorKey, systemId.toString());
    String type = VsAccount.class.getName();
    // Create/Update form definition and attributes
    formDefinition = updateFormDefinition(virtualSystemKey, type, system, virtualConfiguration);
    // Update identity and role implementers relations
    updateSystemImplementers(this.virtualConfiguration, this.systemId);
}
Also used : IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorClass(eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 2 with IcConnectorConfigurationCzechIdMImpl

use of eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl 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

IcConnectorConfigurationCzechIdMImpl (eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl)2 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)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 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)1 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)1 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)1 IcConnectorInfo (eu.bcvsolutions.idm.ic.api.IcConnectorInfo)1 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)1 IcConnectorClass (eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass)1 IcException (eu.bcvsolutions.idm.ic.exception.IcException)1 IcConfigurationPropertiesImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl)1 IcConnectorConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Transactional (org.springframework.transaction.annotation.Transactional)1