SNMP Applet Server Enhancements


Interfaces

  1. Provided two new interfaces which can be implemented to add custom functionality as needed. Only one class of each interface type can be used - although the second will be instantiated for each session between SAS and an applet. The two allow for more flexibility in implementing SAS enhancements. The classes implementing the interfaces will be specified by command-line options. Classes will implement their own persistence.

    Interface SAServerClient: This is to allow instantiation of a custom class when the SAS is started, which will always be running. It's methods are the following:
    	public void init(String applet_dir,String webserver_rootDir);
    		This will be called when SAS starts.
    
    	public void initSession(InetAddress applet_addr, int applet_port);
    		This will be called when a new session is opened
    
    	public int open(int port);
    		This will be called when the client opens a UDP port.
    		Typically, the port is 0, which implies a system assigned
    		UDP port.  For exceptional cases, if listening for TRAP
    		or SNMP PDUs, a specific port can be specified.
    		The return value will be used, to allow for custom
    		port assignment if needed.
    
    	public SnmpPDU requestPDU(SnmpPDU pdu);
    		This is the PDU being sent to the agent, which can be modified
    		as required by the custom class.
    
    	public SnmpPDU responsePDU(SnmpPDU pdu);
    		This is the response PDU from the agent, which can be 
    		modified as required.
    	
    	public byte[] clientCall(byte data[]);
    		This is to allow the applet client to invoke a method
    		on the server.  A corresponding method will be
    		provided in the SASClient class.  Any arguments
    		and return values, will need to be serialized.
    
    	public void closeSession(InetAddress applet_addr, int applet_port);
    		This is called when an applet session is closed.
    


    Interface SASessionClient: This class will be instantiated for each session. This allows for doing custom functions for each applet session, e.g. caching data for an applet. This corresponds to an instance for each SASClient instance on the client.
    	public void init(InetAddress applet_addr, int applet_port);
    		This will be called when a new session is opened
    
    	public int open(int port);
    		This will be called when the client opens a UDP port.
    		Typically, the port is 0, which implies a system assigned
    		UDP port.  For exceptional cases, if listening for TRAP
    		or SNMP PDUs, a specific port can be specified.
    		The return value will be used, to allow for custom
    		port assignment if needed.
    
    	public SnmpPDU requestPDU(SnmpPDU pdu);
    		This is the PDU being sent to the agent, which can be modified
    		as required by the custom class.
    
    	public SnmpPDU responsePDU(SnmpPDU pdu);
    		This is the response PDU from the agent, which can be 
    		modified as required.
    	
    	public byte[] clientCall(byte data[]);
    		This is to allow the applet client to invoke a method
    		on the server.  A corresponding method will be
    		provided in the SASClient class.  Any arguments
    		and return values, will need to be serialized.
    
    	public void closeSession();
    		This is called when the session is closed.  The object will
    		be de-referenced and garbage collected after this, if
    		all of it's threads are stopped. 
    
  2. SAS and SASClient functionality was added for the following:
    Specify dir path (path can be specified in filename), create a directory
    delete a file.  Corresponding methods were added 
    to SASClient.
    	createDir(String dir)
    	  Creates a directory with specified relative or absolute path.
    	deleteDir(String dir)
    	Deletes a directory with specified relative or absolute path.
    	deleteFile(String file)
    	  Deletes a file with specified relative or absolute path.
    

NOTES:

  1. The SAServerClient and SASessionClient classes must support an empty constructor to allow instantiation by the SAS.
  2. For all callbacks where methods from both the SAServerClient and SASessionClient implementations are invoked, e.g. open(int port), the SAServerClient implementation is called first.
  3. To allow for controlling the number of SNMP clients, the return value of the open(int port) can be used. If the number returned is less than zero, a UDP port will not be opened, thus disabling SNMP communication from the applet. The sample program illustrates this.
  4. To minimize overhead when no PDU processing is done in the client programs, the SnmpPDU pre-processing and post-processing methods must call pdu.decode() to see the PDU data, and pdu.encode() to have any changes made in the PDU be effective.

USAGE INSTRUCTIONS:

To use the SAS enhancements the following is required in the server side and the client browser.

Server:
  1. Implement the SAServerClient and SASessionClient interfaces as reqired, and compile them. Sample implementations for testing are provided in the test sub-directory.
  2. Setup CLASSPATH to include the SAS classes, and the SAServerClient and SASessionClient implementation classes. Also include the Snmp classes in the CLASPATH. All the above can be placed in a single classes directory, as is done in this distribution, and the classes directory added to the CLASSPATH.
  3. Invoke the SAS, with the following options java advent.sas.SAServer -server_client TestSvrClient -session_client TestSsnClient -d applet_html_dir -webserver_root webServerRootDir. Replace TestSvrClient and TestSsnClient with your SAServerClient and SASessionClient implementation classes.

Please see the file sas.html in the docs directory for details on the other available SAS options.

Browser:
  1. Create the applet with the required functionality. See the files in the SasDemo directory as examples. For the new functionality available in SASClient, check the javadoc documentation in the docs directory.
  2. Place the applet on the web server, and make sure the codebase is correct. Start SAS as described above.
  3. Load the applet from the web server.


Java is a trademark of Sun Microsystems, Inc.

Netscape and Netscape Navigator are trademarks of Netscape Communications Corporation.