Search in sources :

Example 61 with IdmFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto 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)

Example 62 with IdmFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method createConnectorFormDefinition.

/**
 * Create form definition to given connectorInstance by connector properties
 *
 * @param connectorKey
 * @return
 */
private synchronized IdmFormDefinitionDto createConnectorFormDefinition(IcConnectorInstance connectorInstance) {
    IcConnectorConfiguration conf = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
    if (conf == null) {
        throw new IllegalStateException(MessageFormat.format("Connector with key [{0}] was not found on classpath.", connectorInstance.getConnectorKey().getFullName()));
    }
    // 
    List<IdmFormAttributeDto> formAttributes = new ArrayList<>();
    for (short seq = 0; seq < conf.getConfigurationProperties().getProperties().size(); seq++) {
        IcConfigurationProperty property = conf.getConfigurationProperties().getProperties().get(seq);
        IdmFormAttributeDto attribute = formPropertyManager.toFormAttribute(property);
        attribute.setSeq(seq);
        formAttributes.add(attribute);
    }
    return getFormService().createDefinition(SysSystem.class.getName(), connectorInstance.getConnectorKey().getFullName(), formAttributes);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) ArrayList(java.util.ArrayList)

Example 63 with IdmFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.

the class IdentityReportExecutor method getFormAttributes.

/**
 * Filter form attributes:
 * - enabled / disabled identities
 */
@Override
protected List<IdmFormAttributeDto> getFormAttributes() {
    IdmFormAttributeDto disabled = new IdmFormAttributeDto(IdmIdentityFilter.PARAMETER_DISABLED, "Disabled identities", PersistentType.BOOLEAN);
    // we want select box instead simple checkbox (null value is needed)
    disabled.setFaceType(BaseFaceType.BOOLEAN_SELECT);
    disabled.setPlaceholder("All identities or select ...");
    return Lists.newArrayList(disabled);
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)

Example 64 with IdmFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method updateFormDefinition.

/**
 * Create/Update form definition and attributes
 *
 * @param key
 * @param type
 * @param system
 * @param virtualConfiguration
 * @return
 */
private IdmFormDefinitionDto updateFormDefinition(String key, String type, SysSystemDto system, BasicVirtualConfiguration virtualConfiguration) {
    // TODO: delete attribute definitions
    IdmFormDefinitionDto definition = this.formService.getDefinition(type, key);
    List<IdmFormAttributeDto> formAttributes = new ArrayList<>();
    Arrays.asList(virtualConfiguration.getAttributes()).forEach(virtualAttirbute -> {
        IdmFormAttributeDto formAttribute = formAttributeService.findAttribute(type, key, virtualAttirbute);
        if (formAttribute == null) {
            formAttribute = createFromAttribute(virtualAttirbute);
            formAttribute.setFormDefinition(definition == null ? null : definition.getId());
            formAttributes.add(formAttribute);
        }
    });
    if (definition == null) {
        IdmFormDefinitionDto createdDefinition = this.formService.createDefinition(type, key, formAttributes);
        createdDefinition.setName(MessageFormat.format("Virtual system for [{0}]", system.getName()));
        createdDefinition.setUnmodifiable(true);
        return this.formService.saveDefinition(createdDefinition);
    } else {
        formAttributes.forEach(formAttribute -> {
            this.formService.saveAttribute(formAttribute);
        });
        return definition;
    }
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)

Example 65 with IdmFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method createFromAttribute.

private IdmFormAttributeDto createFromAttribute(String virtualAttirbute) {
    IdmFormAttributeDto formAttribute = new IdmFormAttributeDto();
    formAttribute.setCode(virtualAttirbute);
    formAttribute.setConfidential(false);
    formAttribute.setPersistentType(PersistentType.TEXT);
    formAttribute.setMultiple(false);
    formAttribute.setName(virtualAttirbute);
    formAttribute.setRequired(false);
    return formAttribute;
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)

Aggregations

IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)67 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)40 Test (org.junit.Test)40 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)32 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)22 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)15 Transactional (org.springframework.transaction.annotation.Transactional)12 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)11 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)10 ArrayList (java.util.ArrayList)9 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)7 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)7 UUID (java.util.UUID)7 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 Serializable (java.io.Serializable)5 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)4