use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class DefaultModuleService method setEnabled.
@Override
public void setEnabled(String moduleId, boolean enabled) {
ModuleDescriptor moduleDescriptor = moduleDescriptorRegistry.getPluginFor(moduleId);
ModuleDescriptorDto moduleDescriptorDto = null;
if (moduleDescriptor == null) {
LOG.info("Frontend module [{}] will be enabled [{}].", moduleId, enabled);
// FE module - create basic descriptor
moduleDescriptorDto = new ModuleDescriptorDto(moduleId);
moduleDescriptorDto.setDisableable(true);
moduleDescriptorDto.setDisabled(!configurationService.getBooleanValue(getModuleConfigurationProperty(moduleId, ConfigurationService.PROPERTY_ENABLED), false));
} else {
LOG.info("Backend module [{}] will be enabled [{}].", moduleId, enabled);
//
moduleDescriptorDto = toDto(moduleDescriptor);
}
//
ModuleDescriptorEvent event = new ModuleDescriptorEvent(enabled ? ModuleDescriptorEventType.ENABLE : ModuleDescriptorEventType.DISABLE, moduleDescriptorDto);
entityEventManager.process(event);
}
use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class DefaultModuleService method toDto.
/**
* FIXME: DRY ModuleController#toResource => redesign to work with dto?
*/
private ModuleDescriptorDto toDto(ModuleDescriptor moduleDescriptor) {
ModuleDescriptorDto dto = mapper.map(moduleDescriptor, ModuleDescriptorDto.class);
//
dto.setId(moduleDescriptor.getId());
dto.setDisabled(!isEnabled(moduleDescriptor));
return dto;
}
use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class ModuleController method toResource.
/**
* TODO: resource support + self link
*
* @param moduleDescriptor
* @return
*/
protected ModuleDescriptorDto toResource(ModuleDescriptor moduleDescriptor) {
ModuleDescriptorDto dto = mapper.map(moduleDescriptor, ModuleDescriptorDto.class);
//
dto.setId(moduleDescriptor.getId());
dto.setDisabled(!moduleService.isEnabled(moduleDescriptor));
return dto;
}
use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class DefaultModuleServiceUnitTest method testIsDisableable.
@Test(expected = ModuleNotDisableableException.class)
public void testIsDisableable() {
ModuleDisableProcessor disableProcessor = new ModuleDisableProcessor();
ModuleDescriptorDto moduleDescriptor = new ModuleDescriptorDto(ModuleDescriptorOne.MODULE_ID);
moduleDescriptor.setDisableable(false);
//
disableProcessor.process(new ModuleDescriptorEvent(ModuleDescriptorEventType.DISABLE, moduleDescriptor));
}
use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class AccInitRemoteServerProcessor method process.
@Override
public EventResult<ModuleDescriptorDto> process(EntityEvent<ModuleDescriptorDto> event) {
// all remote systems => will be two at max
List<SysConnectorServerDto> remoteServers = Lists.newArrayList(remoteServerService.find(null).getContent());
// fill password
remoteServers.forEach(remoteServer -> {
remoteServer.setPassword(confidentialStorage.getGuardedString(remoteServer.getId(), SysRemoteServer.class, SysSystemService.REMOTE_SERVER_PASSWORD));
});
//
// find all systems with remote flag and empty related remoteServer
SysSystemFilter systemFilter = new SysSystemFilter();
systemFilter.setRemote(Boolean.TRUE);
systemService.find(systemFilter, null).stream().filter(// remote server is not referenced => old definition with remote flag
system -> Objects.isNull(system.getRemoteServer())).filter(system -> {
// remote server is properly filled
// cannot be filled from frontend, but just for sure
SysConnectorServerDto connectorServer = system.getConnectorServer();
if (connectorServer == null) {
return false;
}
return StringUtils.isNotBlank(connectorServer.getHost());
}).forEach(system -> {
SysConnectorServerDto systemConnector = system.getConnectorServer();
try {
systemConnector.setPassword(confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
} catch (SerializationException ex) {
LOG.error("Password for configured system [{}] is broken, will be ignored.", system.getCode());
}
// try to find remote system by all fields
SysConnectorServerDto remoteServer = remoteServers.stream().filter(r -> {
return StringUtils.equals(r.getHost(), systemConnector.getHost()) && Integer.compare(r.getPort(), systemConnector.getPort()) == 0 && BooleanUtils.compare(r.isUseSsl(), systemConnector.isUseSsl()) == 0 && Integer.compare(r.getTimeout(), systemConnector.getTimeout()) == 0 && (// password is broken, e.g. when confidential storage was dropped
systemConnector.getPassword() == null || StringUtils.equals(r.getPassword().asString(), systemConnector.getPassword().asString()));
}).findFirst().orElse(null);
//
if (remoteServer != null) {
LOG.info("Remote server [{}] will be used for configured system [{}].", remoteServer.getFullServerName(), system.getCode());
system.setRemoteServer(remoteServer.getId());
systemService.save(system);
} else {
String systemCode = system.getCode();
systemConnector.setDescription(String.format("Created automatically by upgrade to CzechIdM version 10.8.0 by target system [%s].", systemCode));
GuardedString password = systemConnector.getPassword();
remoteServer = remoteServerService.save(systemConnector);
// preserve password
remoteServer.setPassword(password);
remoteServers.add(remoteServer);
system.setRemoteServer(remoteServer.getId());
systemService.save(system);
LOG.info("New remote server [{}] was created and used for configured system [{}].", remoteServer.getFullServerName(), systemCode);
}
});
//
// Turn off for next start => already processed
getConfigurationService().setBooleanValue(getConfigurationPropertyName(ConfigurationService.PROPERTY_ENABLED), false);
//
return new DefaultEventResult<>(event, this);
}
Aggregations