test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java

Print this page

        

*** 269,278 **** --- 269,283 ---- } } @Test public static void proxyStaticAccessCheckTest() throws ScriptException { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + final ScriptEngineManager m = new ScriptEngineManager(); final ScriptEngine e = m.getEngineByName("nashorn"); final Runnable r = (Runnable)Proxy.newProxyInstance( ScriptEngineTest.class.getClassLoader(), new Class[] { Runnable.class },
*** 295,300 **** --- 300,344 ---- if (! (exp instanceof SecurityException)) { fail("SecurityException expected, got " + exp); } } } + + + @Test + public void nashornConfigSecurityTest() { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + + final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); + try { + fac.getScriptEngine(new ClassFilter() { + @Override + public boolean exposeToScripts(final String name) { + return true; + } + }); + fail("SecurityException should have been thrown"); + } catch (final SecurityException exp) {} + } + + @Test + public void nashornConfigSecurityTest2() { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + + final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); + try { + fac.getScriptEngine(new String[0], null, new ClassFilter() { + @Override + public boolean exposeToScripts(final String name) { + return true; + } + }); + fail("SecurityException should have been thrown"); + } catch (final SecurityException exp) {} + } }