Java Code Examples for sun.misc.SharedSecrets#setJavaAWTAccess()

The following examples show how to use sun.misc.SharedSecrets#setJavaAWTAccess() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAppletLoggerContext.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 2
Source File: TestAppletLoggerContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 3
Source File: TestAppletLoggerContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 4
Source File: RootLevelInConfigFile.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 5
Source File: RootLevelInConfigFile.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 6
Source File: TestAppletLoggerContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 7
Source File: RootLevelInConfigFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 8
Source File: TestAppletLoggerContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 9
Source File: RootLevelInConfigFile.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 10
Source File: RootLevelInConfigFile.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 11
Source File: TestAppletLoggerContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
Example 12
Source File: RootLevelInConfigFile.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 13
Source File: RootLevelInConfigFile.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    System.setProperty(CONFIG_FILE_KEY,
            new File(System.getProperty("test.src", "."),
                    "rootlogger.properties").getAbsolutePath());
    System.out.println(CONFIG_FILE_KEY + "="
            + System.getProperty(CONFIG_FILE_KEY));
    if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
        throw new RuntimeException("can't read config file: "
                + System.getProperty(CONFIG_FILE_KEY));
    }

    final String configFile = System.getProperty(CONFIG_FILE_KEY);

    test("no security");

    LogManager.getLogManager().readConfiguration();

    Policy.setPolicy(new SimplePolicy(configFile));
    System.setSecurityManager(new SecurityManager());

    test("security");

    LogManager.getLogManager().readConfiguration();

    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);

    test("security and no context");

    for (Context ctx : Context.values()) {

        LogManager.getLogManager().readConfiguration();

        access.setContext(ctx);

        test("security and context " + ctx);
    }
}
 
Example 14
Source File: TestGetLoggerNPE.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 15
Source File: TestGetLoggerNPE.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 16
Source File: TestGetLoggerNPE.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 17
Source File: TestGetLoggerNPE.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 18
Source File: TestGetLoggerNPE.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 19
Source File: TestGetLoggerNPE.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}
 
Example 20
Source File: TestGetLoggerNPE.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    final String testCase = args.length == 0 ? "getLogger" : args[0];
    final JavaAWTAccessStub access = new JavaAWTAccessStub();
    SharedSecrets.setJavaAWTAccess(access);
    final ThreadGroup tg = new ThreadGroup("TestGroup");
    Thread t = new Thread(tg, "test") {
        public void run() {
            try {
                access.setContext(Context.ONE);
                final PrintStream out = System.out;
                System.setOut(null);
                try {
                    if ("getLogger".equals(testCase)) {
                       Logger.getLogger("sun.plugin");
                    } else {
                       LogManager.getLogManager();
                    }
                } finally {
                    System.setOut(out);
                }

                System.out.println(Logger.global);
            } catch (Throwable x) {
                x.printStackTrace();
                thrown = x;
            }
        }
    };
    Policy.setPolicy(new Policy() {
         public boolean implies(ProtectionDomain domain,
                                Permission permission) {
             return true; // all permissions
         }
    });
    System.setSecurityManager(new SecurityManager());
    t.start();
    t.join();
    if (thrown == null) {
        System.out.println("PASSED: " + testCase);
    } else {
        System.err.println("FAILED: " + testCase);
        throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
    }

}