|
|
We
need to use the SecurityManger to make use of these policy files.
-
We can add System.setSecurityManager(new
SecurityManager()) to the public static void main(String args[])
method of our executable class.
-
Interestingly, this is also a case where a SecurityException can be thrown.
If a SecurityManager() is already installed, and the class is not permitted
to add a new SecurityManager, then the exception is thrown. This
is the java.lang.RuntimePermission createSecurityManager permission.
-
Alternatively, we can add another -D argument to our command line call
to start the class. Now our call may look like this:
java -Djava.security.manager -Djava.security.policy=application.policy
Application
-
Note that we do not need to assign this to anything, just state it with
the -D flag.
Making our Policy File
|