The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.security  [30 examples] > Policy Files  [4 examples]

e222. Protecting System Properties

Access 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";
    };

 Related Examples
e219. Creating a New Policy File
e220. Managing Policy Files
e221. Protecting Files

See also: Key Store    Message Digests    Permissions    Public and Private Keys    Signatures   


© 2002 Addison-Wesley.