⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e221. protecting files.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
Access to files is controlled with a policy file (see e220 Managing Policy Files). Here are examples of policy file entries for controlling access to the system. 
    // grant all classes loaded from h1.com ability to read \temp\myfile
    grant codeBase "http://h1.com/-" {
        permission java.io.FilePermission "c:\\temp\\myfile", "read";
    };
    
    // grant ability to create and write c:\temp\myfile
    // Note: if \temp\myfile does not exist, it could be created as a directory
    grant codeBase "http://h2.com/-" {
        permission java.io.FilePermission "c:\\temp\\myfile", "write";
    };
    
    // grant ability to list files in the user's home directory
    grant codeBase "http://h3.com/-" {
        permission java.io.FilePermission "${user.home}", "read";
    };
    
    // grant ability to read any file or directory under c:\temp
    // Note: does not grant ability to read c:\temp itself, i.e. no permission
    // to call File.list() on c:\temp
    grant codeBase "http://h4.com/-" {
        permission java.io.FilePermission "c:\\temp\\-", "read";
    };
    
    // grant ability to delete any file or directory in c:\temp\mydir
    // Note: does not grant ability to delete c:\temp\mydir itself
    grant codeBase "http://h5.com/*" {
        permission java.io.FilePermission "c:\\temp\\mydir\*", "delete";
    };
    
    // grant ability to execute (see Runtime.exec()) the file c:\java.exe
    grant codeBase "http://h6.com/-" {
        permission java.io.FilePermission "c:\\java.exe", "execute";
    };
    
    // grant ability to read and write any file in current directory
    // Note: this is equivalent to ${user.dir}/*
    grant codeBase "http://h7.com/-" {
        permission java.io.FilePermission "*", "read,write";
    };
    
    // grant ability to read any file under current directory
    // Note: this is equivalent to ${user.dir}/-
    grant codeBase "http://h8.com/-" {
        permission java.io.FilePermission "-", "read";
    };
    
    // grant ability to read any file
    grant codeBase "http://h9.com/-" {
        permission java.io.FilePermission "<<ALL FILES>>", "read";
    };

⌨️ 快捷键说明

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