Enabling the Security Manager
By default, no security manager is enabled which means that all
security checks to protected resources and operations are disabled.
To enable security checks, the security manager must be enabled.
Once enabled, policy files determine the type of access an
entity has on a resource. For more details, see
Managing Policy Files.
This example enables the security manager.
The security manager can also be installed from the command line:
// Before the security manager is enabled, this call is possible
System.setProperty("java.version", "malicious data");
try {
// Enable the security manager
SecurityManager sm = new SecurityManager();
System.setSecurityManager(sm);
} catch (SecurityException se) {
// SecurityManager already set
}
// This call is no longer possible; an AccessControlException is thrown
System.setProperty("java.version", "malicious data");
> java -Djava.security.manager MyApp
Post a comment