Unbenannt.gif (2298 Byte)


Classes

This file gives you a short overview of the Java class files used by MC2. It is intended for Programmers who want to modifiy MC2 or for administrators who want to have a closer look.

It is divided into an overview part, a Listing of all classes, a brief description for every class and a section about the cgi scripts written in perl.

It is divided into an overview part, a Listing of all classes, a brief description for every class and a section about the cgi scripts written in perl.

You may want to see the Documentation created by javadoc as well.

Overview

A Word about Security

Class Files

Class Description

CGI

 

Overview The main task of MRTG Configuration Checker is to edit Cfg files of mrtg 2.x. I use the term Cfg file when I mean the config files mrtg uses, and CFG structure when I refer to an object of the CFG class, a data structure which holds the data of the Cfg files.
When the user starts this tool, she will see a window called the MC2 window. It is the main window of the tool.
First, the user opens a CFG -- either a Cfg file from the server or a device in the network. The user makes its choose in the OpenDialog. In both cases, MC2 calls the InputChannel, witch opens a connection to the cfgreader.pl CGI on the server.
The CGI reads either a Cfg file from the server disk, or starts cfgmaker to poll data from a network device.
The InputChannel then parses the data it became from the CGI and feeds it into a CFG data structure which it passes back to MC2.
In the list of the MC2 window are now the interfaces (targets) displayed. The user can now make all sorts of changes to the targets:


Edit Target
By double clicking a target in the list (or by hitting the Edit Target Button) an EditTarget Window opens. It displays the entries of the current target in text fields. The user can alter data, use the revert button to undo, and change between the targets using Left and Rigth Buttons.
After hitting OK, the changes will be saved to the MC2 CFG structure.

Copy Target
Makes a copy of the current target named "Copy_of_..."'

Delete Target
Delete a target after confirming a YesNoDialog

Import Target
Choose in the AddDialog (An OpenDialog) from a Cfg file or network device and import those interfaces without deleting the actual targets (use this if you want to make a new Cfg file with targets from more than one device).

Check Port
Often, the SNMP Port number of a interface may change, e. g. after a reconfiguration of a router. A click on the Check Port Button opens a LineDialog, where the community and hostname of the device can be specified. The CheckPort Window looks similar to the MC2 Window, it shows all interfaces of the device. The Port number can be updated easily: click on the Update Port Button, and the port number of the selcted target in MC2 will be replaced by the port number of the selected target in CheckPort.

Save Target
Finally, the CFG structure can be saved to a Cfg file on the server. The SaveDialog allows to choose a location on the server to save it.
Then, the Distiller is called to convert the CFG structure into a mrtg-readable Cfg file format. It sends it line by line to OutputChannel, which opens a connection to the cfgwriter CGI.
The CGI tests if the file exists already. If so, it puts the old file in a backup directory before overwriting it.

 

A Word about Security This tool allows anyone who has access to it change or delete your mrtg Cfg files. More, this tool has some CGI scripts which allow the user to browse the file system of the server machine and to (over)write any file the web server has permission to. So I recommend strongly:

1. USE THIS TOOL ONLY BEHIND A FIREWALL WHERE YOU CAN TRUST THE PEOPLE USING IT

2. LIMIT THE ACCESS TO THE TOOL AND ITS CGI BY WEB SERVER PASSWORDS

3. LIMIT THE ACCESS RIGHTS OF THE WEB SERVER TO THE DIRECTORIES NEEDED

4. USE IT ONLY WHEN YOU EXACTLY KNOW EVERY PERSON WHICH HAS ACCESS TO THE TOOL (AND WHICH YOU CAN TRUST).

5. SEE 1, 2, 3, 4 AND 5.

If you're not following this security tips, be aware of the risk you are taking.

Please see the security page as well.

 

Class Files AWTHelper.class
Cfg.class
CheckPort$MyCheckHandler.class
CheckPort$MyEditHandler.class
CheckPort$MyListSelectHandler.class
CheckPort$MyWindowHandler.class
CheckPort.class
ChooseDialog$FLList.class
ChooseDialog$IL.class
ChooseDialog.class
Distiller.class
EditTarget$CloseHandler.class
EditTarget$DialogCancel.class
EditTarget$DialogNo.class
EditTarget$DialogWindow.class
EditTarget$DialogYes.class
EditTarget$LeftHandler.class
EditTarget$RevertHandler.class
EditTarget$RightHandler.class
EditTarget$SaveHandler.class
EditTarget$WindowHandler.class
EditTarget$showInfo.class
EditTarget.class
InputChannel.class
LineDialog.class
MC2$Add1.class
MC2$CheckHandler.class
MC2$ChooseCancel.class
MC2$ChooseWindow.class
MC2$CloseNo.class
MC2$CloseYes.class
MC2$CopyHandler.class
MC2$CreateHandler.class
MC2$DeleteHandler.class
MC2$DeleteYes.class
MC2$EditHandler.class
MC2$GetHandler.class
MC2$ListSelectHandler.class
MC2$Open1.class
MC2$Save1.class
MC2$SaveHandler.class
MC2$WindowHandler.class
MC2$YesNoCancel.class
MC2$YesNoWindow.class
MC2$check.class
MC2$showInfo.class
MC2.class
MC2Applet.class
MultiLineLabel.class
OpenDialog.class
OutputChannel.class
SaveDialog.class
Target.class
WarnDialog.class
YesNoDialog.class

 

