Skip to content

Commit

Permalink
fix: optional fields wpa enterprise (#5043)
Browse files Browse the repository at this point in the history
* fix: optinal feilds wpa enterprise

* refactor: revert formatting

* feat: added tab highlighting when tab is wrong

* fix: clear UI changes first

* fix: add ipv6 entry

* fix: add modem entry

* fix: Incorrect behaviour fixes in 802.1x tab

Signed-off-by: MMaiero <[email protected]>

* fix: password management

Signed-off-by: MMaiero <[email protected]>

* fix: Inner auth behaviour

Signed-off-by: MMaiero <[email protected]>

* fix: 802.1 identity validity check

Signed-off-by: MMaiero <[email protected]>

---------

Signed-off-by: MMaiero <[email protected]>
Co-authored-by: MMaiero <[email protected]>
  • Loading branch information
GregoryIvo and MMaiero authored Jan 8, 2024
1 parent a73c7af commit 9b371f4
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.kura.web.client.ui.network;

import java.awt.Color;
import java.nio.channels.AsynchronousCloseException;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
Expand All @@ -35,6 +37,9 @@
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.Unit;

public class NetworkTabsUi extends Composite {

private static final String WIFI_ACCESS_POINT = GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name();
Expand Down Expand Up @@ -143,7 +148,7 @@ private void initIp6Tab() {
NetworkTabsUi.this.content.add(NetworkTabsUi.this.ip6Tab);
});
}

private void initWireless8021xTab() {
this.net8021xTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless8021x());
this.set8021xTab = new Tab8021xUi(this.session, this, this.ip4Tab, this.ip6Tab);
Expand All @@ -158,8 +163,8 @@ private void initWireless8021xTab() {

private void initWirelessTab(final boolean isNet2) {
this.wirelessTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless());
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.ip6Tab,
this.net8021xTabAnchorItem, this, isNet2);
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.ip6Tab, this.net8021xTabAnchorItem, this,
isNet2);

