Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 11. Security[ Fast Forward ][ Next ]

Running an Agent

Java Dynamic Management agents can be run with or without the security protection given by JavaŽ 2 SDK. In the same way as the Java virtual machine, the Java Dynamic Management Kit runs with security enabled (checking for access rights), only if a security manager is installed.

Running an Agent without a Security Manager

In certain applications where security is not required, the agent must be run without instantiating a security manager, using the following command:
prompt% java MyAgent

Running an Agent with a Security Manager

When you want an agent to run with security checks, you must first define a set of permissions which will be granted to locations from which the agent will load code. The access permissions determine the rights given to the sources from which an agent is permitted to receive code. Access permissions are granted in a policy file, which is created using the policytool supplied with JavaŽ 2 SDK. After the access permissions have been granted, the agent must then be run, instantiating a security manager. The security manager can be instantiated either in the agent code or at the command line when starting the agent. The example below shows the security manager being instantiated at the command line.
prompt% java -Djava.security.manager MyAgent

Example 11-1 shows the security manager being instantiated in the application code.

Example 11-1. Instantiating a Security Manager in Application Code
System.setSecurityManager(new java.lang.SecurityManager());


[ Previous ][ Home ][ Next ]
Security[ Up ]Extended Permissions