Class Description AWTHelper.class

Some methods used by the other classes for arranging components in a gridbag layout. It provides a warn dialog as well.

Cfg.class
Main data structure that holds an entire cfg file. It consists of many Target objects which contain one target entry of the cfg file each. This class holds the "global" entries for all targets (e. g. WorkDir, IconDir, URL, etc). It provides methods for reading and writing all entries in the target. This class should be used to access the data in the target instead of the Target methods directly.

CheckPort$MyCheckHandler.class
Inner Class of CheckPort. It implements an ActionListener for the Update Port Button. Its method is called when the user wants to upgrade the port number of a target.

CheckPort$MyCloseHandler.class
Inner class of CheckPort. It closes the CheckPort window after the user pressed the Close Button. It implements an ActionListener for the Close Button.

CheckPort$MyEditHandler.class
Inner class of CheckPort. It does the same thing as CheckPort$MyCheckHandler does, except that it implements an ActionListener for the list. The method of this class can be invoked by double clicking an item of the list.

CheckPort$MyListSelectHandler.class
Inner class of CheckPort. Implements an ItemListener for the list which handles the ListSelect Events.

CheckPort$MyWindowHandler.class
Inner class of CheckPort. Implements a WindowListener which looks for the CloseWindow Event. Click on the Close Box of the window, and you'll see this code closing the window.

CheckPort.class
Subclass of MC2. This class is responsible for the Check Port feature. It brings up a new Window named Check Port Window, which holds a new CFG data structure. The User can compare the SNMP Port numbers received newly from a device and update older ones of the CFG his working on.

ChooseDialog$FLList.class
Inner class of ChooseDialog. Implements a FocusListener. It looks if the List or the text field have the Focus, and adjusts the Button1 to "Save" or "Open".

ChooseDialog$IL.class
Inner class of ChooseDialog. The Implementation of the ItemListener for the list. It handles the ListSelect Events.

ChooseDialog.class
This is the super class of all choose dialogs (OpenDialog, SaveDialog, LineDialog). It opens a window and puts some components in it (Explanation label, List with directory contents, a textfield and so on). Its methods provide some basic functions like remove the last word of a string and communicating with Directory Reader CGI and the caller class.

Distiller.class
This class is responsible for putting the output together. Its basic task is to receive a CFG structure and convert it to the correspondent text lines, which then are sent to OutputChannel. It uses the OutputChannel class to open a connection to the cgi and to send it line by line.

EditTarget$CloseHandler.class
Inner class of EditTarget. An ActionListener Implementation which comes to action after the user clicked the Close Button. It asks the user if it should discard the edits (using a YesNoDialog). If the user clicks on "No" (which is actually the Yes Button -- sorry, implementation detail), it will be saved, "Yes" discards it, and "Cancel" closes the dialog and does nothing else. Responsible for those actions are the EditTarget$DialogYes, EditTarget$DialogNo and EditTarget$DialogCancel classes.

EditTarget$DialogCancel.class
Inner class of EditTarget. It closes the YesNoDialog asking if the user really likes to discard its changes. See above.

EditTarget$DialogNo.class
Inner class of EditTarget. If the user Hits the "Yes" Button, this class will discard the edits made in EditTarget and close the EditTarget window. Please Note that this class is called EditTarget$DialogNo, because it implements an ActionListener of the No Button, which is Labeled "Yes"... (This is because the YesNoDialog is used in other situations, and the logic of this dialog says that the default action (in this case, saving the changes) should start after clicking on the Yes Button).

EditTarget$DialogWindow.class
Inner class of EditTarget. Implements a Window Listener which does approximately the same as the EditTarget$CloseHandler class: It ask the user if he'd like to discard his changes. It is invoked by clicking the close box of the EditTarget Window.

EditTarget$DialogYes.class
Inner class of EditTarget. This implements an ActionListener for the Yes Button of the YesNoDialog used here to aks the user if he'd like to discard his edits. The method will save the changes of the targets made in EditTarget, which means it replaces the CFG structure of MC2 by the new one of EditTarget.
Note: The Yes Button is labeled "No", see above...

