📄 notification.java
字号:
/* ---------------------------------------------------------------------- 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.util.*;import java.io.*;/** * This class implements notification levels. An object of this * class holds all information about level. The static parts of * the class take care of the level vectors and of static levels. * Static levels are stored in the vector <i>staticLevels</i> and are * inserted into that vector in a static initializer. Dynamic levels * are stored in a vector in the ManageDomain class. * @version 1.0 03 Dec 1996 * @author Roland E. Schmid */public class Notification implements Persistent { /** * Initialize empty level. This is used when loading data from a * persistent input stream. */ protected Notification() { } /** * Initialize level. * @param number Level number */ public Notification(int number) { levelNumber = number; } /** * Open a dialog to edit the notification level. * @param co Calling object, will be notified when the edit dialog is closed. * @param p Parent frame * @param md ManageDomain object holding the configuration data * @param newLevel The level is being created and not changed. If the user * cancels the operation, the level will be deleted from the vector. * @see Refreshable */ public void edit(Refreshable co, Frame p, ManageDomain md, boolean newLevel) { NotificationDialog nd = new NotificationDialog(co, p, this, md, newLevel); nd.setVisible(true); if (levelNumber < firstDynamic) UserDialog.WarningBox("Static notification level. Changes will not be saved!"); } /** * Print the notification level in configuration file format * @param ps PrintWriter to write the output to */ public void printLevel(PrintWriter ps) { ps.println("level "+levelNumber+": /* "+levelName+" */"); ps.println(levelText); ps.println(); } // persistence /** * Write object data to a persistent output stream * @param ps Stream * @see PersistentOutputStream */ public void write(PersistentOutputStream ps) { ps.writeInt("Level=", levelNumber); ps.writeString("levelName=", levelName); ps.writeString("levelText=", levelText); } /** * Read object data from a persistent input stream * @param ps Stream * @see PersistentInputStream */ public void read(PersistentInputStream ps) throws java.io.IOException { levelNumber = ps.readInt("Level="); levelName = ps.readString("levelName="); levelText = ps.readString("levelText="); } protected String levelText = new String(); protected int levelNumber; protected String levelName = new String(); // static structures // ================= /** * @param number number of notification level * @return notification level */ public static Notification staticLevel(int number) { Enumeration en = staticLevels.elements(); Notification n; while (en.hasMoreElements()) { n = (Notification)en.nextElement(); if (n.levelNumber == number) return n; } return null; } /** * @param name name of notification level * @return notification level */ public static Notification staticLevel(String name) { Enumeration en = staticLevels.elements(); Notification n; while (en.hasMoreElements()) { n = (Notification)en.nextElement(); if (n.levelName.equals(name)) return n; } return null; } public static Notification getLevel(String name, Vector dynLevels) { Notification n = staticLevel(name); if (n == null) { Enumeration en = dynLevels.elements(); while (en.hasMoreElements()) { n = (Notification)en.nextElement(); if (n.levelName.equals(name)) return n; } } else return n; return null; } public static Notification getLevel(int number, Vector dynLevels) { Notification n = staticLevel(number); if (n == null) { Enumeration en = dynLevels.elements(); while (en.hasMoreElements()) { n = (Notification)en.nextElement(); if (n.levelNumber == number) return n; } } else return n; return null; } public static void constructList(List l, Vector dynLevels, int levelnum) { Enumeration en = staticLevels.elements(); Notification n; while (en.hasMoreElements()) { n = (Notification)en.nextElement(); l.add(n.levelName); if (n.levelNumber == levelnum) { l.select(l.getItemCount()-1); l.makeVisible(l.getItemCount()-1); } } en = dynLevels.elements(); while (en.hasMoreElements()) { n = (Notification)en.nextElement(); l.add(n.levelName); if (n.levelNumber == levelnum) { l.select(l.getItemCount()-1); l.makeVisible(l.getItemCount()-1); } } } public static void constructList(List l, Vector dynLevels) { constructList(l, dynLevels, 0); } public static void printAllLevels(PrintWriter ps, Vector dynLevels) { Enumeration en = staticLevels.elements(); Notification n; while (en.hasMoreElements()) { n = (Notification)en.nextElement(); n.printLevel(ps); } en = dynLevels.elements(); while (en.hasMoreElements()) { n = (Notification)en.nextElement(); n.printLevel(ps); } } public static final int STATIC_SOURCEROUTE = 1; public static final int STATIC_SERVER = 10; public static final int STATIC_IDENT = 11; public static final int STATIC_TRACEROUTE = 12; public static final int STATIC_OUTGOING = 13; public static final int STATIC_PING = 14; public static final int STATIC_ICMP = 15; public static final int STATIC_OVERLOAD = 95; public static final int STATIC_CHKPORTSCAN = 96; public static final int STATIC_CHECKSATAN = 97; public static final int STATIC_LOGATTACK = 98; public static final int STATIC_CHECKATTACK = 99; public static Vector staticLevels = new Vector(10,10); public static final int firstDynamic = 100; // level number of first dynamic level/* This is a copy-paste template for creating new static levels:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -