Skip to content

Commit

Permalink
fix: 802.1x tab displaying and refresh
Browse files Browse the repository at this point in the history
Signed-off-by: MMaiero <[email protected]>
  • Loading branch information
MMaiero committed Dec 12, 2023
1 parent 6b701c3 commit ad145ad
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;

import org.eclipse.kura.web.client.messages.Messages;
import org.eclipse.kura.web.client.util.MessageUtils;
Expand Down Expand Up @@ -142,10 +143,22 @@ 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);

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 initWirelessTab(final boolean isNet2) {
this.wirelessTabAnchorItem = new AnchorListItem(MSGS.netWifiWireless());
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.ip6Tab, this.set8021xTab,
this.wirelessTab = new TabWirelessUi(this.session, this.ip4Tab, this.ip6Tab,
this.net8021xTabAnchorItem, this, isNet2);

this.wirelessTabAnchorItem.addClickHandler(event -> {
Expand All @@ -156,18 +169,6 @@ private void initWirelessTab(final boolean isNet2) {
});
}

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);
Expand Down Expand Up @@ -334,8 +335,10 @@ private void showWirelessTabs(boolean interfaceNotEnabled) {

insertTab(this.wirelessTabAnchorItem);
if (this.isNet2) {
if(interfaceNotEnabled) {
this.net8021xTabAnchorItem.setEnabled(false);
}
insertTab(this.net8021xTabAnchorItem);
this.net8021xTabAnchorItem.setEnabled(!interfaceNotEnabled);
}

insertTab(this.dhcp4NatTabAnchorItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,27 @@
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.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.Form;
import org.gwtbootstrap3.client.ui.FormGroup;
import org.gwtbootstrap3.client.ui.FormLabel;
import org.gwtbootstrap3.client.ui.ListBox;
import org.gwtbootstrap3.client.ui.PanelHeader;
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 org.gwtbootstrap3.client.ui.FormGroup;

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;
import com.google.gwt.user.client.ui.Widget;

public class Tab8021xUi extends Composite implements NetworkTab {

Expand All @@ -52,11 +49,16 @@ public class Tab8021xUi extends Composite implements NetworkTab {
interface Tab8021xUiUiBinder extends UiBinder<Widget, Tab8021xUi> {
}

private static final Logger logger = Logger.getLogger(Tab8021xUi.class.getSimpleName());

private final NetworkTabsUi netTabs;

Gwt8021xConfig activeConfig;
GwtSession currentSession;

private final TabIp4Ui tcp4Tab;
private final TabIp6Ui tcp6Tab;

private boolean dirty;

// Labels
Expand Down Expand Up @@ -152,28 +154,34 @@ interface Tab8021xUiUiBinder extends UiBinder<Widget, Tab8021xUi> {
@UiField
FormGroup identityPublicPrivateKeyPairName;

public Tab8021xUi(GwtSession currentSession, NetworkTabsUi tabs) {
public Tab8021xUi(GwtSession currentSession, NetworkTabsUi tabs, TabIp4Ui tcp4, TabIp6Ui tcp6) {
initWidget(uiBinder.createAndBindUi(this));

this.currentSession = currentSession;
this.netTabs = tabs;
this.tcp4Tab = tcp4;
this.tcp6Tab = tcp6;

initLabels();
initHelpButtons();
initListBoxes();
initTextBoxes();

this.buttonTestPassword.setVisible(false);

this.tcp4Tab.status.addChangeHandler(event -> update());

this.tcp6Tab.status.addChangeHandler(event -> update());
}

private void initLabels() {
labelEap.setText(MSGS.net8021xEap());
labelInnerAuth.setText(MSGS.net8021xInnerAuth());
labelUsername.setText(MSGS.net8021xUsername());
labelPassword.setText(MSGS.net8021xPassword());
labelKeystorePid.setText(MSGS.net8021xKeystorePid());
labelCaCertName.setText(MSGS.net8021xCaCert());
labelPublicPrivateKeyPairName.setText(MSGS.net8021xPublicPrivateKeyPair());
this.labelEap.setText(MSGS.net8021xEap());
this.labelInnerAuth.setText(MSGS.net8021xInnerAuth());
this.labelUsername.setText(MSGS.net8021xUsername());
this.labelPassword.setText(MSGS.net8021xPassword());
this.labelKeystorePid.setText(MSGS.net8021xKeystorePid());
this.labelCaCertName.setText(MSGS.net8021xCaCert());
this.labelPublicPrivateKeyPairName.setText(MSGS.net8021xPublicPrivateKeyPair());
}

private void initHelpButtons() {
Expand Down Expand Up @@ -214,7 +222,6 @@ private void initEapListBox() {

this.eap.addChangeHandler(event -> {
setDirty(true);
this.netTabs.updateTabs();
refreshForm();
resetValidations();
});
Expand All @@ -235,7 +242,6 @@ private void initInnerAuthListBox() {

this.innerAuth.addChangeHandler(event -> {
setDirty(true);
this.netTabs.updateTabs();
refreshForm();
resetValidations();
});
Expand Down Expand Up @@ -320,9 +326,7 @@ private void initCaCertNameTextBox() {
this.caCertName.setAllowBlank(true);
this.caCertName.addMouseOutHandler(event -> resetHelpText());

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

private void initPrivateKeyNameTextBox() {
Expand All @@ -348,6 +352,14 @@ private void initPrivateKeyNameTextBox() {
});
}

private void update() {
logger.info("update");
setValues();
refreshForm();
this.netTabs.updateTabs();
logger.info("update... done");
}

private void resetValidations() {
this.formgroupIdentityUsername.setValidationState(ValidationState.NONE);
this.formgroupPassword.setValidationState(ValidationState.NONE);
Expand All @@ -370,6 +382,7 @@ private void refreshForm() {
}

private void reset() {
logger.info("reset");
for (int i = 0; i < this.eap.getItemCount(); i++) {
if (this.eap.getSelectedItemText().equals(Gwt8021xEap.TTLS.name())) {
this.eap.setSelectedIndex(i);
Expand All @@ -390,6 +403,8 @@ private void reset() {
this.keystorePid.setValue("");
this.caCertName.setValue("");
this.publicPrivateKeyPairName.setValue("");
update();
logger.info("reset... done");
}

private void setValues() {
Expand All @@ -414,7 +429,6 @@ private void setValues() {
this.keystorePid.setValue(this.activeConfig.getKeystorePid());
this.caCertName.setValue(this.activeConfig.getCaCertName());
this.publicPrivateKeyPairName.setValue(this.activeConfig.getPublicPrivateKeyPairName());

}

@Override
Expand All @@ -431,9 +445,7 @@ public void refresh() {
if (this.activeConfig == null) {
reset();
} else {
setValues();
refreshForm();
this.netTabs.updateTabs();
update();
}
}
}
Expand All @@ -445,9 +457,9 @@ public boolean isDirty() {

@Override
public boolean isValid() {
boolean isTLS = (Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.TLS);
boolean isPEAP = (Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.PEAP);
boolean isTTLS = (Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.TTLS);
boolean isTLS = Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.TLS;
boolean isPEAP = Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.PEAP;
boolean isTTLS = Gwt8021xEap.valueOf(this.eap.getSelectedValue()) == Gwt8021xEap.TTLS;

if (isTLS) {

Expand Down
Loading

0 comments on commit ad145ad

Please sign in to comment.