9.2.6.1 Implementing the HttpServerInterface
9.2.6.2 Modifying HTML Adaptor Code
9.2.6.3 Enabling SSL Support in Your Web Server
The AdventNet HTML Adaptor uses Tomcat 3.2.4 Web server by default. You can plug in any other Web server instead of the Tomcat server. This facility of plugging in a Web server has been enabled by providing the HttpServerInterface. All you have to do to plug in your own Web server is to perform the two steps given below:
Write a class that implements the HttpServerInterface
Modify the agent code to use your interface
These steps are discussed below in detail.
9.2.6.1 Implementing the HttpServerInterface
The interface for plugging in your Web server must perform the functions such as: starting, stopping, and restarting the server and setting the configuration file. The following methods from the HttpServerInterface must be implemented in the interface
you write:
startHttpServer
public void startHttpServer()
throws java.lang.Exception
Method to start the Web Server initially.
Throws:
java.lang.Exception - while error starting Web Server.
stopHttpServer
public void stopHttpServer()
throws java.lang.Exception
Stops the Web Server.
Throws:
java.lang.Exception - on error while stopping Web Server.
restartHttpServer
public void restartHttpServer()
throws java.lang.Exception
Restarts the Web Server.
Throws:
java.lang.Exception - while error trying to restart the Web Server.
setConfigFileName
public void setConfigFileName(java.lang.String configFileName)
Setter for the configuration file Name with location.
Parameters:
configFileName - The configuration file name with path.
getConfigFileName
public java.lang.String getConfigFileName()
Getter for the configFileName.
Returns:
The configuration file Name by which the Server is running.
The AdventNet HTML Adaptor uses HtmlAdaptorServerImpl, which is a default implementation of the HttpServerInterface.
9.2.6.2 Modifying HTML Adaptor Code
Once the class file implementing the HttpServerInterface is available, the agent code has to be modified to replace the default HtmlAdaptorServerImpl class with your implementation. The default HtmlAdaptorServerImpl class basically provides the means to specify and modify the configurations of the Web server and pass on the requests from the Web server to the HTML Adaptor API.
When you plug in your Web server, your interface must perform the same function of the default implementation. To replace HtmlAdaptorServerImpl with your implementation, change the code (shown in bold) in the registerAdventNetAdaptors() method of the
agent main file.
htmladaptor= new HtmlAdaptor();
htmladaptor.setParentDir(agentDir);
htmladaptor.registerAuthentication();
htmladaptor.addHttpServerInterface(new HtmlAdaptorServerImpl());
name = "Adaptors:type=HTMLAdaptor";
server.registerMBean(htmladaptor, new ObjectName(name));
htmladaptor.setLogFile("agentDir/jmxprojects/<projectname>/agent/bin/HtmlNotif.ser");
// you can specify your own log file name and directory
Here, isHtmlSSL is a boolean tag which specifies if authentication is enabled. isJarFile is a boolean tag that specifies if the configuration files are to be read from the jar.
9.2.6.3 Enabling SSL in your Webserver
In case you want to enable SSL in your Web server, you have to first get a SSLServerSocket. This can be done using the com.adventnet.agent.security.Httpssl class. This class has been built using the SunJSSE RI.
The com.adventnet.agent.security.Httpssl class also contains methods to set the SSL parameters such as: keystore name, keypassword, manager algorithm, trust store, trust store password, etc. These methods simplify your task of configuring the Web server for SSL.