EditTarget$LeftHandler.class
Inner class of EditTarget. This implementation of an ActionLister for the Left Button allows to scroll one Target "left", which means one Target "up" in the MC2 list of targets. If the target entry was altered, the changes will be stored in the temporary CFG structure of EditTarget (they are not updated in the CFG of MC2 yet, this will happen after the user clicked the OK Button).

EditTarget$RevertHandler.class
Inner class of EditTarget. ActionListener for the Revert Button which is labeled "Reset". It will cause the temporary actual Target to be loaded newly, all changes in this target are lost.

EditTarget$RightHandler.class
Inner class of EditTarget. Does the same as the EditTarget$LeftHandler class, but to the right ("down") instead of left ("up").

EditTarget$SaveHandler.class
Inner class of EditTarget. Action Listener of the Save Button, which is labeled "OK". It was not labeled "Save" because it saves the changes to the CFG structure in MC2, but not to a file on the server disk. After the user clicked the Save Button, the method of this class will replace the old CFG structure in MC2 by the newly changed temporary CFG structure of EditTarget.

EditTarget$WindowHandler.class
Inner class of EditTarget. Does the same as EditTarget$CloseHandler, except that it's not an ActionListener for a button, but a WindowListener for the EditTarget window. Invoke this code by clicking the close box in EditTarget window.

EditTarget$showInfo.class
Inner class of EditTarget. It implements a MouseListener. If the mouse is moved over one of the components this listens to (all text fields and buttons), a help text will appear.

EditTarget.class
Big class invoked by MC2 to edit the targets of the currently loaded CFG structure. It copies the CFG structure of MC2 into its own temporary CFG structure, opens an EditTarget window with a text field for each entry. It is possible to scroll between the targets using the "Left" and "Right" buttons. If the window is closed, its inner classes will ask the user if he'd like to discard his edits or save them into the MC2 CFG structure ( = replace the MC2 CFG with the temporary CFG of EditTarget).

InputChannel.class
Opens a connection to the cfgreader.pl CGI, imports the data and feeds it into a CFG structure, which it gives back to MC2.

LineDialog.class
Subclass of ChooseDialog. A dialog which has only a textfield. It is called by CheckPort and in this case prompts the user to insert the community and hostname of a device whose ports are to be checked.

MC2$Add1.class
Inner class of MC2. It is an ActionListener for the Button1 of the Add Target Dialog. The Add Target Dialog is a OpenDialog where the user can specifiy a CFG or a device to be imported into the active CFG structure. This class calls InputChannel to import the targets and puts them into the currently active CFG of MC2 without replacing the existing targets.

MC2$CheckHandler.class
Inner class of MC2. This ActionListener listens to the CheckPort Button of MC2. It launches a LineDialog, which asks the user for the name of a device whose ports are to be checked (and proposes the active device). The dialog's buttons are controled by MC2$Check (Button1) and MC2$ChooseCancel (Button2).

MC2$ChooseCancel.class
Inner class of MC2. This ActionListener listens to all Button2's of all ChooseDialog's (OpenDialog, SaveDialog, LineDialog). It simply calls a method in the dialogs which causes them to close and dispose.

MC2$ChooseWindow.class
Inner class of MC2. Same story as MC2$ChooseCancel, except that it's a WindowListener Implementation that listens to the close box of the ChooseDialogs.

MC2$CloseNo.class
Inner class of MC2. ActionListener for the No Button of the YesNoDialog which asks the user if changes should be saved. If the No Button is clicked, a method of this class disposes the dialog and MC2, all changes are lost.

MC2$CloseYes.class
Inner class of MC2. ActionListener for the Yes Button of the YesNoDialog. It brings up a save dialog.

MC2$CopyHandler.class
Inner class of MC2. Makes a copy (a clone, a real copy of the object, not just a reference) of the active Target, names it "Copy_of_.." and prepends it to the CFG structure.

MC2$CreateHandler.class
Inner class of MC2. ActionListener for the CreateTarget Button, which is labeled "Import Targets". Brings up the AddTargetDialog, which allows to add more targets to the currently active CFG without deleting the actual ones.

MC2$DeleteHandler.class
Inner class of MC2. ActionListener to the DeleteTarget Button. Brings up a YesNoDialog named DeleteDialog which asks if the selected Target should be deleted (removed from the CFG structure).

MC2$DeleteYes.class
Inner class of MC2. ActionListener for the Yes Button of the DeleteDialog (see above). It deletes the current target (removes it from the CFG structure).

MC2$EditHandler.class
Inner class of MC2. ActionListener to the EditTarget Button. Instantiates an EditTarget Object and opens the EditTarget Window.

