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

📄 guardtest.java

📁 wendang for java. 124342423 432
💻 JAVA
字号:
package javasec.samples.ch05;

import java.security.*;

// This is a dummy class; it would usually be the object
// that we want to protect access to (e.g. a real payroll
// request would fall into that category).
class XYZPayrollRequest {}

public class GuardTest {
    public static void main(String args[]) {
        // Protect the given object by requiring the given
        // permission.
        GuardedObject go = new GuardedObject(new XYZPayrollRequest(),
                         new XYZPayrollPermission("sdo", "view"));
        try {
            Object o = go.getObject();
            System.out.println("Got access to object");
        } catch (AccessControlException ace) {
            System.out.println("Can't access object");
        }
    }
}

⌨️ 快捷键说明

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