文档

Java™ 教程-Java Tutorials 中文版
设置策略文件以授予所需权限
Trail: Security Features in Java SE
Lesson: Quick Tour of Controlling Applications

设置策略文件以授予所需权限

This step uses the Policy Tool utility to open the policy file named examplepolicy created in the Creating a Policy File lesson. You will add a new policy entry granting permission for code from the directory where GetProps.class is stored to read the "user.home" and the "java.home" property values, as shown in the following figure.

The examplepolicy policy file grants WriteFile and GetProps the permissions they need

The steps are as follows.

  1. 打开策略文件
  2. 授予所需权限
  3. 保存策略文件

Note for UNIX Users: The instructions illustrate creating the policy file for a Windows system. The steps are exactly the same if you are working on a UNIX system, with the following differences.
  • You retrieve the examplepolicy file from the test directory in your home directory.
  • For the CodeBase URL in the step for granting the required permissions, you can substitute file:${user.home}/test/ for file:/C:/Test/. Alternatively you could directly specify your home directory rather than referring to the "user.home" property, as in file:/home/jones/test/.


Previous page: See How to Restrict Applications
Next page: Open the Policy File