⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managecontrol.java

📁 sifi-0.1.6.tar.gz 出自http://www.ifi.unizh.ch/ikm/SINUS/firewall/ 一个linux的防火墙工具。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ----------------------------------------------------------------------   The SINUS Firewall -- a TCP/IP packet filter for Linux   Written within the SINUS project at the University of Zurich,   SWITCH, Telekurs Payserv AG, ETH Zurich.   originally based on the sf Firewall Software (C) 1996 by Robert   Muchsel and Roland Schmid.   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   SINUS Firewall resources:   SINUS Homepage: http://www.ifi.unizh.ch/ikm/SINUS/   Firewall Homepage: http://www.ifi.unizh.ch/ikm/SINUS/firewall.html   Frequently asked questions: http://www.ifi.unizh.ch/ikm/SINUS/sf_faq.html   Mailing list for comments, questions, bug reports: firewall@ifi.unizh.ch   ----------------------------------------------------------------------  */package sfclasses;import java.awt.*;import java.awt.event.*;import java.net.*;import java.applet.*;import java.util.*;import java.io.*;import com.sun.java.swing.*;/** * <b>Toplevel Frame of Remote Config Tool</b><br> * This class implements the main window of the control panel. The frame * is constructed when the user clicks on a button in the start page (see * sfRemote.java). It contains a drag and drop panel for the network * topology in the client area and provides access to all global  * configuration functions. * @version 1.0 12 Dec 1996 * @author Roland E. Schmid */public class ManageControl	extends Frame	implements ActionListener, ItemListener {  /**   * Initialize new main window<br>   * The window is set up and a new ManageDomain object is created   * holding the configuration data.   * @param titleString Initial window title   */  public ManageControl(String titleString) {    // window title bar		super(titleString);    if (titleString != null)      setTitle(titleString);    // create menus    mbar = new MenuBar();    FileMenu = new Menu("File");	 MenuItem FileMenu1, FileMenu2, FileMenu3, FileMenu4, FileMenu5, FileMenu6, FileMenu7;    FileMenu.add(FileMenu1 = new MenuItem("Load from Firewall"));    FileMenu.add(FileMenu2 = new MenuItem("Save to Firewalls"));    FileMenu.add(FileMenu3 = new MenuItem("Load from Local File"));    FileMenu.add(FileMenu4 = new MenuItem("Save to Local File"));    FileMenu.add(FileMenu5 = new MenuItem("Export Topology"));    FileMenu.add(FileMenu6 = new MenuItem("Close"));    FileMenu.addSeparator();    FileMenu.add(FileMenu7 = new MenuItem("Quit"));    mbar.add(FileMenu);    EditMenu = new Menu("Edit"); 	 MenuItem EditMenu1, EditMenu2, EditMenu3, EditMenu4, EditMenu5, EditMenu6;    EditMenu.add(EditMenu1 = new MenuItem("General"));    EditMenu.add(EditMenu2 = new MenuItem("Autoconfig"));    EditMenu.add(EditMenu3 = new MenuItem("Rules"));    EditMenu.add(EditMenu4 = new MenuItem("Notification Levels"));    EditMenu.add(EditMenu5 = new MenuItem("Macros"));    EditMenu.add(EditMenu6 = new MenuItem("Preferences"));    EditMenu.addSeparator();    EditMenu.add(TopologyCheckbox = new CheckboxMenuItem("Edit Topology", topologyEdit));    mbar.add(EditMenu);    ReportMenu = new Menu("Reports");	 MenuItem ReportMenu1;    ReportMenu.add(ReportMenu1 = new MenuItem("Configuration Report"));    mbar.add(ReportMenu);    HelpMenu = new Menu("Help");	 MenuItem HelpMenu1, HelpMenu2;    HelpMenu.add(HelpMenu1 = new MenuItem("User's Guide"));    HelpMenu.add(HelpMenu2 = new MenuItem("About"));    mbar.add(HelpMenu);    mbar.setHelpMenu(HelpMenu);    setMenuBar(mbar);	 // register to receive events	 FileMenu1.addActionListener(this);	 FileMenu2.addActionListener(this);	 FileMenu3.addActionListener(this);	 FileMenu4.addActionListener(this);	 FileMenu5.addActionListener(this);	 FileMenu6.addActionListener(this);	 FileMenu7.addActionListener(this);	 EditMenu1.addActionListener(this);	 EditMenu2.addActionListener(this);	 EditMenu3.addActionListener(this);	 EditMenu4.addActionListener(this);	 EditMenu5.addActionListener(this);	 EditMenu6.addActionListener(this);	 TopologyCheckbox.addItemListener(this);	// CheckBoxMenu generates itemEvents	 	 ReportMenu1.addActionListener(this);	 HelpMenu1.addActionListener(this);	 HelpMenu2.addActionListener(this);    // initialize data    //appletContext = ac;	 Communicator.parent = this;    if (titleString != null) {      byte host[] = Communicator.resolve(titleString);      ServerInputStream ris =         new ServerInputStream(host, this.custom.getProperty("CONF_DIR") + this.custom.getProperty("GLOBAL_CONFIG"));      if (ris.isEOF())        mgDomain = null;      else {				PersistentInputStream is = new PersistentInputStream(ris);				mgDomain = ManageDomain.loadDomainConfig(is);      }    }    else      mgDomain = new ManageDomain();    if (mgDomain == null) { // host is unreachable      prepareQuit();      return;     }    // create drag and drop panel    try {      hostClass = Class.forName("sfclasses.Host");      netClass = Class.forName("sfclasses.Net");      internetClass = Class.forName("sfclasses.Internet");    }    catch (ClassNotFoundException e) {      System.out.println("Fatal error: class Host, Net or Internet not found!");      terminated = true;      return;    }    drawClass = hostClass;    // create panels    ddPanel = new DragDrop(mgDomain.getTopology(), drawClass, topologyEdit);    Toolbar = new Panel();    Toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));    CheckboxGroup g = new CheckboxGroup();    Toolbar.add(hostBox = new Checkbox("Host", g, true));    Toolbar.add(netBox = new Checkbox("Net", g, false));    Toolbar.add(internetBox = new Checkbox("Internet", g, false));	 	hostBox.addItemListener(this);	 	netBox.addItemListener(this);	 	internetBox.addItemListener(this);    setLayout(new BorderLayout());    add("Center", ddPanel);    // set window title    if (mgDomain.DomainName.length() > 0)      setTitle(mgDomain.DomainName);    else      setTitle("Unnamed domain");		ddPanel.checkConsistency(); 		if (!(mgDomain.isConsistent())) 			UserDialog.ErrorBox("Topology inconsistent!");	 addWindowListener(new MCWAdapter());	 UserDialog.WelcomeBox();	 pack();	 validate();	 setSize(500, 350);	 setVisible(true);  }	// Our own Adapter because we only process windowClosing events  class MCWAdapter extends WindowAdapter {  	public void windowClosing(WindowEvent we) {      if (isEnabled())        prepareQuit();  	}  } // class MCWAdapter  public void actionPerformed(ActionEvent evt) {  	 String arg = (String)evt.getActionCommand();		// Process "Quit"      if (arg.equals("Quit")) {        prepareQuit();      }		// Process "Save to Firewalls"      else if (arg.equals("Save to Firewalls")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        SaveData sd = new SaveData(mgDomain, this, false, false);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        sd.start();        return;      }				// Process "Save to Local File"      else if (arg.equals("Save to Local File")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        SaveData sd = new SaveData(mgDomain, this, false, true);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        sd.start();        return;      }		// Process "Export Topology"			else if (arg.equals("Export Topology")) {				if (topologyEdit) {					UserDialog.ErrorBox("Function not available while editing the topology!");					return;				}        ExportData ed = new ExportData(this, mgDomain);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        ed.start();        return;			}		// Process "Load from Local File"      else if (arg.equals("Load from Local File")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        LoadData ld = new LoadData(mgDomain, this, LoadData.LOCAL);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        ld.start();        return;      }		// Process "Load from Firewall"      else if (arg.equals("Load from Firewall")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        LoadData ld = new LoadData(mgDomain, this, LoadData.REMOTE);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        ld.start();        return;      }		// Process "Close"      else if (arg.equals("Close")) {        LoadData ld = new LoadData(mgDomain, this, LoadData.NONE);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        ld.start();				Communicator.dispose();        return;      }		// Process "General"      else if (arg.equals("General")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        if (editRuleFrame != null && editRuleFrame.isShowing()) {          UserDialog.ErrorBox("Function not available while editing rules!");          return;        }        mgDomain.changed = true;        mgDomain.autoconfValid = false;        GeneralSettings gs;        if (mgDomain.DomainName.length() == 0)          gs = new GeneralSettings(this, "General Settings", mgDomain);        else          gs = new GeneralSettings(this, mgDomain.DomainName, mgDomain);        gs.show();        return;      }		// Process "Rules"      else if (arg.equals("Rules")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        mgDomain.changed = true;        if (editRuleFrame == null) {          editRuleFrame = new RuleEditor(mgDomain);          Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();          editRuleFrame.setSize(screensize.width/6*5, screensize.height/4*3);          editRuleFrame.setVisible(true);        }        else          editRuleFrame.showAgain();        if (!mgDomain.autoconfValid) {          UserDialog.WarningBox("Autoconfig not executed. Rules may not be valid.");        }        return;      }		// Process "Autoconfig"      else if (arg.equals("Autoconfig")) {        if (topologyEdit) {          UserDialog.ErrorBox("Function not available while editing the topology!");          return;        }        if (editRuleFrame != null && editRuleFrame.isShowing()) {          UserDialog.ErrorBox("Function not available while editing rules!");          return;        }        mgDomain.changed = true;        AutoconfThread at = new AutoconfThread(mgDomain, this);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        at.start();        return;      }		// Process "Notification Levels"      else if (arg.equals("Notification Levels")) {        NotificationSelect notificationSelect = new NotificationSelect(mgDomain, this);        notificationSelect.setVisible(true);        return;      }      else if (arg.equals("Macros")) {        MacroSelect macroSelect = new MacroSelect(mgDomain, this);        macroSelect.setVisible(true);        return;      }      else if (arg.equals("Preferences")) {				Preferences p = new Preferences();				p.setVisible(true);        return;      }		// Process "Configuration Report"      else if (arg.equals("Configuration Report")) {        ReportThread rt = new ReportThread(mgDomain, this, ReportThread.REPORT_CONFIG);        setEnabled(false);        setCursor(new Cursor(Cursor.WAIT_CURSOR));        rt.start();        return;      }		// Process "User's Guide"      else if (arg.equals("User's Guide")) {			UserDialog.NoticeBox("Documentation only available as a PostScript file.");      return;      }		// Process "About"      else if (arg.equals("About")) {								AboutDialog ad = new AboutDialog(this);				ad.setVisible(true);				return;      }	} // end actionPerformed	public void itemStateChanged(ItemEvent ie) {	String arg = (String)ie.getItem();		// Process "Edit Topology"     if (arg.equals("Edit Topology")) {        if (editRuleFrame != null && editRuleFrame.isShowing()) {          UserDialog.ErrorBox("Function not available while editing rules!");          topologyEdit = false;          TopologyCheckbox.setState(topologyEdit);          return;        }        topologyEdit = TopologyCheckbox.getState();        mgDomain.changed = true;        mgDomain.autoconfValid = false;        if (topologyEdit) {          ddPanel.enableEdit();          add("North", Toolbar);          validate();        }        else {          if (!ddPanel.disableEdit()) {            topologyEdit = true;            TopologyCheckbox.setState(topologyEdit);          }          remove(Toolbar);          mgDomain.topologyChanged();          validate();					if (mgDomain.isConsistent()) {          	UserDialog.NoticeBox("Run autoconfiguration now to update the rules!");					}					else {						UserDialog.ErrorBox("Topology is inconsistent. Please fix prior to running autoconfiguration!");					}        }        return;		}		// Process Checkbox "Host"		 else if (arg.equals("Host")) {			drawClass = hostClass;			ddPanel.setClass(drawClass);			return;		 }		// Process Checkbox "Net"		 else if (arg.equals("Net")) {			drawClass = netClass;			ddPanel.setClass(drawClass);			return;		 }		// Process Checkbox "Internet"		 else if (arg.equals("Internet")) {			drawClass = internetClass;			ddPanel.setClass(drawClass);			return;		 }	} 		// itemStateChanged  protected void prepareQuit() {    if (mgDomain != null && mgDomain.changed) {      SaveData sd = new SaveData(mgDomain, this, true, false);      setEnabled(false);      setCursor(new Cursor(Cursor.WAIT_CURSOR));      sd.start();      return;    }         /* cleanup stuff */    Communicator.dispose();		setVisible(false);    dispose();    ddPanel = null;    mgDomain = null;		System.exit(0);  }  protected void setManageDomain(ManageDomain newmd) {    remove(ddPanel);    ddPanel = new DragDrop(newmd.getTopology(), drawClass, topologyEdit);    add("Center", ddPanel);		ddPanel.checkConsistency();    validate();		if (!newmd.isConsistent()) {			UserDialog.ErrorBox("Topology is inconsistent!");		}    if (newmd.DomainName.length() > 0)      setTitle(newmd.DomainName);    else      setTitle("Unnamed domain");    mgDomain = newmd;  }  // public data  public boolean terminated = false;	public static Custom custom;  // private data  // gui data  private DragDrop ddPanel;  private MenuBar mbar;  private Menu FileMenu;  private Menu EditMenu;  private Menu ReportMenu;  private Menu HelpMenu;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -