From 0f19af7f3576a6808326c35e32d0edfe0ea6ea54 Mon Sep 17 00:00:00 2001 From: Matteo Maiero Date: Mon, 24 Jun 2024 09:48:07 +0200 Subject: [PATCH] fix: fixed null in wi-fi frontend and missing wi-fi update on IPv6 (#5291) Signed-off-by: MMaiero (cherry picked from commit 75581bffdce615b6fd94ad515bc13071536f6a71) --- .../web/client/ui/network/TabWirelessUi.java | 15 +++++++------- ...ConfigurationServicePropertiesBuilder.java | 20 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) 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 a55451e4dd2..c5229ed12fc 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 @@ -1322,16 +1322,16 @@ private void setPasswordValidation() { configUserOptions.allowAnyPassword(); } - if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA_MESSAGE) + if (this.security != null && (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA_MESSAGE) || this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA2_MESSAGE) - || this.security.getSelectedItemText().contentEquals(WIFI_SECURITY_WPA_WPA2_MESSAGE)) { + || this.security.getSelectedItemText().contentEquals(WIFI_SECURITY_WPA_WPA2_MESSAGE))) { this.password.setValidatorsFrom(configUserOptions); configUserOptions.setPasswordMinimumLength(Math.min(configUserOptions.getPasswordMinimumLength(), 63)); this.password.addValidator(GwtValidators.regex(REGEX_PASS_WPA, MSGS.netWifiWirelessInvalidWPAPassword())); - } else if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WEP_MESSAGE)) { + } else if (this.security != null && this.security.getSelectedItemText().equals(WIFI_SECURITY_WEP_MESSAGE)) { configUserOptions.setPasswordRequireSpecialChars(false); configUserOptions.setPasswordMinimumLength(Math.min(configUserOptions.getPasswordMinimumLength(), 26)); @@ -1741,14 +1741,14 @@ private void setForm(boolean visible) { private boolean checkPassword() { boolean result = true; - if (!this.password.validate() && this.password.isEnabled()) { + if (this.password != null && !this.password.validate() && this.password.isEnabled()) { this.groupPassword.setValidationState(ValidationState.ERROR); result = false; } else { this.groupPassword.setValidationState(ValidationState.NONE); } - if (this.verify.isEnabled() && TabWirelessUi.this.password != null + if (this.verify != null && this.verify.isEnabled() && TabWirelessUi.this.password != null && !TabWirelessUi.this.verify.getText().equals(TabWirelessUi.this.password.getText())) { TabWirelessUi.this.helpVerify.setText(MSGS.netWifiWirelessPasswordDoesNotMatch()); TabWirelessUi.this.groupVerify.setValidationState(ValidationState.ERROR); @@ -1820,7 +1820,8 @@ private void updateChannelListValues(List freqChannels) addAutomaticChannel(freqChannels); freqChannels.stream().forEach(this::addItemChannelList); - if (this.activeConfig.getChannels() != null && !this.activeConfig.getChannels().isEmpty()) { + if (this.activeConfig != null && this.activeConfig.getChannels() != null + && !this.activeConfig.getChannels().isEmpty()) { this.netTabs.hardwareTab.channel .setText(this.channelList.getItemText(this.activeConfig.getChannels().get(0))); @@ -1880,7 +1881,7 @@ public void onSuccess(Boolean acSupported) { if (selectedRadioMode != null) { setRadioModeByValue(selectedRadioMode); - } else { + } else if (TabWirelessUi.this.activeConfig != null) { setRadioModeByValue(TabWirelessUi.this.activeConfig.getRadioMode()); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServicePropertiesBuilder.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServicePropertiesBuilder.java index a8a9e369dd4..6dcc5e8ca36 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServicePropertiesBuilder.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServicePropertiesBuilder.java @@ -64,15 +64,10 @@ public Map build() throws GwtKuraException { setIpv4DhcpServerProperties(); set8021xConfig(); - switch (this.gwtConfig.getStatusEnum()) { - case netIPv4StatusDisabled: - break; - case netIPv4StatusUnmanaged: - break; - default: + if (isIPv4StatusEnabledManaged(this.gwtConfig.getStatus()) + || isIPv6StatusEnabledManaged(this.gwtConfig.getIpv6Status())) { setWifiProperties(); setModemProperties(); - break; } // Manage GPS independently of device ip status @@ -83,6 +78,15 @@ public Map build() throws GwtKuraException { return this.properties.getProperties(); } + private boolean isIPv4StatusEnabledManaged(String ipv4Status) { + return !(ipv4Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name()) + || ipv4Status.equals(GwtNetIfStatus.netIPv4StatusUnmanaged.name())); + } + + private boolean isIPv6StatusEnabledManaged(String ipv6Status) { + return !ipv6Status.equals(GwtNetIfStatus.netIPv6StatusDisabled.name()); + } + private void setCommonProperties() { this.properties.setType(this.ifname, this.gwtConfig.getHwType()); @@ -427,7 +431,7 @@ private void setAdvancedProperties() { this.properties.setIp6Mtu(this.ifname, Objects.nonNull(this.gwtConfig.getIpv6Mtu()) ? this.gwtConfig.getIpv6Mtu() : DEFAULT_MTU); this.properties.setPromisc(this.ifname, - Objects.nonNull(this.gwtConfig.getPromisc()) ? this.gwtConfig.getPromisc() : DEFAULT_PROMISC); + Objects.nonNull(this.gwtConfig.getPromisc()) ? this.gwtConfig.getPromisc() : DEFAULT_PROMISC); } private static GwtNetInterfaceConfig getConfigsAndStatuses(String ifName) throws GwtKuraException, KuraException {