Skip to content

Commit

Permalink
Update tab colors, UI updates on separate thread, remove unused class
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Arthur committed Jan 28, 2020
1 parent bb879bb commit a0bf3db
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
@Override
public void onStartupSuccess(String message) {
logger.info("Local authentication proxy started!");
burpTabController.setTabColor(Color.GREEN);
SwingUtilities.invokeLater(() -> burpTabController.setTabColor(new Color(60, 146, 38)));
}

@Override
Expand All @@ -108,20 +108,26 @@ public void onStartupFail(String message) {

@Override
public void onShutdown() {
burpTabController.setTabColor(Color.RED);
SwingUtilities.invokeLater(() -> {
if(UIManager.getLookAndFeel().getName().equalsIgnoreCase("darcula")) {
burpTabController.setTabColor(new Color(212, 60, 55));
}else{
burpTabController.setTabColor(new Color(220, 10, 19));
}
});
}
});

//Color tab orange if errors, green if working correctly.
this.contextManager.addEventListener(new CollaboratorEventAdapter() {
@Override
public void onPollingResponseReceived(CollaboratorContext collaboratorContext, ArrayList<Interaction> interactions) {
burpTabController.setTabColor(Color.GREEN);
SwingUtilities.invokeLater(() -> burpTabController.setTabColor(new Color(60, 146, 38)));
}

@Override
public void onPollingFailure(CollaboratorContext collaboratorContext, String error) {
burpTabController.setTabColor(Color.ORANGE);
SwingUtilities.invokeLater(() -> burpTabController.setTabColor(Color.ORANGE));
}
});

Expand All @@ -138,7 +144,11 @@ public void onPollingFailure(CollaboratorContext collaboratorContext, String err
this.burpTabController = new BurpTabController(burpTabbedPane, this.ui.getUiComponent(), null, null);

//Start off the tab as red, until we've started up.
burpTabController.setTabColor(Color.RED);
if(UIManager.getLookAndFeel().getName().equalsIgnoreCase("darcula")) {
burpTabController.setTabColor(new Color(212, 60, 55));
}else{
burpTabController.setTabColor(new Color(220, 10, 19));
}

this.ui.addMenuItemsToBurp();
if(this.preferences.getSetting(PREF_AUTO_START)){
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static com.nccgroup.collaboratorplusplus.extension.Globals.*;

public class ConfigUI extends JPanel implements LogListener, IProxyServiceListener {
public class ConfigUI extends JPanel implements IProxyServiceListener {

private final CollaboratorPlusPlus extension;
private JToggleButton startStopButton;
Expand All @@ -36,8 +36,6 @@ public class ConfigUI extends JPanel implements LogListener, IProxyServiceListen
private JLabel statusLabel;
private JTextArea logArea;

private final static org.apache.logging.log4j.Logger logger = LogManager.getLogger(Globals.EXTENSION_NAME);

public ConfigUI(CollaboratorPlusPlus extension){
this.setLayout(new BorderLayout());
this.extension = extension;
Expand Down Expand Up @@ -221,51 +219,59 @@ public JPanel buildMainPanel(){

@Override
public void beforeStartup() {
startStopButton.setText("Starting...");
startStopButton.setEnabled(false);
startStopButton.setSelected(true);
SwingUtilities.invokeLater(() -> {
startStopButton.setText("Starting...");
startStopButton.setEnabled(false);
startStopButton.setSelected(true);

//Disable all other controls
enableControls(false);
//Disable all other controls
enableControls(false);
});
}

@Override
public void onStartupFail(String message) {
startStopButton.setText("Start");
startStopButton.setSelected(false);
startStopButton.setEnabled(true);
SwingUtilities.invokeLater(() -> {
startStopButton.setText("Start");
startStopButton.setSelected(false);
startStopButton.setEnabled(true);

//Enable all other controls
enableControls(true);
//Enable all other controls
enableControls(true);

statusLabel.setText("Status: Not Running");
statusLabel.setText("Status: Not Running");
});
}

@Override
public void onStartupSuccess(String message) {
startStopButton.setText("Stop");
startStopButton.setSelected(true);
statusLabel.setText("Status: Listening on port " + localPortSpinner.getValue());

//Disable all other controls
enableControls(false);
startStopButton.setEnabled(true);
this.revalidate();
this.repaint();
SwingUtilities.invokeLater(() -> {
startStopButton.setText("Stop");
startStopButton.setSelected(true);
statusLabel.setText("Status: Listening on port " + localPortSpinner.getValue());

//Disable all other controls
enableControls(false);
startStopButton.setEnabled(true);
this.revalidate();
this.repaint();
});
}

@Override
public void onShutdown() {
statusLabel.setText("Status: Not Running");

//Reenable other controls
//Disable all other controls
enableControls(true);
startStopButton.setEnabled(true);
startStopButton.setSelected(false);
startStopButton.setText("Start");
this.revalidate();
this.repaint();
SwingUtilities.invokeLater(() -> {
statusLabel.setText("Status: Not Running");

//Reenable other controls
//Disable all other controls
enableControls(true);
startStopButton.setEnabled(true);
startStopButton.setSelected(false);
startStopButton.setText("Start");
this.revalidate();
this.repaint();
});
}

private void enableControls(boolean enabled){
Expand All @@ -281,27 +287,4 @@ private void enableControls(boolean enabled){
enableAuthentication.setEnabled(enabled);
secretArea.setEnabled(enabled && enableAuthentication.isSelected());
}

@Override
public void onInfo(String message) {
if(logArea == null) return;
synchronized (logArea) {
logArea.append("INFO: " + message + "\n");
}
}

@Override
public void onError(String message) {
if(logArea == null) return;
synchronized (logArea) {
logArea.append("ERROR: " + message + "\n");
}
}

@Override
public void onDebug(String message) {
synchronized (logArea) {
logArea.append("DEBUG: " + message + "\n");
}
}
}

0 comments on commit a0bf3db

Please sign in to comment.