MC2$GetHandler.class
Inner class of MC2. Action Lister to the Get_CFG Button which opens an OpenDialog to open a CFG file.

MC2$ListSelectHandler.class
Inner class of MC2. ItemListener of the list. It handles the ListSelect Events.

MC2$Open1.class
Inner class of MC2. Action Listener to the Button1 of the Opendialog. It calls the InputChannel to open a CFg file.

MC2$Save1.class
Inner class of MC2. ActionListener for the Button1 of the SaveDialog. Calls a Distiller to save the current CFG structure of MC2 to a CFG file.

MC2$SaveHandler.class
Inner class of MC2. Action Listener for the Save Button. Opens a SaveDialog, which allows saving the current CFG structure.

MC2$WindowHandler.class
Inner class of MC2. WindowListener for the MC2 Window. If the close box is clicked, it opens a YesNoDialog which asks if the changes made to the CFG structure should be saved.

MC2$YesNoCancel.class
Inner class of MC2. ActionListener for the Cancel Button of all YesNoDialogs (DeleteDialog, CloseDialog). It causes the dialog to disappear.

MC2$YesNoWindow.class
Inner class of MC2. Same as MC2$YesNoCancel, except that it's a WindowListener which listens for a click into the close box.

MC2$check.class
Inner class of MC2. This ActionListener handles the Button1 of the LineDialog. It opens a CheckPort Window.

MC2$showInfo.class
Inner class of MC2. MouseListener for all text fields and buttons of the MC2 Window. If the mouse enters one of the components it listens to, a help text will appear.

MC2.class
This is the most important class. It opens a window, the MC2 Window, from which the user has access to all functions. Its primary data structure is a CFG structure, which holds the data of the Cfg file currently loaded. It has functions to load a Cfg, to save the Cfg, to add and delete targets, to copy targets and to check the port number of the selected targets. It has many inner classes which are responsible for all the Events generated by its user interface.

MC2Applet.class
This is the Applet loaded by the browser. Its primary job is to instantiate the MC2 class. the Applet provides a method to the other classes to read the parameters stored in the HTML file's PARAM tag.

MultiLineLabel.class
A Label which has multiple lines. It is used in the EditTarget class.

OpenDialog.class
Subclass of ChooseDialog. It is a dialog for opening Cfg files which allows browsing thrue the directories of the server (if the webserver has the correct access privileges). Its buttons are controlled by inner classes of the caller class.

OutputChannel.class
This class opens a connection to the cfgwriter.pl CGI, sends the data to it and receives the result code. It is called by Distiller.

SaveDialog.class
Subclass of ChooseDialog. It is a dialog which allows to choose a path in the directory structure of the server to save the Cfg file while browsing thrue the server's directories.

Target.class
Data structure which holds the values of one target. It provides some interfaces to read and write the data, however, you should use the methods of the CFG class to access the data. A Cfg object references to several Target objects.

WarnDialog.class
A simple dialog with an OK Button (that closes the dialog) which is used to display error messages.

YesNoDialog.class
A Dialog with a Yes, No and Cancel Button which is used for asking the user questions like "Quit without saving?". The Cancel Button forces the dialog to disappear, the Yes and No Buttons are controlled by inner classes of the caller class.

 

CGI MC2 consists also of 3 cgi scripts hacked in perl. They provide the server side tasks to the Java applet. The scripts are located in one of the web server's cgi directories (the URL of the scripts must be specified in the PARAM tag of the HTML file).
None of those scripts can tell if it is MC2 which calls them. One could call the scripts directly. So be aware of your security.

CAUTION: THOSE CGI SCRIPT CAN CAUSE A SECURITY BREAK IN THE WEB SERVER. SEE THE ENCLOSED FILE CONCERNING SECURITY.

cfgreader.pl

It reads a Cfg file from an URL given by the the Applet. It parses the file, sorts the entries and returns them to the applet. It can be invoked (for test purposes) by the command line as well.
cfgreader.pl can only read Cfg files because it has to parse them; other files which do not follow the Cfg syntax can not be read correctly and cfgreader.pl will produce garbage.


cfgwriter.pl

It is used to write a Cfg file to the server's disk. First, it checks if a file with the same URL as the file to be written exists. If so, it will be moved to a backup directory. Then, cfgwriter will write the new Cfg file. It will return a status report if it was successful.
cfgwriter.pl receives a file line by line. It can therefore write every kind of file which is in plain text format, even scripts. It may become a potential security risk for your server, if it is not protected behind a firewall.


directory_reader.pl

It reads the contents of a directory and gives it back line by line. It returns directories first, then files, alphabetically sorted.
It can not decide wether it is called by MC2 or by someone else; it may be possible for others to explore your file structure on the server.


Last updated: 07/16/98, by ibgm.