From 11fb63b2298c8da8d8ef1b4ce121ebff81b6e941 Mon Sep 17 00:00:00 2001 From: pierantoniomerlino Date: Mon, 25 Nov 2024 12:57:48 +0100 Subject: [PATCH 1/4] Hide WPA3 feature based on property Signed-off-by: pierantoniomerlino --- .../org.eclipse.kura.api/META-INF/MANIFEST.MF | 2 +- .../eclipse/kura/system/SystemService.java | 14 +++ .../META-INF/MANIFEST.MF | 2 +- .../kura/core/system/SystemServiceImpl.java | 10 ++ kura/org.eclipse.kura.nm/META-INF/MANIFEST.MF | 1 + .../OSGI-INF/networkConfigurationService.xml | 1 + .../org/eclipse/kura/nm/NMDbusConnector.java | 42 +++++++ .../NMConfigurationServiceImpl.java | 7 ++ .../web/client/ui/network/TabWirelessUi.java | 98 +++++++++++++--- .../kura/web/server/GwtDeviceServiceImpl.java | 31 +++-- .../kura/web/server/GwtLogServiceImpl.java | 2 - .../web/client/messages/Messages.properties | 3 +- .../client/messages/Messages_ja.properties | 3 +- .../core/system/test/SystemServiceTest.java | 6 + .../eclipse/kura/nm/NMDbusConnectorTest.java | 110 ++++++++++++++++++ 15 files changed, 297 insertions(+), 35 deletions(-) diff --git a/kura/org.eclipse.kura.api/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.api/META-INF/MANIFEST.MF index 1e7eaa3bb13..383187ce0e7 100644 --- a/kura/org.eclipse.kura.api/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.api/META-INF/MANIFEST.MF @@ -76,7 +76,7 @@ Export-Package: org.eclipse.kura;version="1.7.0", org.eclipse.kura.security.tamper.detection;version="1.0.0", org.eclipse.kura.ssl;version="2.1.0", org.eclipse.kura.status;version="1.0.2", - org.eclipse.kura.system;version="1.8.0", + org.eclipse.kura.system;version="1.9.0", org.eclipse.kura.type;version="1.1.0", org.eclipse.kura.usb;version="1.3.0", org.eclipse.kura.watchdog;version="1.0.2", diff --git a/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/system/SystemService.java b/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/system/SystemService.java index 21d71584a9a..f6dbc46c8a5 100644 --- a/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/system/SystemService.java +++ b/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/system/SystemService.java @@ -136,6 +136,11 @@ public interface SystemService { */ public static final String KEY_DEFAULT_LOG_MANAGER = "kura.default.log.manager"; + /** + * @since 3.0 + */ + public static final String KEY_WPA3_WIFI_SECURITY_ENABLE = "kura.wpa3.wifi.security.enable"; + /** * @deprecated */ @@ -619,4 +624,13 @@ public interface SystemService { */ public Optional getDefaultLogManager(); + /** + * Returns true if the WPA3 WiFi Security is enabled on this device. + * The default is false. + * + * @since 3.0 + * @return true if the WPA3 WiFi Security is enabled + */ + public boolean isWPA3WifiSecurityEnabled(); + } diff --git a/kura/org.eclipse.kura.core.system/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.core.system/META-INF/MANIFEST.MF index 3451af7b08b..8c98e049e29 100644 --- a/kura/org.eclipse.kura.core.system/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.core.system/META-INF/MANIFEST.MF @@ -12,7 +12,7 @@ Import-Package: org.eclipse.kura;version="[1.0,2.0)", org.eclipse.kura.executor;version="[1.0,2.0)", org.eclipse.kura.net;version="[2.0,3.0)", - org.eclipse.kura.system;version="[1.8,1.9)", + org.eclipse.kura.system;version="[1.9,2.0)", org.osgi.framework;version="1.5.0", org.osgi.service.component;version="1.2.0", org.slf4j;version="1.6.4" diff --git a/kura/org.eclipse.kura.core.system/src/main/java/org/eclipse/kura/core/system/SystemServiceImpl.java b/kura/org.eclipse.kura.core.system/src/main/java/org/eclipse/kura/core/system/SystemServiceImpl.java index d914c29d201..de3a404402b 100644 --- a/kura/org.eclipse.kura.core.system/src/main/java/org/eclipse/kura/core/system/SystemServiceImpl.java +++ b/kura/org.eclipse.kura.core.system/src/main/java/org/eclipse/kura/core/system/SystemServiceImpl.java @@ -1527,4 +1527,14 @@ public Optional getDefaultLogManager() { return getProperty(KEY_DEFAULT_LOG_MANAGER); } + @Override + public boolean isWPA3WifiSecurityEnabled() { + final Optional isWPA3enabled = getProperty(KEY_WPA3_WIFI_SECURITY_ENABLE); + if (isWPA3enabled.isPresent()) { + return Boolean.parseBoolean(isWPA3enabled.get()); + } + + return false; + } + } diff --git a/kura/org.eclipse.kura.nm/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.nm/META-INF/MANIFEST.MF index 097d3f29d1c..5349e340b50 100644 --- a/kura/org.eclipse.kura.nm/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.nm/META-INF/MANIFEST.MF @@ -45,6 +45,7 @@ Import-Package: javax.xml.bind;version="2.3.3", org.eclipse.kura.net.wifi;version="[2.4,3.0]", org.eclipse.kura.position;version="[1.4,2.0)", org.eclipse.kura.security.keystore;version="[1.0,2.0)", + org.eclipse.kura.system;version="[1.9,2.0)", org.eclipse.kura.usb;version="[1.0,2.0)", org.osgi.framework;version="1.5.0", org.osgi.service.component;version="1.2.0", diff --git a/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml b/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml index afe926ff280..01c339508d1 100644 --- a/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml +++ b/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml @@ -25,4 +25,5 @@ + diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java index bb779200353..b48ca400b74 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java @@ -31,6 +31,8 @@ import org.eclipse.kura.linux.net.util.IwCapabilityTool; import org.eclipse.kura.net.status.NetworkInterfaceStatus; import org.eclipse.kura.net.wifi.WifiChannel; +import org.eclipse.kura.net.wifi.WifiMode; +import org.eclipse.kura.net.wifi.WifiSecurity; import org.eclipse.kura.nm.configuration.NMSettingsConverter; import org.eclipse.kura.nm.enums.MMModemLocationSource; import org.eclipse.kura.nm.enums.NMDeviceState; @@ -44,6 +46,7 @@ import org.eclipse.kura.nm.status.NMStatusConverter; import org.eclipse.kura.nm.status.SimProperties; import org.eclipse.kura.nm.status.SupportedChannelsProperties; +import org.eclipse.kura.system.SystemService; import org.freedesktop.NetworkManager; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.connections.impl.DBusConnection; @@ -94,6 +97,7 @@ public class NMDbusConnector { private final NetworkManagerDbusWrapper networkManager; private final ModemManagerDbusWrapper modemManager; private final WpaSupplicantDbusWrapper wpaSupplicant; + private Optional optionalSystemService = Optional.empty(); private Map cachedConfiguration = null; @@ -125,6 +129,10 @@ public DBusConnection getDbusConnection() { return this.dbusConnection; } + public void setSystemService(SystemService systemService) { + this.optionalSystemService = Optional.of(systemService); + } + public boolean configurationEnforcementIsActive() { return Objects.nonNull(this.configurationEnforcementHandler) && Objects.nonNull(this.deviceAddedHandler) && this.configurationEnforcementHandlerIsArmed; @@ -459,6 +467,12 @@ private synchronized void manageConfiguredInterface(Optional device, Str return; } + if (NMDeviceType.NM_DEVICE_TYPE_WIFI.equals(deviceType) && !isWPA3WifiSecuritySupported() + && shouldConfigureWPA3WifiSecurity(deviceId, properties)) { + logger.warn("WPA3 is not supported. Cannot configure device \"{}\"", deviceId); + return; + } + logger.info("Settings iface \"{}\":{}", deviceId, deviceType); if (interfaceStatus == KuraInterfaceStatus.DISABLED) { @@ -481,6 +495,34 @@ private synchronized void manageConfiguredInterface(Optional device, Str } + private boolean isWPA3WifiSecuritySupported() { + boolean isWPA3Supported = false; + if (this.optionalSystemService.isPresent()) { + isWPA3Supported = this.optionalSystemService.get().isWPA3WifiSecurityEnabled(); + } + return isWPA3Supported; + } + + private boolean shouldConfigureWPA3WifiSecurity(String deviceId, NetworkProperties properties) { + Optional optionalWifiMode = properties.getOpt(String.class, "net.interface.%s.config.wifi.mode", + deviceId); + if (!optionalWifiMode.isPresent() || (!optionalWifiMode.get().equals(WifiMode.INFRA.toString()) + && !optionalWifiMode.get().equals(WifiMode.MASTER.toString()))) { + return false; + } + + String wifiMode = optionalWifiMode.get().toLowerCase(); + Optional optionalWifiSecurity = properties.getOpt(String.class, + "net.interface.%s.config.wifi.%s.securityType", deviceId, wifiMode); + + if (optionalWifiSecurity.isPresent()) { + return optionalWifiSecurity.get().equals(WifiSecurity.SECURITY_WPA3.toString()) + || optionalWifiSecurity.get().equals(WifiSecurity.SECURITY_WPA2_WPA3.toString()); + } + + return false; + } + private void enableInterface(String deviceId, NetworkProperties properties, Optional device, NMDeviceType deviceType) throws DBusException { if (device.isPresent()) { diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java index a19561ade62..13ccd671b80 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMConfigurationServiceImpl.java @@ -52,6 +52,7 @@ import org.eclipse.kura.nm.configuration.writer.DhcpServerConfigWriter; import org.eclipse.kura.nm.configuration.writer.FirewallNatConfigWriter; import org.eclipse.kura.security.keystore.KeystoreService; +import org.eclipse.kura.system.SystemService; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.osgi.service.component.ComponentContext; @@ -79,6 +80,7 @@ public class NMConfigurationServiceImpl implements SelfConfiguringComponent { private EventAdmin eventAdmin; private CommandExecutorService commandExecutorService; private CryptoService cryptoService; + private SystemService systemService; private Map keystoreServices = new HashMap<>(); @@ -149,6 +151,10 @@ public void setDnsServerService(DnsServerService dnsServer) { this.dnsServer = dnsServer; } + public void setSystemService(SystemService systemService) { + this.systemService = systemService; + } + public NMConfigurationServiceImpl() { try { this.nmDbusConnector = NMDbusConnector.getInstance(); @@ -176,6 +182,7 @@ public void activate(ComponentContext componentContext, Map prop if (Objects.nonNull(this.nmDbusConnector)) { try { this.nmDbusConnector.checkPermissions(); + this.nmDbusConnector.setSystemService(this.systemService); } catch (DBusExecutionException e) { logger.error("Cannot check NetworkManager permissions due to: ", e); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java index f49f9a76a25..e1479ba258b 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java @@ -16,8 +16,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.logging.Logger; +import org.eclipse.kura.system.SystemService; import org.eclipse.kura.web.client.messages.Messages; import org.eclipse.kura.web.client.ui.EntryClassUi; import org.eclipse.kura.web.client.ui.NewPasswordInput; @@ -27,6 +29,7 @@ import org.eclipse.kura.web.client.util.MessageUtils; import org.eclipse.kura.web.shared.GwtSafeHtmlUtils; import org.eclipse.kura.web.shared.model.GwtConsoleUserOptions; +import org.eclipse.kura.web.shared.model.GwtGroupedNVPair; import org.eclipse.kura.web.shared.model.GwtNetIfStatus; import org.eclipse.kura.web.shared.model.GwtNetInterfaceConfig; import org.eclipse.kura.web.shared.model.GwtSession; @@ -41,6 +44,8 @@ import org.eclipse.kura.web.shared.model.GwtWifiSecurity; import org.eclipse.kura.web.shared.model.GwtWifiWirelessMode; import org.eclipse.kura.web.shared.model.GwtXSRFToken; +import org.eclipse.kura.web.shared.service.GwtDeviceService; +import org.eclipse.kura.web.shared.service.GwtDeviceServiceAsync; import org.eclipse.kura.web.shared.service.GwtNetworkService; import org.eclipse.kura.web.shared.service.GwtNetworkServiceAsync; import org.eclipse.kura.web.shared.service.GwtSecurityTokenService; @@ -140,6 +145,7 @@ interface TabWirelessUiUiBinder extends UiBinder { private final GwtSecurityTokenServiceAsync gwtXSRFService = GWT.create(GwtSecurityTokenService.class); private final GwtNetworkServiceAsync gwtNetworkService = GWT.create(GwtNetworkService.class); + private final GwtDeviceServiceAsync gwtDeviceService = GWT.create(GwtDeviceService.class); private static final String REGEX_PASS_WPA = "^[ -~]{8,63}$"; private static final String REGEX_PASS_WEP = "^(?:[\\x00-\\x7F]{5}|[\\x00-\\x7F]{13}|[a-fA-F0-9]{10}|[a-fA-F0-9]{26})$"; @@ -152,6 +158,7 @@ interface TabWirelessUiUiBinder extends UiBinder { private final NetworkTabsUi netTabs; private final ListDataProvider ssidDataProvider = new ListDataProvider<>(); private final SingleSelectionModel ssidSelectionModel = new SingleSelectionModel<>(); + // private boolean isWPA3WifiSecuritySupported; AnchorListItem wireless8021xTabAnchorItem; @@ -372,6 +379,8 @@ public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp4, TabIp6Ui tcp6, evalActiveConfig(); }); + configureWifiSecurityListBox(); + logger.info("Constructor done."); } @@ -914,23 +923,7 @@ private void initForm() { }); // Wireless Security - this.labelSecurity.setText(MSGS.netWifiWirelessSecurity()); - this.security.addMouseOverHandler(event -> { - if (TabWirelessUi.this.security.isEnabled()) { - TabWirelessUi.this.helpText.clear(); - TabWirelessUi.this.helpText.add(new Span(MSGS.netWifiToolTipSecurity())); - } - }); - this.security.addMouseOutHandler(event -> resetHelp()); - for (GwtWifiSecurity mode : GwtWifiSecurity.values()) { - this.security.addItem(MessageUtils.get(mode.name())); - } - this.security.addChangeHandler(event -> { - setDirty(true); - setPasswordValidation(); - refreshForm(); - checkPassword(); - }); + initWifiSecurityListBox(false); // Password this.labelPassword.setText(MSGS.netWifiWirelessPassword()); @@ -1201,6 +1194,7 @@ private void remove8021xFromSecurityDropdown() { for (int i = 0; i < this.security.getItemCount(); i++) { if (this.security.getItemText(i).equals(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE)) { this.security.removeItem(i); + return; } } } @@ -1866,4 +1860,74 @@ private void fillRadioMode(boolean acSupported) { this.radio.addItem(WIFI_BAND_BOTH_MESSAGE, WIFI_RADIO_BGN); } + private void configureWifiSecurityListBox() { + + this.gwtXSRFService.generateSecurityToken(new AsyncCallback() { + + @Override + public void onFailure(Throwable ex) { + FailureHandler.handle(ex); + } + + @Override + public void onSuccess(GwtXSRFToken token) { + TabWirelessUi.this.gwtDeviceService.findSystemProperties(token, + new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + logger.info("Unable to read WPA3 WiFi Security support property."); + } + + @Override + public void onSuccess(List result) { + Optional wpa3SupportPair = result.stream().filter( + pair -> pair.getName().equals(SystemService.KEY_WPA3_WIFI_SECURITY_ENABLE)) + .findFirst(); + if (wpa3SupportPair.isPresent() + && Boolean.parseBoolean(wpa3SupportPair.get().getValue())) { + initWifiSecurityListBox(true); + } + } + }); + } + }); + } + + private void initWifiSecurityListBox(boolean isWPA3WifiSecuritySupported) { + this.labelSecurity.setText(MSGS.netWifiWirelessSecurity()); + this.security.addMouseOverHandler(event -> { + if (TabWirelessUi.this.security.isEnabled()) { + TabWirelessUi.this.helpText.clear(); + TabWirelessUi.this.helpText.add(new Span(composeNetWifiToolTipSecurity(isWPA3WifiSecuritySupported))); + } + }); + this.security.addMouseOutHandler(event -> resetHelp()); + this.security.clear(); + for (GwtWifiSecurity mode : GwtWifiSecurity.values()) { + if (mode.equals(GwtWifiSecurity.netWifiSecurityWPA3) + || mode.equals(GwtWifiSecurity.netWifiSecurityWPA2_WPA3)) { + if (isWPA3WifiSecuritySupported) { + this.security.addItem(MessageUtils.get(mode.name())); + } + } else { + this.security.addItem(MessageUtils.get(mode.name())); + } + } + this.security.addChangeHandler(event -> { + setDirty(true); + setPasswordValidation(); + refreshForm(); + checkPassword(); + }); + } + + private String composeNetWifiToolTipSecurity(boolean isWPA3WifiSecuritySupported) { + String toolTipMessage = MSGS.netWifiToolTipSecurity(); + if (isWPA3WifiSecuritySupported) { + toolTipMessage += "

" + MSGS.netWifiToolTipSecurityWPA3(); + } + return toolTipMessage; + } + } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtDeviceServiceImpl.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtDeviceServiceImpl.java index e2e61d4f8e6..fb8e2ab86e7 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtDeviceServiceImpl.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtDeviceServiceImpl.java @@ -195,9 +195,9 @@ public ArrayList findSystemProperties(GwtXSRFToken xsrfToken) // kura properties SystemService systemService = ServiceLocator.getInstance().getService(SystemService.class); Properties kuraProps = systemService.getProperties(); - SortedSet kuraKeys = new TreeSet(kuraProps.keySet()); + SortedSet kuraKeys = new TreeSet(kuraProps.stringPropertyNames()); for (Object key : kuraKeys) { - pairs.add(new GwtGroupedNVPair("propsKura", key.toString(), kuraProps.get(key).toString())); + pairs.add(new GwtGroupedNVPair("propsKura", key.toString(), kuraProps.getProperty(key.toString()))); } return new ArrayList<>(pairs); } @@ -233,17 +233,19 @@ public ArrayList findBundles(GwtXSRFToken xsrfToken) throws Gw public boolean checkIfContainerOrchestratorIsActive(GwtXSRFToken xsrfToken) throws GwtKuraException { checkXSRFToken(xsrfToken); - ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); + ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); return checkIfContainerOrchestratorIsActive != null; } - + @Override public List findImages(GwtXSRFToken xsrfToken) throws GwtKuraException { checkXSRFToken(xsrfToken); List pairs = new ArrayList<>(); try { - ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); + ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); List images = checkIfContainerOrchestratorIsActive.listImageInstanceDescriptors(); if (images != null) { for (ImageInstanceDescriptor image : images) { @@ -253,7 +255,7 @@ public List findImages(GwtXSRFToken xsrfToken) throws GwtKuraE pair.setStatus("bndInstalled"); pair.setVersion(image.getImageTag()); pair.set("arch", image.getImageArch()); - + pairs.add(pair); } } @@ -264,12 +266,13 @@ public List findImages(GwtXSRFToken xsrfToken) throws GwtKuraE return new ArrayList<>(pairs); } - + @Override public void deleteImage(GwtXSRFToken xsrfToken, String imageId) throws GwtKuraException { checkXSRFToken(xsrfToken); - ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); + ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); List images = containerOrchestrationService.listImageInstanceDescriptors(); @@ -299,8 +302,10 @@ public List findContainers(GwtXSRFToken xsrfToken) throws GwtK checkXSRFToken(xsrfToken); List pairs = new ArrayList<>(); try { - ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); - List containers = checkIfContainerOrchestratorIsActive.listContainerDescriptors(); + ContainerOrchestrationService checkIfContainerOrchestratorIsActive = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); + List containers = checkIfContainerOrchestratorIsActive + .listContainerDescriptors(); if (containers != null) { for (ContainerInstanceDescriptor container : containers) { GwtGroupedNVPair pair = new GwtGroupedNVPair(); @@ -324,7 +329,8 @@ public List findContainers(GwtXSRFToken xsrfToken) throws GwtK public void startContainer(GwtXSRFToken xsrfToken, String containerName) throws GwtKuraException { checkXSRFToken(xsrfToken); - ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); + ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); List containers = containerOrchestrationService.listContainerDescriptors(); logger.info("Starting container with name: {}", containerName); @@ -351,7 +357,8 @@ public void startContainer(GwtXSRFToken xsrfToken, String containerName) throws public void stopContainer(GwtXSRFToken xsrfToken, String containerName) throws GwtKuraException { checkXSRFToken(xsrfToken); - ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance().getService(ContainerOrchestrationService.class); + ContainerOrchestrationService containerOrchestrationService = ServiceLocator.getInstance() + .getService(ContainerOrchestrationService.class); List containers = containerOrchestrationService.listContainerDescriptors(); diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtLogServiceImpl.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtLogServiceImpl.java index 70364ad4071..3d2bd2a8bad 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtLogServiceImpl.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/GwtLogServiceImpl.java @@ -41,8 +41,6 @@ public class GwtLogServiceImpl extends OsgiRemoteServiceServlet implements GwtLo private static final LogEntriesCache cache = new LogEntriesCache(); private static final List registeredLogProviders = new LinkedList<>(); - private static SystemService systemService; - @Override public List initLogProviders(GwtXSRFToken xsrfToken) throws GwtKuraException { checkXSRFToken(xsrfToken); diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties index 8c23d15c95b..a8a4bb16ca8 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties @@ -629,7 +629,8 @@ netWifiToolTipWirelessModeAdhoc=Configure the wireless interface in adhoc mode. netWifiToolTipNetworkName=In Access Point mode, enter the SSID that will identify this wireless network.

In Station mode, enter the SSID of the wireless network or click the button to select wireless network in range. The button may be disabled for some systems. netWifiToolTipRadioMode=In Access Point mode, select the appropriate speed rating for this device.

* 802.11a - 54 MBps, 50 feet or 450 MBps, using 5Ghz channels (up to 32)
* 802.11b - 11 Mbps, 150 feet
* 802.11g - 54 MBps, 50 feet
* 802.11n - 300 MBps, 175 feet
* 802.11ac - 1000 MBps, 50 feet

Note that real-world speeds are more modest. Likewise, range varies depending on device configuration and placement. netWifiToolTipBand=Select the frequency band to use for this wireless interface.

  • 2.4 GHz band provides the most coverage but transmits data at slower speeds.
  • 5 GHz band provides less coverage but transmits data at faster speeds.
Wireless range decreases with higher frequencies because higher frequencies cannot penetrate solid objects, such as walls and floors. However, higher frequencies allow data to be transmitted faster than lower frequencies. -netWifiToolTipSecurity=Select the appropriate security protocol for this wireless network.
WPA2 is the most secure encryption method available for wireless networks - we recommend using WPA2 with the CCMP cipher whenever possible. WPA2 with CCMP is the only option permitted for high throughput 802.11n transmissions.
If you need to accommodate legacy devices with an SSID, enable WPA encryption with the TKIP cipher.

The WPA3-SAE security protocol support is experimental. Please check whether the new standard is supported by the Wifi module device, driver and firmware. +netWifiToolTipSecurity=Select the appropriate security protocol for this wireless network.
WPA2 is the most secure encryption method available for wireless networks - we recommend using WPA2 with the CCMP cipher whenever possible. WPA2 with CCMP is the only option permitted for high throughput 802.11n transmissions.
If you need to accommodate legacy devices with an SSID, enable WPA encryption with the TKIP cipher. +netWifiToolTipSecurityWPA3=The WPA3-SAE security protocol is experimental. Please check if the device, driver and firmware are compliant with the new standard. netWifiToolTipPassword=Enter password for wireless network.

* In Access Point mode, provide password verification in the field below.

* In Station mode, press the button below to verify password. netWifiToolTipVerifyPassword=In Access Point mode, retype wireless password to verify it. If entries don''t match, the field will be marked invalid with the Passwords do not match error message. netWifiToolTipChannels=Select the desired channel frequencies over which the device should communicate. diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties index 900f3519d9c..98527c1b1b9 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties @@ -606,7 +606,8 @@ netWifiToolTipWirelessModeAdhoc=ワイヤレスインターフェースをアド netWifiToolTipNetworkName= アクセスポイント モードでは、このワイヤレスネットワークを識別するSSIDを入力してください。

ステーションモードでは、ワイヤレスネットワークのSSIDを入力するか、ボタンを押して範囲内にあるワイヤレスネットワークを選択してください。ボタンが無効になるシステムが存在する場合もあります。 netWifiToolTipRadioMode= アクセスポイント モードでは、このデバイスに適するスピードレートを選択してください。

* 802.11a - 54 MBps、50 feetあるいは450 MBps、5Ghzチャネルを使用(32まで)
* 802.11b - 11 Mbps、150 feet
* 802.11g - 54 MBps、50 feet
* 802.11n - 300 MBps、175 feet
* 802.11ac - 1000 MBps、50 feet

実際の速度は標記より遅くなること、範囲もデバイスの環境設定や設置場所によって変化することにご注意ください。 netWifiToolTipBand=このワイヤレス インターフェイスに使用する周波数帯域を選択します。
  • 2.4 GHz 帯域は最大のカバレッジを提供しますが、データの送信速度は遅くなります。
  • 5 GHz 帯域はカバレッジが狭くなりますが、より高速にデータを送信できます。
高い周波数は壁や床などの固体物を透過できないため、ワイヤレス範囲は周波数が高くなるほど減少します。 ただし、周波数が高いと、周波数が低い場合よりもデータを高速に送信できます。 -netWifiToolTipSecurity=このワイヤレスネットワークに適切なセキュリティプロトコルを選択してください。
WPA2は、ワイヤレスネットワークに使用可能なものの中で最も安全性の高い暗号化方式です。可能な限り、CCMP暗号を用いたWPA2の使用を推奨します。CCMPを用いたWPA2は、802.11n高処理転送に許諾されている唯一のオプションです。
SSIDを使用した最新でないデバイスを適応させることが必要な場合は、TKIP暗号を用いたWPA暗号化を使用可能にしてください。

WPA3-SAE セキュリティ プロトコルは実験的なものです。デバイス、ドライバー、ファームウェアが新しい規格に準拠しているかどうかを確認してください。 +netWifiToolTipSecurity=このワイヤレスネットワークに適切なセキュリティプロトコルを選択してください。
WPA2は、ワイヤレスネットワークに使用可能なものの中で最も安全性の高い暗号化方式です。可能な限り、CCMP暗号を用いたWPA2の使用を推奨します。CCMPを用いたWPA2は、802.11n高処理転送に許諾されている唯一のオプションです。
SSIDを使用した最新でないデバイスを適応させることが必要な場合は、TKIP暗号を用いたWPA暗号化を使用可能にしてください。 +netWifiToolTipSecurityWPA3=WPA3-SAE セキュリティ プロトコルは実験的なものです。デバイス、ドライバー、ファームウェアが新しい規格に準拠しているかどうかを確認してください。 netWifiToolTipPassword=ワイヤレスネットワークのパスワードを入力してください。

* アクセスポイントモードでは、下のフィールドでパスワード認証を行ってください。

*ステーションモードでは、下のボタンを押してパスワード認証を行ってください。 netWifiToolTipVerifyPassword=アクセスポイントモードでは、認証のためにワイヤレスパスワードを再度入力してください。エントリが正しくない場合、パスワードが正しくありませんというエラーメッセージと共にフィールドが無効であると表示されます。 netWifiToolTipChannels=デバイスが通信したいチャネル周波数を選択してください。 diff --git a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java index 9076abf248f..6f205d09a57 100644 --- a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java +++ b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java @@ -375,4 +375,10 @@ public void shouldGetDefaultLogManagerProperty() { assertFalse(systemService.getDefaultLogManager().isPresent()); } + @TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL }) + @Test + public void shouldGetDefaultWPA3WifiSecuritySupportProperty() { + assertFalse(systemService.isWPA3WifiSecurityEnabled()); + } + } diff --git a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NMDbusConnectorTest.java b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NMDbusConnectorTest.java index 78721c82a58..4c6c5d31c3e 100644 --- a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NMDbusConnectorTest.java +++ b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NMDbusConnectorTest.java @@ -47,6 +47,7 @@ import java.util.concurrent.TimeoutException; import org.eclipse.kura.KuraException; +import org.eclipse.kura.configuration.Password; import org.eclipse.kura.executor.Command; import org.eclipse.kura.executor.CommandExecutorService; import org.eclipse.kura.executor.CommandStatus; @@ -74,6 +75,7 @@ import org.eclipse.kura.nm.enums.NMDeviceType; import org.eclipse.kura.nm.signal.handlers.DeviceCreationLock; import org.eclipse.kura.nm.signal.handlers.NMConfigurationEnforcementHandler; +import org.eclipse.kura.system.SystemService; import org.freedesktop.ModemManager1; import org.freedesktop.NetworkManager; import org.freedesktop.dbus.DBusPath; @@ -1057,6 +1059,74 @@ public void shouldTriggerWirelessNetworkScan() throws DBusException, IOException thenScanIsTriggered("wlan0"); } + @Test + public void shouldApplyWPA3WiFiConfigurationIfWPA3IsSupported() throws DBusException, IOException { + givenBasicMockedDbusConnector(); + givenSystemService(true); + givenMockedDevice("wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI, NMDeviceState.NM_DEVICE_STATE_ACTIVATED, + true, false, false); + givenMockedDeviceList(); + + givenWifiInterfaceConfiguration("SECURITY_WPA3"); + + whenApplyIsCalledWith(this.netConfig); + + thenNoExceptionIsThrown(); + thenConnectionUpdateIsCalledFor("wlan0"); + thenActivateConnectionIsCalledFor("wlan0"); + } + + @Test + public void shouldNotApplyWPA3WiFiConfigurationIfWPA3IsNotSupported() throws DBusException, IOException { + givenBasicMockedDbusConnector(); + givenSystemService(false); + givenMockedDevice("wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI, NMDeviceState.NM_DEVICE_STATE_ACTIVATED, + true, false, false); + givenMockedDeviceList(); + + givenWifiInterfaceConfiguration("SECURITY_WPA3"); + + whenApplyIsCalledWith(this.netConfig); + + thenNoExceptionIsThrown(); + thenConnectionUpdateIsNotCalledFor("wlan0"); + thenActivateConnectionIsNotCalledFor("wlan0"); + } + + @Test + public void shouldApplyWPA2WPA3WiFiConfigurationIfWPA3IsSupported() throws DBusException, IOException { + givenBasicMockedDbusConnector(); + givenSystemService(true); + givenMockedDevice("wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI, NMDeviceState.NM_DEVICE_STATE_ACTIVATED, + true, false, false); + givenMockedDeviceList(); + + givenWifiInterfaceConfiguration("SECURITY_WPA2_WPA3"); + + whenApplyIsCalledWith(this.netConfig); + + thenNoExceptionIsThrown(); + thenConnectionUpdateIsCalledFor("wlan0"); + thenActivateConnectionIsCalledFor("wlan0"); + } + + @Test + public void shouldNotApplyWPA2WPA3WiFiConfigurationIfWPA3IsNotSupported() throws DBusException, IOException { + givenBasicMockedDbusConnector(); + givenSystemService(false); + givenMockedDevice("wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI, NMDeviceState.NM_DEVICE_STATE_ACTIVATED, + true, false, false); + givenMockedDeviceList(); + + givenWifiInterfaceConfiguration("SECURITY_WPA2_WPA3"); + + whenApplyIsCalledWith(this.netConfig); + + thenNoExceptionIsThrown(); + thenConnectionUpdateIsNotCalledFor("wlan0"); + thenActivateConnectionIsNotCalledFor("wlan0"); + } + /* * Given */ @@ -1455,6 +1525,36 @@ private void givenApplyWasCalledOnceWith(Map networkConfig) thro clearInvocations(this.mockConnection); } + private void givenSystemService(boolean isWPASupported) { + SystemService mockSystemService = mock(SystemService.class); + when(mockSystemService.isWPA3WifiSecurityEnabled()).thenReturn(isWPASupported); + + this.instanceNMDbusConnector.setSystemService(mockSystemService); + } + + private void givenWifiInterfaceConfiguration(String wifiSecurity) { + givenNetworkConfigMapWith("net.interfaces", "wlan0"); + givenNetworkConfigMapWith("net.interface.wlan0.config.ip4.status", "netIPv4StatusEnabledLAN"); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.mode", "MASTER"); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpClient4.enabled", false); + givenNetworkConfigMapWith("net.interface.wlan0.config.ip4.address", "192.168.0.12"); + givenNetworkConfigMapWith("net.interface.wlan0.config.ip4.prefix", (short) 25); + givenNetworkConfigMapWith("net.interface.wlan0.config.ip4.dnsServers", "1.1.1.1"); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.enabled", true); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.mode", "MASTER"); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.ssid", "whatACoolSSID!"); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.securityType", wifiSecurity); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.prefix", 25); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.rangeStart", "192.168.0.20"); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.rangeEnd", "192.168.0.24"); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.passDns", true); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.defaultLeaseTime", 900); + givenNetworkConfigMapWith("net.interface.wlan0.config.dhcpServer4.maxLeaseTime", 900); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.channel", "1"); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.radioMode", "RADIO_MODE_80211b"); + givenNetworkConfigMapWith("net.interface.wlan0.config.wifi.master.passphrase", new Password("EEEEEHHHHH")); + } + /* * When */ @@ -1613,10 +1713,20 @@ private void thenConnectionUpdateIsCalledFor(String netInterface) throws DBusExc verify(connect).Update(any()); } + private void thenConnectionUpdateIsNotCalledFor(String netInterface) throws DBusException { + Connection connect = this.dbusConnection.getRemoteObject("org.freedesktop.NetworkManager", + "/mock/device/" + netInterface, Connection.class); + verify(connect, never()).Update(any()); + } + private void thenActivateConnectionIsCalledFor(String netInterface) throws DBusException { verify(this.mockedNetworkManager).ActivateConnection(any(), any(), any()); } + private void thenActivateConnectionIsNotCalledFor(String netInterface) throws DBusException { + verify(this.mockedNetworkManager, never()).ActivateConnection(any(), any(), any()); + } + private void thenAddAndActivateConnectionIsCalledFor(String netInterface) throws DBusException { verify(this.mockedNetworkManagerSettings).AddConnection(any()); verify(this.mockedNetworkManager).ActivateConnection(any(), any(), any()); From af628810bb7faab3e6722310f2b5b21f8b157087 Mon Sep 17 00:00:00 2001 From: pierantoniomerlino Date: Fri, 6 Dec 2024 12:38:03 +0100 Subject: [PATCH 2/4] Updated copyright Signed-off-by: pierantoniomerlino --- .../org/eclipse/kura/core/system/test/SystemServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java index 6f205d09a57..1f83f99bed3 100644 --- a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java +++ b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2011, 2024 Eurotech and/or its affiliates and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 From 8bdcede167fe5212afea0b2805e769be67e66487 Mon Sep 17 00:00:00 2001 From: pierantoniomerlino Date: Wed, 11 Dec 2024 16:25:33 +0100 Subject: [PATCH 3/4] Removed commented line; updated copyright headers Signed-off-by: pierantoniomerlino --- .../OSGI-INF/networkConfigurationService.xml | 2 +- .../org/eclipse/kura/web/client/ui/network/TabWirelessUi.java | 1 - .../java/org/eclipse/kura/web/server/GwtDeviceServiceImpl.java | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml b/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml index 01c339508d1..7476ec848e6 100644 --- a/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml +++ b/kura/org.eclipse.kura.nm/OSGI-INF/networkConfigurationService.xml @@ -1,7 +1,7 @@