![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e212. Enabling the Security ManagerBy 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 e220 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
e214. Determining If One Permission Implies Another e215. Creating a Custom Permission e216. Controlling Access to an Object e217. Listing All Permissions Granted to a Loaded Class e218. Listing All Permissions Granted to Classes Loaded from a URL or Directory
© 2002 Addison-Wesley. |