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

The following examples show how to use sun.misc.SharedSecrets#setJavaAWTAccess() . These examples are extracted from open source projects. 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
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 2
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
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 4
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 5
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
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 7
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 8
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 9
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 10
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
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 12
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 13
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 14
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
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
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
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
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
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
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);
    }

}