this.wirelessTabAnchorItem.addClickHandler(event -> {
setSelected(NetworkTabsUi.this.wirelessTabAnchorItem);
Expand Down Expand Up @@ -335,7 +340,7 @@ private void showWirelessTabs(boolean interfaceNotEnabled) {

insertTab(this.wirelessTabAnchorItem);
if (this.isNet2) {
if(interfaceNotEnabled) {
if (interfaceNotEnabled) {
this.net8021xTabAnchorItem.setEnabled(false);
}
insertTab(this.net8021xTabAnchorItem);
Expand Down Expand Up @@ -420,7 +425,8 @@ private void refreshAllVisibleTabs() {
*/

public boolean isDirty() {
if ((this.visibleTabs.contains(this.ip4TabAnchorItem) && this.ip4Tab.isDirty()) || (this.visibleTabs.contains(this.ip6TabAnchorItem) && this.ip6Tab.isDirty())) {
if ((this.visibleTabs.contains(this.ip4TabAnchorItem) && this.ip4Tab.isDirty())
|| (this.visibleTabs.contains(this.ip6TabAnchorItem) && this.ip6Tab.isDirty())) {
return true;
}

Expand Down Expand Up @@ -526,40 +532,61 @@ public NetworkTab getSelectedTab() {
}

public boolean isValid() {

clearErrorTab(this.ip4TabAnchorItem);
clearErrorTab(this.ip6TabAnchorItem);
clearErrorTab(this.hardwareTabAnchorItem);
clearErrorTab(this.dhcp4NatTabAnchorItem);
clearErrorTab(this.wirelessTabAnchorItem);
clearErrorTab(this.modemTabAnchorItem);
clearErrorTab(this.modemGpsTabAnchorItem);
clearErrorTab(this.modemAntennaTabAnchorItem);
clearErrorTab(this.net8021xTabAnchorItem);

if (this.visibleTabs.contains(this.ip4TabAnchorItem) && !this.ip4Tab.isValid()) {
errorTab(this.ip4TabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.ip6TabAnchorItem) && this.ip6TabAnchorItem.isEnabled()
&& !this.ip6Tab.isValid()) {
errorTab(this.ip6TabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.hardwareTabAnchorItem) && !this.hardwareTab.isValid()) {
errorTab(this.hardwareTabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.dhcp4NatTabAnchorItem) && this.dhcp4NatTabAnchorItem.isEnabled()
&& !this.dhcp4NatTab.isValid()) {
errorTab(this.dhcp4NatTabAnchorItem);
return false;
}

if ((this.visibleTabs.contains(this.wirelessTabAnchorItem) && !this.wirelessTab.isValid()) || (this.visibleTabs.contains(this.modemTabAnchorItem) && !this.modemTab.isValid())) {
if ((this.visibleTabs.contains(this.wirelessTabAnchorItem) && !this.wirelessTab.isValid())
|| (this.visibleTabs.contains(this.modemTabAnchorItem) && !this.modemTab.isValid())) {
errorTab(this.wirelessTabAnchorItem);
errorTab(this.modemTabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.modemGpsTabAnchorItem) && this.modemGpsTabAnchorItem.isEnabled()
&& !this.modemGpsTab.isValid()) {
errorTab(this.modemGpsTabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.modemAntennaTabAnchorItem) && this.modemAntennaTabAnchorItem.isEnabled()
&& !this.modemAntennaTab.isValid()) {
errorTab(this.modemAntennaTabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.net8021xTabAnchorItem) && this.net8021xTabAnchorItem.isEnabled()
&& !this.set8021xTab.isValid()) {
errorTab(this.net8021xTabAnchorItem);
return false;
}

Expand All @@ -574,6 +601,14 @@ public boolean isUnmanagedSelected() {
* Utilities
*/

private void errorTab(AnchorListItem tab) {
tab.addStyleName("alert-danger");
}

private void clearErrorTab(AnchorListItem tab) {
tab.removeStyleName("alert-danger");
}

private void removeTab(AnchorListItem tab) {
this.visibleTabs.remove(tab);
this.tabsPanel.remove(tab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*******************************************************************************/
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;
Expand Down Expand Up @@ -159,6 +157,7 @@ public Tab8021xUi(GwtSession currentSession, NetworkTabsUi tabs, TabIp4Ui tcp4,
this.netTabs = tabs;
this.tcp4Tab = tcp4;
this.tcp6Tab = tcp6;
this.helpTitle.setText(MSGS.netHelpTitle());

initLabels();
initHelpButtons();
Expand Down Expand Up @@ -231,18 +230,10 @@ private void initInnerAuthListBox() {
}

this.innerAuth.addMouseOverHandler(event -> {
if (this.innerAuth.isEnabled()) {
setHelpText(MSGS.net8021xInnerAuthHelp());
}
setHelpText(MSGS.net8021xInnerAuthHelp());
});

this.innerAuth.addMouseOutHandler(event -> resetHelpText());

this.innerAuth.addChangeHandler(event -> {
setDirty(true);
refreshForm();
resetValidations();
});
}

private void initUsernameTextBox() {
Expand Down Expand Up @@ -280,6 +271,7 @@ private void initPasswordTextBox() {
this.password.addMouseOutHandler(event -> resetHelpText());

this.password.addChangeHandler(event -> {
setDirty(true);

if (!this.password.validate() && this.password.isEnabled()) {
this.formgroupPassword.setValidationState(ValidationState.ERROR);
Expand Down Expand Up @@ -455,42 +447,48 @@ public boolean isValid() {
boolean isPEAP = Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.PEAP;
boolean isTTLS = Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.TTLS;

boolean result = true;

if (isTLS) {

if (this.username.getValue().isEmpty()) {
if (isNonEmptyString(this.username)) {
this.formgroupIdentityUsername.setValidationState(ValidationState.ERROR);
return false;
result = false;
}

if (this.keystorePid.getValue().isEmpty()) {
if (isNonEmptyString(this.keystorePid)) {
this.identityKeystorePid.setValidationState(ValidationState.ERROR);
return false;
result = false;
}

if (this.publicPrivateKeyPairName.getValue().isEmpty()) {
if (isNonEmptyString(this.publicPrivateKeyPairName)) {
this.identityPublicPrivateKeyPairName.setValidationState(ValidationState.ERROR);
return false;
result = false;
}
}

if (isPEAP || isTTLS) {
if (this.username.getValue().isEmpty()) {
if (isNonEmptyString(this.username)) {
this.formgroupIdentityUsername.setValidationState(ValidationState.ERROR);
return false;
result = false;
}

if (this.password.getValue().isEmpty()) {
if (this.password.getValue() == null || this.password.getValue().trim().isEmpty()) {
this.formgroupPassword.setValidationState(ValidationState.ERROR);
return false;
result = false;
}

if (this.keystorePid.getValue().isEmpty() && !this.caCertName.getValue().isEmpty()) {
if (isNonEmptyString(this.keystorePid) && !isNonEmptyString(this.caCertName)) {
this.identityKeystorePid.setValidationState(ValidationState.ERROR);
return false;
result = false;
}
}

return true;
return result;
}

private boolean isNonEmptyString(TextBox value) {
return value.getValue() == null || value.getValue().trim().isEmpty();
}

@Override
Expand Down Expand Up @@ -534,6 +532,7 @@ private void refreshFieldsBasedOnSelectedValues() {
switch (Gwt8021xEap.valueOf(this.eap.getSelectedValue())) {
case PEAP:
case TTLS:
this.innerAuth.setEnabled(false);
setInnerAuthTo(Gwt8021xInnerAuth.MSCHAPV2);
this.publicPrivateKeyPairName.setEnabled(false);
break;
Expand Down
Loading

0 comments on commit 9b371f4

Please sign in to comment.