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);
}
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;
}
Aggregations