The ContextClient and ContextAgent applications in he examplesDir/Context directory also demonstrate the use of stackable MBean servers and context checking through the HTTP connector.
If you have not done so already, compile all files in this directory with the javac command. For example, on the Solaris platform with the Korn shell, you would type:
$ cd examplesDir/Context/ $ javac -classpath classpath *.java |
If the agent and client applications are not already running from the previous example, type the following commands in separate windows:
$ java -classpath classpath ContextAgent |
$ java -classpath classpath ContextClient |
The classpath should include the current directory (.) for both applications because they rely on classes that were compiled in this directory.
Press <Enter> in the client application to trigger another set of requests.
The agent window displays the output of the ContextChecker class. We can see that the checkAny method verifies the "nice" context of every request and that the other checkers just print out their name, providing a trace of the request.
Stop both applications by typing <Control-C> in each of the windows.Restart both applications, but specify a different context string for the client:
$ java -classpath classpath ContextAgent |
$ java -classpath classpath ContextClient -context BadToTheBone |
This time we see the result of a context that is not recognized. The agent raises a java.lang.SecurityException which is propagated to the client who then exits.
Press <Control-C> in the agent window to stop the ContextAgent application.