e222. protecting system properties.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 37 行

TXT
37
字号
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";
    };

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?