![]() |
The Java Developers Almanac 1.4 |
|
e222. Protecting System PropertiesAccess to system properties (System.getProperty()) is controlled
with a policy file (see e220 Managing Policy Files). Here are
examples of policy file entries for controlling access to system
properties.
// grant all classes loaded from h1.com ability to read the `myprop' system properties
grant codeBase "http://h1.com/-" {
permission java.util.PropertyPermission "myprop", "read";
};
// grant ability to write the `myprop' system properties
grant codeBase "http://h2.com/-" {
permission java.util.PropertyPermission "myprop", "write";
};
// grant ability to read and write the `myprop' system properties
grant codeBase "http://h3.com/-" {
permission java.util.PropertyPermission "myprop", "read,write";
};
// grant ability to read all properties that start with `myprops.'
grant codeBase "http://h4.com/-" {
permission java.util.PropertyPermission "myprops.*", "read";
};
// grant ability to read all system properties
grant codeBase "http://h5.com/-" {
permission java.util.PropertyPermission "*", "read";
};
// grant ability to write all system properties
grant codeBase "http://h6.com/-" {
permission java.util.PropertyPermission "*", "write";
};
// grant ability to read and write all system properties
grant codeBase "http://h7.com/-" {
permission java.util.PropertyPermission "*", "read,write";
};
e220. Managing Policy Files e221. Protecting Files
© 2002 Addison-Wesley. |