diff --git a/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF index 929b84389ac..9259019a32a 100644 --- a/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.web2/META-INF/MANIFEST.MF @@ -70,7 +70,7 @@ Import-Package: com.eclipsesource.json;version="0.9.5", org.eclipse.kura.net.status.modem;version="[1.0,2.0)", org.eclipse.kura.net.status.wifi;version="[1.0,2.0)", org.eclipse.kura.net.status.vlan;version="[1.0,2.0)", - org.eclipse.kura.net.wifi;version="[2.2,3.0)", + org.eclipse.kura.net.wifi;version="[2.4,2.5)", org.eclipse.kura.net.vlan;version="[1.0,2.0)", org.eclipse.kura.position;version="[1.0,2.0)", org.eclipse.kura.rest.configuration.api;version="[1.0,2.0)", diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/NetworkTabsUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/NetworkTabsUi.java index b3c7619cd28..279e803a9dc 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/NetworkTabsUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/NetworkTabsUi.java @@ -62,6 +62,7 @@ interface NetworkTabsUiUiBinder extends UiBinder { AnchorListItem ip6TabAnchorItem; AnchorListItem dhcp4NatTabAnchorItem; AnchorListItem wirelessTabAnchorItem; + AnchorListItem net8021xTabAnchorItem; AnchorListItem modemTabAnchorItem; AnchorListItem modemGpsTabAnchorItem; AnchorListItem modemAntennaTabAnchorItem; @@ -74,6 +75,7 @@ interface NetworkTabsUiUiBinder extends UiBinder { TabIp6Ui ip6Tab; TabDhcp4NatUi dhcp4NatTab; TabWirelessUi wirelessTab; + Tab8021xUi set8021xTab; TabModemUi modemTab; TabModemGpsUi modemGpsTab; TabModemAntennaUi modemAntennaTab; @@ -122,6 +124,7 @@ private void initTabs() { initIp4Tab(); initIp6Tab(); + initWireless8021xTab(); initWirelessTab(); initModemTab(); initModemGpsTab(); @@ -161,7 +164,8 @@ private void initIp6Tab() { private void initWirelessTab() { this.wirelessTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless()); - this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this); + this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.set8021xTab, this.net8021xTabAnchorItem, + this); this.wirelessTabAnchorItem.addClickHandler(event -> { setSelected(NetworkTabsUi.this.wirelessTabAnchorItem); @@ -171,6 +175,18 @@ private void initWirelessTab() { }); } + private void initWireless8021xTab() { + this.net8021xTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless8021x()); + this.set8021xTab = new Tab8021xUi(this.session, this); + + this.net8021xTabAnchorItem.addClickHandler(event -> { + setSelected(NetworkTabsUi.this.net8021xTabAnchorItem); + NetworkTabsUi.this.selectedTab = NetworkTabsUi.this.set8021xTab; + NetworkTabsUi.this.content.clear(); + NetworkTabsUi.this.content.add(NetworkTabsUi.this.set8021xTab); + }); + } + private void initModemTab() { this.modemTabAnchorItem = new AnchorListItem(MSGS.netModemCellular()); this.modemTab = new TabModemUi(this.session, this.ip4Tab, this); @@ -250,6 +266,7 @@ public void setNetInterface(GwtNetInterfaceConfig selection) { this.ip6Tab.setNetInterface(selection); this.dhcp4NatTab.setNetInterface(selection); this.wirelessTab.setNetInterface(selection); + this.set8021xTab.setNetInterface(selection); this.modemTab.setNetInterface(selection); this.modemGpsTab.setNetInterface(selection); this.modemAntennaTab.setNetInterface(selection); @@ -263,6 +280,7 @@ public void updateTabs() { removeAllTabs(); insertTab(this.ip4TabAnchorItem); + if (this.isNet2) { insertTab(this.ip6TabAnchorItem); } @@ -276,6 +294,7 @@ private void removeAllTabs() { removeTab(this.ip4TabAnchorItem); removeTab(this.ip6TabAnchorItem); removeTab(this.wirelessTabAnchorItem); + removeTab(this.net8021xTabAnchorItem); removeTab(this.dhcp4NatTabAnchorItem); removeTab(this.modemTabAnchorItem); removeTab(this.modemGpsTabAnchorItem); @@ -328,6 +347,10 @@ private void showWirelessTabs() { this.wirelessTabAnchorItem.setEnabled(true); insertTab(this.wirelessTabAnchorItem); + if (this.isNet2) { + insertTab(this.net8021xTabAnchorItem); + } + insertTab(this.dhcp4NatTabAnchorItem); } @@ -363,6 +386,7 @@ private boolean isModemLTE() { private void removeOptionalTabs() { this.visibleTabs.remove(this.wirelessTabAnchorItem); + this.visibleTabs.remove(this.net8021xTabAnchorItem); this.visibleTabs.remove(this.dhcp4NatTabAnchorItem); this.visibleTabs.remove(this.modemTabAnchorItem); this.visibleTabs.remove(this.modemGpsTabAnchorItem); @@ -398,6 +422,9 @@ private void refreshAllVisibleTabs() { if (this.visibleTabs.contains(this.modemAntennaTabAnchorItem)) { this.modemAntennaTab.refresh(); } + if (this.visibleTabs.contains(this.net8021xTabAnchorItem)) { + this.set8021xTab.refresh(); + } } /* @@ -437,6 +464,10 @@ public boolean isDirty() { return true; } + if (this.visibleTabs.contains(this.net8021xTabAnchorItem) && this.set8021xTab.isDirty()) { + return true; + } + return false; } @@ -446,6 +477,7 @@ public void setDirty(boolean isDirty) { this.hardwareTab.setDirty(isDirty); this.dhcp4NatTab.setDirty(isDirty); this.wirelessTab.setDirty(isDirty); + this.set8021xTab.setDirty(isDirty); this.modemTab.setDirty(isDirty); this.modemGpsTab.setDirty(isDirty); this.modemAntennaTab.setDirty(isDirty); @@ -457,6 +489,7 @@ public void refresh() { this.hardwareTab.refresh(); this.dhcp4NatTab.refresh(); this.wirelessTab.refresh(); + this.set8021xTab.refresh(); this.modemTab.refresh(); this.modemGpsTab.refresh(); this.modemAntennaTab.refresh(); @@ -497,6 +530,9 @@ public GwtNetInterfaceConfig getUpdatedInterface() { if (this.visibleTabs.contains(this.modemAntennaTabAnchorItem)) { this.modemAntennaTab.getUpdatedNetInterface(updatedNetIf); } + if (this.visibleTabs.contains(this.net8021xTabAnchorItem)) { + this.set8021xTab.getUpdatedNetInterface(updatedNetIf); + } return updatedNetIf; } @@ -542,6 +578,11 @@ public boolean isValid() { return false; } + if (this.visibleTabs.contains(this.net8021xTabAnchorItem) && this.net8021xTabAnchorItem.isEnabled() + && !this.set8021xTab.isValid()) { + return false; + } + return true; } @@ -574,6 +615,7 @@ private void setSelected(AnchorListItem item) { this.ip6TabAnchorItem.setActive(false); this.dhcp4NatTabAnchorItem.setActive(false); this.wirelessTabAnchorItem.setActive(false); + this.net8021xTabAnchorItem.setActive(false); this.modemTabAnchorItem.setActive(false); this.modemGpsTabAnchorItem.setActive(false); this.modemAntennaTabAnchorItem.setActive(false); @@ -581,6 +623,7 @@ private void setSelected(AnchorListItem item) { } class InterfaceConfigWrapper { + private GwtNetInterfaceConfig config; public InterfaceConfigWrapper(GwtNetInterfaceConfig config) { @@ -604,8 +647,7 @@ public boolean isGpsSupported() { } public boolean isLoopback() { - return this.config.getHwTypeEnum() == GwtNetIfType.LOOPBACK - || this.config.getName().startsWith("mon.wlan"); + return this.config.getHwTypeEnum() == GwtNetIfType.LOOPBACK || this.config.getName().startsWith("mon.wlan"); } } } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.java new file mode 100644 index 00000000000..04889f6e0a6 --- /dev/null +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.java @@ -0,0 +1,405 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech + * Sterwen-Technology + *******************************************************************************/ +package org.eclipse.kura.web.client.ui.network; + +import java.util.logging.Logger; + +import org.eclipse.kura.web.client.messages.Messages; +import org.eclipse.kura.web.client.ui.NewPasswordInput; +import org.eclipse.kura.web.client.util.HelpButton; +import org.eclipse.kura.web.client.util.MessageUtils; +import org.eclipse.kura.web.shared.GwtSafeHtmlUtils; +import org.eclipse.kura.web.shared.model.Gwt8021xConfig; +import org.eclipse.kura.web.shared.model.Gwt8021xEap; +import org.eclipse.kura.web.shared.model.Gwt8021xInnerAuth; +import org.eclipse.kura.web.shared.model.GwtNetInterfaceConfig; +import org.eclipse.kura.web.shared.model.GwtSession; +import org.eclipse.kura.web.shared.model.GwtWifiChannelModel; +import org.eclipse.kura.web.shared.model.GwtWifiConfig; +import org.eclipse.kura.web.shared.model.GwtWifiNetInterfaceConfig; +import org.eclipse.kura.web.shared.service.GwtNetworkService; +import org.eclipse.kura.web.shared.service.GwtNetworkServiceAsync; +import org.eclipse.kura.web.shared.service.GwtSecurityTokenService; +import org.eclipse.kura.web.shared.service.GwtSecurityTokenServiceAsync; +import org.gwtbootstrap3.client.ui.Button; +import org.gwtbootstrap3.client.ui.Form; +import org.gwtbootstrap3.client.ui.FormLabel; +import org.gwtbootstrap3.client.ui.ListBox; +import org.gwtbootstrap3.client.ui.TextBox; +import org.gwtbootstrap3.client.ui.constants.ValidationState; +import org.gwtbootstrap3.client.ui.html.Span; +import org.gwtbootstrap3.client.ui.html.Text; +import org.gwtbootstrap3.client.ui.PanelHeader; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.user.client.ui.ScrollPanel; + +public class Tab8021xUi extends Composite implements NetworkTab { + + private static Tab8021xUiUiBinder uiBinder = GWT.create(Tab8021xUiUiBinder.class); + + private final GwtSecurityTokenServiceAsync gwtXSRFService = GWT.create(GwtSecurityTokenService.class); + private final GwtNetworkServiceAsync gwtNetworkService = GWT.create(GwtNetworkService.class); + + private static final Messages MSGS = GWT.create(Messages.class); + + private static final Logger logger = Logger.getLogger(Tab8021xUi.class.getSimpleName()); + + interface Tab8021xUiUiBinder extends UiBinder { + } + + private final GwtSession currentSession; + private final NetworkTabsUi netTabs; + + Gwt8021xConfig activeConfig; + + private boolean dirty; + + // Labels + @UiField + FormLabel labelEap; + + @UiField + FormLabel labelInnerAuth; + + @UiField + FormLabel labelUsername; + + @UiField + FormLabel labelPassword; + + @UiField + Form form; + + // Fields + @UiField + Button buttonTestPassword; + + @UiField + ListBox eap; + + @UiField + ListBox innerAuth; + + @UiField + TextBox username; + + @UiField + NewPasswordInput password; + + // Help + @UiField + HelpButton helpEap; + + @UiField + HelpButton helpInnerAuth; + + @UiField + HelpButton helpUsername; + + @UiField + HelpButton helpPassword; + + @UiField + PanelHeader helpTitle; + + @UiField + ScrollPanel helpText; + + public Tab8021xUi(GwtSession currentSession, NetworkTabsUi tabs) { + initWidget(uiBinder.createAndBindUi(this)); + + this.currentSession = currentSession; + this.netTabs = tabs; + + initLabels(); + initHelpButtons(); + initListBoxes(); + initTextBoxes(); + + this.buttonTestPassword.setVisible(false); + } + + private void initLabels() { + labelEap.setText(MSGS.net8021xEap()); + labelInnerAuth.setText(MSGS.net8021xInnerAuth()); + labelUsername.setText(MSGS.net8021xUsername()); + labelPassword.setText(MSGS.net8021xPassword()); + } + + private void initHelpButtons() { + this.helpEap.setHelpText(MSGS.net8021xEapHelp()); + this.helpInnerAuth.setHelpText(MSGS.net8021xInnerAuthHelp()); + this.helpUsername.setHelpText(MSGS.net8021xUsernameHelp()); + this.helpPassword.setHelpText(MSGS.net8021xPasswordHelp()); + } + + private void initListBoxes() { + initEapListBox(); + initInnerAuthListBox(); + } + + private void initTextBoxes() { + initUsernameTextBox(); + initPasswordTextBox(); + } + + private void initEapListBox() { + for (Gwt8021xEap eap : Gwt8021xEap.values()) { + this.eap.addItem(eap.name()); + } + + this.eap.addMouseOverHandler(event -> { + if (this.eap.isEnabled()) { + setHelpText(MSGS.net8021xEapHelp()); + } + }); + + this.eap.addMouseOutHandler(event -> resetHelpText()); + + this.eap.addChangeHandler(event -> { + setDirty(true); + this.netTabs.updateTabs(); + updateFormEap(Gwt8021xEap.valueOf(this.eap.getSelectedValue())); + }); + } + + private void initInnerAuthListBox() { + for (Gwt8021xInnerAuth auth : Gwt8021xInnerAuth.values()) { + this.innerAuth.addItem(auth.name()); + } + + this.innerAuth.addMouseOverHandler(event -> { + if (this.innerAuth.isEnabled()) { + setHelpText(MSGS.net8021xInnerAuthHelp()); + } + }); + + this.innerAuth.addMouseOutHandler(event -> resetHelpText()); + + this.innerAuth.addChangeHandler(event -> { + setDirty(true); + this.netTabs.updateTabs(); + }); + } + + private void initUsernameTextBox() { + this.username.addMouseOverHandler(event -> { + Tab8021xUi.this.logger.info("hover detected."); + }); + this.username.addBlurHandler(e -> this.username.validate()); + this.username.setAllowBlank(true); + this.username.addMouseOutHandler(event -> resetHelpText()); + + this.username.addChangeHandler(event -> { + setDirty(true); + }); + } + + private void initPasswordTextBox() { + this.password.addMouseOverHandler(event -> { + Tab8021xUi.this.logger.info("hover detected."); + }); + + this.password.addBlurHandler(e -> this.password.validate()); + this.password.setAllowBlank(false); + this.password.addMouseOutHandler(event -> resetHelpText()); + + this.password.addChangeHandler(event -> { + setDirty(true); + }); + } + + private void reset() { + for (int i = 0; i < this.eap.getItemCount(); i++) { + if (this.eap.getSelectedItemText().equals(Gwt8021xEap.TTLS.name())) { + this.eap.setSelectedIndex(i); + break; + } + } + + for (int i = 0; i < this.innerAuth.getItemCount(); i++) { + if (this.innerAuth.getSelectedItemText().equals(Gwt8021xInnerAuth.NONE.name())) { + this.innerAuth.setSelectedIndex(i); + break; + } + } + + this.password.setText(""); + this.username.setText(""); + + update(); + } + + private void setValues() { + logger.info("Start setValues"); + + if (this.activeConfig == null) { + // return; + } + + for (int i = 0; i < this.eap.getItemCount(); i++) { + if (this.eap.getItemText(i).equals(this.activeConfig.getEapEnum().name())) { + this.eap.setSelectedIndex(i); + break; + } + } + + for (int i = 0; i < this.innerAuth.getItemCount(); i++) { + if (this.innerAuth.getItemText(i).equals(this.activeConfig.getInnerAuthEnum().name())) { + this.innerAuth.setSelectedIndex(i); + break; + } + } + + this.username.setValue(GwtSafeHtmlUtils.htmlUnescape(this.activeConfig.getUsername())); + this.password.setValue(GwtSafeHtmlUtils.htmlUnescape(this.activeConfig.getPassword())); + } + + private boolean checkPassword() { + + if (!this.password.isEnabled()) { + return true; + } + + return !this.password.getText().isEmpty(); + } + + private void update() { + setValues(); + } + + @Override + public void clear() { + // Not needed + } + + @Override + public void refresh() { + if (isDirty()) { + setDirty(false); + if (this.activeConfig == null) { + reset(); + } else { + update(); + } + } + } + + @Override + public boolean isDirty() { + return this.dirty; + } + + @Override + public boolean isValid() { + boolean result = this.form.validate(); + + result &= checkPassword(); + + return result; + } + + @Override + public void setDirty(boolean dirty) { + this.dirty = dirty; + if (this.netTabs.getButtons() != null) { + this.netTabs.getButtons().setButtonsDirty(dirty); + } + } + + @Override + public void getUpdatedNetInterface(GwtNetInterfaceConfig updatedNetIf) { + Gwt8021xConfig updated8021xConfig = new Gwt8021xConfig(); + + if (this.username.isEnabled()) { + updated8021xConfig.setIdentity(this.username.getText()); + } + + if (this.password.isEnabled()) { + updated8021xConfig.setPassword(this.password.getText()); + } + + updated8021xConfig.setEap(Gwt8021xEap.valueOf(this.eap.getSelectedValue())); + updated8021xConfig.setInnerAuthEnum(Gwt8021xInnerAuth.valueOf(this.innerAuth.getSelectedValue())); + + updatedNetIf.setEnterpriseConfig(updated8021xConfig); + } + + @Override + public void setNetInterface(GwtNetInterfaceConfig config) { + + this.activeConfig = config.get8021xConfig(); + + for (int i = 0; i < this.eap.getItemCount(); i++) { + if (this.eap.getValue(i).equals(config.get8021xConfig().getEapEnum().name())) { + this.eap.setSelectedIndex(i); + break; + } + } + + for (int i = 0; i < this.innerAuth.getItemCount(); i++) { + if (this.innerAuth.getValue(i).equals(config.get8021xConfig().getInnerAuthEnum().name())) { + this.innerAuth.setSelectedIndex(i); + break; + } + } + + this.username.setValue(config.get8021xConfig().getUsername()); + this.password.setValue(config.get8021xConfig().getPassword()); + } + + private void updateFormEap(Gwt8021xEap eap) { + switch (eap) { + case PEAP: + case TTLS: + this.innerAuth.setEnabled(true); + this.username.setEnabled(true); + this.password.setEnabled(true); + break; + case TLS: + this.innerAuth.setEnabled(false); + setInnerAuthTo(Gwt8021xInnerAuth.NONE); + this.username.setEnabled(false); + this.password.setEnabled(false); + break; + default: + break; + } + } + + private void setInnerAuthTo(Gwt8021xInnerAuth auth) { + for (int i = 0; i < this.innerAuth.getItemCount(); i++) { + if (this.innerAuth.getItemText(i).equals(auth.name())) { + this.innerAuth.setSelectedIndex(i); + break; + } + } + } + + private void setHelpText(String message) { + this.helpText.clear(); + this.helpText.add(new Span(message)); + } + + private void resetHelpText() { + this.helpText.clear(); + this.helpText.add(new Span(MSGS.netHelpDefaultHint())); + } + +} diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.ui.xml b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.ui.xml new file mode 100644 index 00000000000..71d7168fec8 --- /dev/null +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/Tab8021xUi.ui.xml @@ -0,0 +1,126 @@ + + + + + + + + .important { + font-weight: bold; + } + + .center-panel { + font-size: 12px; + font-weight: normal; + } + + .padding { + margin-bottom: 50px; + } + + .help { + height: 300px; + } + + .help-header { + font-size: 14px; + } + + .scrollable { + overflow-x: auto; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 b38210aead8..cb74bacba13 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 @@ -47,6 +47,7 @@ import org.eclipse.kura.web.shared.service.GwtSecurityTokenService; import org.eclipse.kura.web.shared.service.GwtSecurityTokenServiceAsync; import org.gwtbootstrap3.client.ui.Alert; +import org.gwtbootstrap3.client.ui.AnchorListItem; import org.gwtbootstrap3.client.ui.Button; import org.gwtbootstrap3.client.ui.Form; import org.gwtbootstrap3.client.ui.FormGroup; @@ -100,6 +101,8 @@ public class TabWirelessUi extends Composite implements NetworkTab { private static final String WIFI_SECURITY_WPA_MESSAGE = MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA.name()); private static final String WIFI_SECURITY_WPA2_MESSAGE = MessageUtils .get(GwtWifiSecurity.netWifiSecurityWPA2.name()); + private static final String WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE = MessageUtils + .get(GwtWifiSecurity.netWifiSecurityWPA2WPA3Enterprise.name()); private static final String WIFI_SECURITY_WPA_WPA2_MESSAGE = MessageUtils .get(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name()); private static final String WIFI_BGSCAN_NONE_MESSAGE = MessageUtils @@ -143,9 +146,12 @@ interface TabWirelessUiUiBinder extends UiBinder { private final GwtSession session; private final TabIp4Ui tcpTab; private final NetworkTabsUi netTabs; + private final Tab8021xUi wireless8021x; private final ListDataProvider ssidDataProvider = new ListDataProvider<>(); private final SingleSelectionModel ssidSelectionModel = new SingleSelectionModel<>(); + AnchorListItem wireless8021xTabAnchorItem; + private boolean dirty; private boolean ssidInit; private boolean isNet2; @@ -338,12 +344,15 @@ interface TabWirelessUiUiBinder extends UiBinder { @UiField Text unavailableChannelErrorText; - public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp, NetworkTabsUi tabs) { + public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp, Tab8021xUi wireless8021x, + AnchorListItem wireless8021xTabAnchorItem, NetworkTabsUi tabs) { this.ssidInit = false; initWidget(uiBinder.createAndBindUi(this)); this.session = currentSession; this.tcpTab = tcp; this.netTabs = tabs; + this.wireless8021x = wireless8021x; + this.wireless8021xTabAnchorItem = wireless8021xTabAnchorItem; detectIfNet2(); @@ -665,6 +674,8 @@ private void refreshForm() { // Station mode if (WIFI_MODE_STATION_MESSAGE.equals(this.wireless.getSelectedItemText())) { + add8021xFromSecurityDropdown(); + if (tcpipStatus.equals(IPV4_STATUS_WAN_MESSAGE)) { this.wireless.setEnabled(false); } @@ -672,6 +683,9 @@ private void refreshForm() { } else if (WIFI_MODE_ACCESS_POINT_MESSAGE.equals(this.wireless.getSelectedItemText())) { // access point mode + + remove8021xFromSecurityDropdown(); + // disable access point when TCP/IP is set to WAN if (tcpipStatus.equals(IPV4_STATUS_WAN_MESSAGE)) { setForm(false); @@ -688,11 +702,21 @@ private void refreshForm() { this.buttonPassword.setVisible(false); } - // disable Password if security is none - if (this.security.getSelectedItemText().equals(WIFI_SECURITY_NONE_MESSAGE)) { + // disable Password if security is none, or if Wifi-Enterprise is enabled + if (this.security.getSelectedItemText().equals(WIFI_SECURITY_NONE_MESSAGE) + || this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE)) { + this.password.setEnabled(false); + this.verify.setEnabled(false); + this.buttonPassword.setEnabled(false); + } + + if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE)) { this.password.setEnabled(false); this.verify.setEnabled(false); this.buttonPassword.setEnabled(false); + this.wireless8021xTabAnchorItem.setEnabled(true); + } else { + this.wireless8021xTabAnchorItem.setEnabled(false); } if (WIFI_MODE_STATION_MESSAGE.equals(this.wireless.getSelectedItemText())) { @@ -755,6 +779,10 @@ private void refreshForm() { this.pairwise.setEnabled(false); this.group.setEnabled(false); } + + if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE)) { + this.password.setEnabled(false); + } } this.netTabs.updateTabs(); @@ -1227,6 +1255,29 @@ private List getChannelFrequencyByIndex(int selectedIndex) return Collections.singletonList(frequencyEntry); } + 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); + } + } + } + + private void add8021xFromSecurityDropdown() { + + if (!this.isNet2) { + remove8021xFromSecurityDropdown(); + return; + } + + for (int i = 0; i < this.security.getItemCount(); i++) { + if (this.security.getItemText(i).equals(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE)) { + return; + } + } + this.security.addItem(WIFI_SECURITY_WPA2_WPA3_ENTERPRISE_MESSAGE); + } + private Validator newBgScanValidator(TextBox field) { return new Validator() { diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net/GwtNetworkServiceImpl.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net/GwtNetworkServiceImpl.java index 3f84cbdc247..30abdfe0099 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net/GwtNetworkServiceImpl.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net/GwtNetworkServiceImpl.java @@ -353,16 +353,23 @@ private static List privateFindNetInterfaceConfigurations gwtWifiConfig.setDriver(wifiConfig.getDriver()); // security - if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA) { - gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA.name()); - } else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA2) { - gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA2.name()); - } else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WPA_WPA2) { - gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name()); - } else if (wifiConfig.getSecurity() == WifiSecurity.SECURITY_WEP) { - gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWEP.name()); - } else { - gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityNONE.name()); + switch(wifiConfig.getSecurity()){ + case SECURITY_WPA: + gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA.name()); + break; + case SECURITY_WPA2: + gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA2.name()); + break; + case SECURITY_WPA_WPA2: + gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name()); + break; + case SECURITY_WEP: + gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityWEP.name()); + break; + case SECURITY_NONE: + default: + gwtWifiConfig.setSecurity(GwtWifiSecurity.netWifiSecurityNONE.name()); + break; } if (wifiConfig.getPairwiseCiphers() == WifiCiphers.CCMP_TKIP) { diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/GwtNetInterfaceConfigBuilder.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/GwtNetInterfaceConfigBuilder.java index 044ffa3c010..b32c26f75b1 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/GwtNetInterfaceConfigBuilder.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/GwtNetInterfaceConfigBuilder.java @@ -19,6 +19,7 @@ import org.eclipse.kura.net.status.NetworkInterfaceType; import org.eclipse.kura.net.wifi.WifiBgscanModule; import org.eclipse.kura.web.server.net2.utils.EnumsParser; +import org.eclipse.kura.web.shared.model.Gwt8021xConfig; import org.eclipse.kura.web.shared.model.GwtModemInterfaceConfig; import org.eclipse.kura.web.shared.model.GwtNetIfConfigMode; import org.eclipse.kura.web.shared.model.GwtNetInterfaceConfig; @@ -66,6 +67,7 @@ public GwtNetInterfaceConfig build() { setRouterMode(); setWifiProperties(); setModemProperties(); + set8021xProperties(); return this.gwtConfig; } @@ -225,12 +227,12 @@ private void setWifiMasterProperties() { gwtWifiConfig.setIgnoreSSID(this.properties.getWifiMasterIgnoreSsid(this.ifName)); gwtWifiConfig.setPassword(new String(this.properties.getWifiMasterPassphrase(this.ifName).getPassword())); gwtWifiConfig.setWirelessMode(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name()); - gwtWifiConfig.setSecurity( - EnumsParser.getGwtWifiSecurity(this.properties.getWifiMasterSecurityType(this.ifName))); + gwtWifiConfig + .setSecurity(EnumsParser.getGwtWifiSecurity(this.properties.getWifiMasterSecurityType(this.ifName))); gwtWifiConfig.setPairwiseCiphers( EnumsParser.getGwtWifiCiphers(this.properties.getWifiMasterPairwiseCiphers(this.ifName))); - gwtWifiConfig.setGroupCiphers( - EnumsParser.getGwtWifiCiphers(this.properties.getWifiMasterGroupCiphers(this.ifName))); + gwtWifiConfig + .setGroupCiphers(EnumsParser.getGwtWifiCiphers(this.properties.getWifiMasterGroupCiphers(this.ifName))); gwtWifiConfig.setChannels(this.properties.getWifiMasterChannel(this.ifName)); // wifi master specific properties @@ -258,10 +260,10 @@ private void setWifiInfraProperties() { .setSecurity(EnumsParser.getGwtWifiSecurity(this.properties.getWifiInfraSecurityType(this.ifName))); gwtWifiConfig.setPairwiseCiphers( EnumsParser.getGwtWifiCiphers(this.properties.getWifiInfraPairwiseCiphers(this.ifName))); - gwtWifiConfig.setGroupCiphers( - EnumsParser.getGwtWifiCiphers(this.properties.getWifiInfraGroupCiphers(this.ifName))); + gwtWifiConfig + .setGroupCiphers(EnumsParser.getGwtWifiCiphers(this.properties.getWifiInfraGroupCiphers(this.ifName))); gwtWifiConfig.setChannels(this.properties.getWifiInfraChannel(this.ifName)); - + // wifi infra specific properties Optional radioMode = EnumsParser @@ -305,8 +307,7 @@ private void setModemProperties() { if (this.gwtConfig instanceof GwtModemInterfaceConfig) { GwtModemInterfaceConfig gwtModemConfig = (GwtModemInterfaceConfig) this.gwtConfig; - gwtModemConfig - .setAuthType(EnumsParser.getGwtModemAuthType(this.properties.getModemAuthType(this.ifName))); + gwtModemConfig.setAuthType(EnumsParser.getGwtModemAuthType(this.properties.getModemAuthType(this.ifName))); gwtModemConfig.setPdpType(EnumsParser.getGwtModemPdpType(this.properties.getModemPdpType(this.ifName))); gwtModemConfig.setDialString(this.properties.getModemDialString(this.ifName)); @@ -332,4 +333,14 @@ private void setModemProperties() { } } + private void set8021xProperties() { + + Gwt8021xConfig gwt8021xConfig = this.gwtConfig.get8021xConfig(); + + gwt8021xConfig.setEap(this.properties.get8021xEap(this.ifName)); + gwt8021xConfig.setInnerAuth(this.properties.get8021xInnerAuth(this.ifName)); + gwt8021xConfig.setIdentity(this.properties.get8021xIdentity(this.ifName)); + gwt8021xConfig.setPassword(new String(this.properties.get8021xPassword(this.ifName).getPassword())); + } + } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServiceProperties.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServiceProperties.java index cbcad7b7fe5..7ebb2da07de 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServiceProperties.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/configuration/NetworkConfigurationServiceProperties.java @@ -809,6 +809,47 @@ public void setUsbDevicePath(String ifname, String path) { this.properties.put(String.format(NET_INTERFACE_USB_DEVICE_PATH, ifname), path); } + /** + * Wifi Enterprise / 802-1x Configuration + */ + + private static final String NET_INTERFACE_CONFIG_8021X_EAP = "net.interface.%s.config.802-1x.eap"; + private static final String NET_INTERFACE_CONFIG_8021X_PHASE2 = "net.interface.%s.config.802-1x.innerAuth"; + private static final String NET_INTERFACE_CONFIG_8021X_IDENTITY = "net.interface.%s.config.802-1x.identity"; + private static final String NET_INTERFACE_CONFIG_8021X_PASSWORD = "net.interface.%s.config.802-1x.password"; + + public void set8021xEap(String ifname, String eap) { + this.properties.put(String.format(NET_INTERFACE_CONFIG_8021X_EAP, ifname), eap); + } + + public String get8021xEap(String ifname) { + return (String) this.properties.getOrDefault(String.format(NET_INTERFACE_CONFIG_8021X_EAP, ifname), ""); + } + + public void set8021xInnerAuth(String ifname, String phase2) { + this.properties.put(String.format(NET_INTERFACE_CONFIG_8021X_PHASE2, ifname), phase2); + } + + public String get8021xInnerAuth(String ifname) { + return (String) this.properties.getOrDefault(String.format(NET_INTERFACE_CONFIG_8021X_PHASE2, ifname), ""); + } + + public void set8021xIdentity(String ifname, String identity) { + this.properties.put(String.format(NET_INTERFACE_CONFIG_8021X_IDENTITY, ifname), identity); + } + + public String get8021xIdentity(String ifname) { + return (String) this.properties.getOrDefault(String.format(NET_INTERFACE_CONFIG_8021X_IDENTITY, ifname), ""); + } + + public void set8021xPassword(String ifname, String password) { + this.properties.put(String.format(NET_INTERFACE_CONFIG_8021X_PASSWORD, ifname), new Password(password)); + } + + public Password get8021xPassword(String ifname) { + return getPasswordFromProperty(this.properties.get(String.format(NET_INTERFACE_CONFIG_8021X_PASSWORD, ifname))); + } + /** * Password properties of the NetworkConfigurationService can be empty strings. * This method deals with that. 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 63f10cc3f8c..dbf543e78e7 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 @@ -28,6 +28,9 @@ import org.eclipse.kura.web.shared.model.GwtNetRouterMode; import org.eclipse.kura.web.shared.model.GwtWifiConfig; import org.eclipse.kura.web.shared.model.GwtWifiNetInterfaceConfig; +import org.eclipse.kura.web.shared.model.GwtWifiSecurity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NetworkConfigurationServicePropertiesBuilder { @@ -37,6 +40,8 @@ public class NetworkConfigurationServicePropertiesBuilder { private final NetworkConfigurationServiceProperties properties; private final String ifname; + private static final Logger logger = LoggerFactory.getLogger(NetworkConfigurationServicePropertiesBuilder.class); + private final GwtNetInterfaceConfig oldGwtNetInterfaceConfig; public NetworkConfigurationServicePropertiesBuilder(GwtNetInterfaceConfig gwtConfig) @@ -54,16 +59,17 @@ public Map build() throws GwtKuraException { setIpv6Properties(); setIpv4DhcpClientProperties(); setIpv4DhcpServerProperties(); + set8021xConfig(); switch (this.gwtConfig.getStatusEnum()) { - case netIPv4StatusDisabled: - break; - case netIPv4StatusUnmanaged: - break; - default: - setWifiProperties(); - setModemProperties(); - break; + case netIPv4StatusDisabled: + break; + case netIPv4StatusUnmanaged: + break; + default: + setWifiProperties(); + setModemProperties(); + break; } // Manage GPS independently of device ip status @@ -150,25 +156,23 @@ private void setIpv6Properties() { private void setIpv4DhcpClientProperties() { switch (this.gwtConfig.getConfigModeEnum()) { - case netIPv4ConfigModeDHCP: - this.properties.setDhcpClient4Enabled(this.ifname, true); - break; - case netIPv4ConfigModeManual: - this.properties.setDhcpClient4Enabled(this.ifname, false); - break; - default: - break; + case netIPv4ConfigModeDHCP: + this.properties.setDhcpClient4Enabled(this.ifname, true); + break; + case netIPv4ConfigModeManual: + this.properties.setDhcpClient4Enabled(this.ifname, false); + break; + default: + break; } } private void setIpv4DhcpServerProperties() { boolean isManualAddress = this.gwtConfig.getConfigModeEnum() == GwtNetIfConfigMode.netIPv4ConfigModeManual; - boolean isDhcpServer = isManualAddress - && this.gwtConfig.getRouterModeEnum() != GwtNetRouterMode.netRouterOff + boolean isDhcpServer = isManualAddress && this.gwtConfig.getRouterModeEnum() != GwtNetRouterMode.netRouterOff && this.gwtConfig.getRouterModeEnum() != GwtNetRouterMode.netRouterNat; - boolean isNatEnabled = isManualAddress - && (this.gwtConfig.getRouterModeEnum() == GwtNetRouterMode.netRouterNat - || this.gwtConfig.getRouterModeEnum() == GwtNetRouterMode.netRouterDchpNat); + boolean isNatEnabled = isManualAddress && (this.gwtConfig.getRouterModeEnum() == GwtNetRouterMode.netRouterNat + || this.gwtConfig.getRouterModeEnum() == GwtNetRouterMode.netRouterDchpNat); this.properties.setDhcpServer4Enabled(this.ifname, isDhcpServer); this.properties.setNatEnabled(this.ifname, isNatEnabled); @@ -215,9 +219,9 @@ private void setWifiMasterProperties() throws GwtKuraException { GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig = (GwtWifiNetInterfaceConfig) oldGwtNetInterfaceConfig; gwtWifiNetInterfaceConfig.setUnescaped(true); - GwtWifiConfig gwtApConfig = gwtWifiNetInterfaceConfig.getAccessPointWifiConfig(); + GwtWifiConfig gwtApConfig = gwtWifiNetInterfaceConfig.getAccessPointWifiConfig(); gwtApConfig.setUnescaped(true); - + this.properties.setWifiMasterPassphrase(this.ifname, gwtApConfig.getPassword()); } else { GwtServerUtil.validateUserPassword(gwtWifiConfig.getPassword()); @@ -242,6 +246,14 @@ private void setWifiMasterProperties() throws GwtKuraException { } + private void set8021xConfig() { + logger.error("setting 802-1x config"); + this.properties.set8021xEap(this.ifname, this.gwtConfig.get8021xConfig().getEap()); + this.properties.set8021xInnerAuth(this.ifname, this.gwtConfig.get8021xConfig().getInnerAuth()); + this.properties.set8021xIdentity(this.ifname, this.gwtConfig.get8021xConfig().getUsername()); + this.properties.set8021xPassword(this.ifname, this.gwtConfig.get8021xConfig().getPassword()); + } + private void setWifiInfraProperties() { GwtWifiConfig gwtWifiConfig = ((GwtWifiNetInterfaceConfig) this.gwtConfig).getStationWifiConfig(); gwtWifiConfig.setUnescaped(true); @@ -256,11 +268,11 @@ private void setWifiInfraProperties() { && oldGwtNetInterfaceConfig instanceof GwtWifiNetInterfaceConfig) { GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig = (GwtWifiNetInterfaceConfig) oldGwtNetInterfaceConfig; gwtWifiNetInterfaceConfig.setUnescaped(true); - - GwtWifiConfig gwtStationConfig = gwtWifiNetInterfaceConfig.getStationWifiConfig(); + + GwtWifiConfig gwtStationConfig = gwtWifiNetInterfaceConfig.getStationWifiConfig(); gwtStationConfig.setUnescaped(true); - - this.properties.setWifiInfraPassphrase(this.ifname,gwtStationConfig.getPassword()); + + this.properties.setWifiInfraPassphrase(this.ifname, gwtStationConfig.getPassword()); } else { this.properties.setWifiInfraPassphrase(this.ifname, gwtWifiConfig.getPassword()); } @@ -315,10 +327,10 @@ private void setModemProperties() { if (gwtModemConfig.getPassword() != null) { if (GwtServerUtil.PASSWORD_PLACEHOLDER.equals(gwtModemConfig.getPassword()) && oldGwtNetInterfaceConfig instanceof GwtModemInterfaceConfig) { - + GwtModemInterfaceConfig gwtModemInterfaceConfig = (GwtModemInterfaceConfig) oldGwtNetInterfaceConfig; gwtModemInterfaceConfig.setUnescaped(true); - + this.properties.setModemPassword(this.ifname, gwtModemInterfaceConfig.getPassword()); } else { this.properties.setModemPassword(this.ifname, gwtModemConfig.getPassword()); diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/utils/EnumsParser.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/utils/EnumsParser.java index 037438a0fc8..a5a3865c7b3 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/utils/EnumsParser.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/utils/EnumsParser.java @@ -166,6 +166,10 @@ public static String getGwtWifiSecurity(Optional wifiSecurity) { if (wifiSecurity.get().equals(WifiSecurity.SECURITY_WPA_WPA2.name())) { return GwtWifiSecurity.netWifiSecurityWPA_WPA2.name(); } + + if (wifiSecurity.get().equals(WifiSecurity.SECURITY_WPA2_WPA3_ENTERPRISE.name())) { + return GwtWifiSecurity.netWifiSecurityWPA2WPA3Enterprise.name(); + } } return GwtWifiSecurity.netWifiSecurityWPA2.name(); @@ -192,6 +196,11 @@ public static String getWifiSecurity(Optional gwtWifiSecurity) { if (gwtWifiSecurity.get().equals(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name())) { return WifiSecurity.SECURITY_WPA_WPA2.name(); } + + if (gwtWifiSecurity.get().equals(GwtWifiSecurity.netWifiSecurityWPA2WPA3Enterprise.name())) { + return WifiSecurity.SECURITY_WPA2_WPA3_ENTERPRISE.name(); + } + } return WifiSecurity.NONE.name(); @@ -263,9 +272,9 @@ public static Optional getGwtWifiRadioMode(Optional wifiRadioMod return Optional.of(GwtWifiRadioMode.netWifiRadioModeBG.name()); } - if (wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT20.name()) || - wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT40above.name()) || - wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT40below.name())) { + if (wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT20.name()) + || wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT40above.name()) + || wifiRadioMode.get().equals(WifiRadioMode.RADIO_MODE_80211nHT40below.name())) { return Optional.of(GwtWifiRadioMode.netWifiRadioModeBGN.name()); } } @@ -333,16 +342,16 @@ public static GwtModemAuthType getGwtModemAuthType(Optional authType) { public static String getAuthType(Optional gwtModemAuthType) { if (gwtModemAuthType.isPresent()) { switch (gwtModemAuthType.get()) { - case netModemAuthAUTO: - return AuthType.AUTO.name(); - case netModemAuthCHAP: - return AuthType.CHAP.name(); + case netModemAuthAUTO: + return AuthType.AUTO.name(); + case netModemAuthCHAP: + return AuthType.CHAP.name(); - case netModemAuthPAP: - return AuthType.PAP.name(); - case netModemAuthNONE: - default: - break; + case netModemAuthPAP: + return AuthType.PAP.name(); + case netModemAuthNONE: + default: + break; } } @@ -378,15 +387,15 @@ public static GwtModemPdpType getGwtModemPdpType(Optional pdpType) { public static String getPdpType(Optional gwtModemPdpType) { if (gwtModemPdpType.isPresent()) { switch (gwtModemPdpType.get()) { - case netModemPdpIP: - return PdpType.IP.name(); - case netModemPdpIPv6: - return PdpType.IPv6.name(); - case netModemPdpPPP: - return PdpType.PPP.name(); - case netModemPdpUnknown: - default: - break; + case netModemPdpIP: + return PdpType.IP.name(); + case netModemPdpIPv6: + return PdpType.IPv6.name(); + case netModemPdpPPP: + return PdpType.PPP.name(); + case netModemPdpUnknown: + default: + break; } } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xConfig.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xConfig.java new file mode 100644 index 00000000000..b4b8176ef80 --- /dev/null +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xConfig.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech + *******************************************************************************/ +package org.eclipse.kura.web.shared.model; + +import java.io.Serializable; +import java.util.Map; +import java.util.Map.Entry; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Gwt8021xConfig extends KuraBaseModel implements Serializable { + + private static final String KEY_EAP = "eap"; + private static final String KEY_INNER_AUTH = "innerAuth"; + private static final Logger logger = Logger.getLogger(Gwt8021xConfig.class.getSimpleName()); + private static final long serialVersionUID = 7079533925979145804L; + + public Gwt8021xEap getEapEnum() { + return Gwt8021xEap.fromMetatypeString(getEap()); + } + + public String getEap() { + return get(KEY_EAP); + } + + public void setEap(String eap) { + set(KEY_EAP, eap); + } + + public void setEap(Gwt8021xEap eap) { + set(KEY_EAP, eap.getLabel()); + } + + public Gwt8021xInnerAuth getInnerAuthEnum() { + return Gwt8021xInnerAuth.fromMetatypeString(getInnerAuth()); + } + + public String getInnerAuth() { + return get(KEY_INNER_AUTH); + } + + public void setInnerAuth(String innerAuth) { + set(KEY_INNER_AUTH, innerAuth); + } + + public void setInnerAuthEnum(Gwt8021xInnerAuth innerAuth) { + set(KEY_INNER_AUTH, innerAuth.getLabel()); + } + + public String getUsername() { + return get("username"); + } + + public void setIdentity(String username) { + set("username", username); + } + + public String getPassword() { + return get("password"); + } + + public void setPassword(String password) { + set("password", password); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Gwt8021xConfig)) { + return false; + } + + Map properties = getProperties(); + Map otherProps = ((Gwt8021xConfig) o).getProperties(); + + if (properties != null) { + if (otherProps == null) { + return false; + } + if (properties.size() != otherProps.size()) { + logger.log(Level.FINER, "Sizes differ"); + return false; + } + + for (Entry entry : properties.entrySet()) { + final Object oldVal = entry.getValue(); + final Object newVal = otherProps.get(entry.getKey()); + if (oldVal != null) { + if (!oldVal.equals(newVal)) { + logger.log(Level.FINER, () -> "Values differ - Key: " + entry.getKey() + " oldVal: " + oldVal + + ", newVal: " + newVal); + return false; + } + } else if (newVal != null) { + return false; + } + } + } else if (otherProps != null) { + return false; + } + + return true; + } +} diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xEap.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xEap.java new file mode 100644 index 00000000000..a2d4f3679be --- /dev/null +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xEap.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech + *******************************************************************************/ +package org.eclipse.kura.web.shared.model; + +public enum Gwt8021xEap { + + TLS("Kura8021xEapTls"), + TTLS("Kura8021xEapTtls"), + PEAP("Kura8021xEapPeap"); + + private final String label; + + Gwt8021xEap(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + + public static Gwt8021xEap fromMetatypeString(String label) { + for (Gwt8021xEap eap : Gwt8021xEap.values()) { + if (eap.getLabel().equals(label)) { + return eap; + } + } + return Gwt8021xEap.TTLS; + } + +} diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xInnerAuth.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xInnerAuth.java new file mode 100644 index 00000000000..52d5ac3c833 --- /dev/null +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/Gwt8021xInnerAuth.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech + *******************************************************************************/ +package org.eclipse.kura.web.shared.model; + +public enum Gwt8021xInnerAuth { + + NONE("Kura8021xInnerAuthNone"), + MSCHAPV2("Kura8021xInnerAuthMschapv2"); + + private final String label; + + Gwt8021xInnerAuth(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + + public static Gwt8021xInnerAuth fromMetatypeString(String label) { + for (Gwt8021xInnerAuth innerAuth : Gwt8021xInnerAuth.values()) { + if (innerAuth.getLabel().equals(label)) { + return innerAuth; + } + } + return Gwt8021xInnerAuth.NONE; + } +} diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java index 77746105f4d..e98a1d45787 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java @@ -24,6 +24,20 @@ public class GwtNetInterfaceConfig extends KuraBaseModel implements Serializable private static final Logger logger = Logger.getLogger(GwtNetInterfaceConfig.class.getSimpleName()); private static final long serialVersionUID = 7079533925979145804L; + private Gwt8021xConfig enterpriseConfig = new Gwt8021xConfig(); + + public void setEnterpriseConfig(Gwt8021xConfig enterpriseConfig) { + this.enterpriseConfig = enterpriseConfig; + } + + public Gwt8021xConfig get8021xConfig() { + return this.enterpriseConfig; + } + + public Map getEnterpriseConfigProps() { + return this.enterpriseConfig.getProperties(); + } + public String getName() { return get("name"); } @@ -292,7 +306,7 @@ public String getIpv6Status() { public void setIpv6Status(String status) { set("ipv6.status", status); } - + public Integer getIpv6WanPriority() { return get("ipv6.priority"); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtWifiSecurity.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtWifiSecurity.java index a6831381d56..d2957da58fe 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtWifiSecurity.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtWifiSecurity.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2020 Eurotech and/or its affiliates and others + * Copyright (c) 2011, 2020, 2023 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 @@ -17,5 +17,6 @@ public enum GwtWifiSecurity { netWifiSecurityWEP, netWifiSecurityWPA, netWifiSecurityWPA2, + netWifiSecurityWPA2WPA3Enterprise, netWifiSecurityWPA_WPA2 } 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 1665827cfac..08d197bcadd 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,6 +629,16 @@ netWifiChannelMissingError=The chosen network uses a channel that is not allowed netWifiCountryCode=Country Code netWifiCountryCodeLabel=Country Code +netWifiWireless8021x=802-1x +net8021xEap=Enterprise EAP (Extensible Authentication Protocol) +net8021xEapHelp=Extensible Authentication Protocol (EAP), determine what protocol will be used to authenticate the network. +net8021xInnerAuth=Inner Authentication (Phase2 Auth) +net8021xInnerAuthHelp=Inner Authentication, also known as Phase 2 authentication. Determines which type of credientials will be used to authenticate the client on the network. +net8021xUsername=Identity (Username) +net8021xUsernameHelp=A String that represents a username used for EAP authentication. +net8021xPassword=Password +net8021xPasswordHelp=A String that represents a password used for EAP authentication. + netLabelDhcpLease=DHCP List netDhcpLeaseHelp=Displays List of Dhcp (MAC Address, IP Address, Hostname) 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 d85e2eee630..b03e320864d 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 @@ -597,6 +597,16 @@ netWifiChannelListLabel=チャネルのリスト netWifiCountryCode=カントリーコード netWifiCountryCodeLabel=カントリーコード +netWifiWireless8021x=802-1x +net8021xEap=エンタープライズ WiFi EAP (Extensible Authentication Protocol) +net8021xEapHelp=Extensible Authentication Protocol (EAP), ネットワークの認証にどのプロトコルが使用されるかを決定します。 +net8021xInnerAuth=内部認証 (フェーズ 2 認証) +net8021xInnerAuthHelp=内部認証, としても知られている フェーズ 2 認証. ネットワーク上のクライアントの認証にどのタイプの資格情報を使用するかを決定します。 +net8021xUsername=ID (ユーザー名) +net8021xUsernameHelp=EAP 認証に使用されるユーザー名を表す文字列。 +net8021xPassword=パスワード +net8021xPasswordHelp=EAP 認証に使用されるパスワードを表す文字列。 + netModemCellular=セルラー netModemGps=GPS netModemModel=モデル diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/ValidationMessages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/ValidationMessages.properties index 2669cea5aa3..7f9dd53f819 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/ValidationMessages.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/ValidationMessages.properties @@ -164,6 +164,7 @@ netWifiSecurityWEP=WEP netWifiSecurityWPA=WPA netWifiSecurityWPA2=WPA2 netWifiSecurityWPA_WPA2=WPA/WPA2 +netWifiSecurityWPA2WPA3Enterprise=WPA2/WPA3-Enterprise netWifiWpaAcceptedProtocols_WPA_RSN=WPA and RSN netWifiWpaAcceptedProtocols_WPA=WPA