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.

// 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");
The security manager can also be installed from the command line:
> java -Djava.security.manager MyApp

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.