jdk.nashorn.api.scripting.ClassFilter Java Examples
The following examples show how to use
jdk.nashorn.api.scripting.ClassFilter.
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: ScriptEngineSecurityTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #2
Source File: TrustedScriptEngineTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #3
Source File: ScriptEngineSecurityTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #4
Source File: ScriptEngineSecurityTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #5
Source File: TrustedScriptEngineTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #6
Source File: ScriptEngineSecurityTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #7
Source File: ScriptEngineSecurityTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #8
Source File: TrustedScriptEngineTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #9
Source File: TrustedScriptEngineTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #10
Source File: ScriptEngineSecurityTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #11
Source File: ScriptEngineSecurityTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #12
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #13
Source File: TrustedScriptEngineTest.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #14
Source File: ScriptEngineSecurityTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #15
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #16
Source File: ScriptEngineSecurityTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #17
Source File: TrustedScriptEngineTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #18
Source File: TrustedScriptEngineTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #19
Source File: TrustedScriptEngineTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #20
Source File: ScriptEngineSecurityTest.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #21
Source File: ScriptEngineSecurityTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #22
Source File: ScriptEngineSecurityTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #23
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest2() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(), new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #24
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void classFilterTest() throws ScriptException { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); final ScriptEngine e = fac.getScriptEngine(new ClassFilter() { @Override public boolean exposeToScripts(final String fullName) { // don't allow anything that is not "java." return fullName.startsWith("java."); } }); assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object"); assertEquals(e.eval("typeof java.util.Vector"), "function"); try { e.eval("Java.type('javax.script.ScriptContext')"); fail("should not reach here"); } catch (final ScriptException | RuntimeException se) { if (! (se.getCause() instanceof ClassNotFoundException)) { fail("ClassNotFoundException expected"); } } }
Example #25
Source File: ScriptEngineSecurityTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #26
Source File: ScriptEngineSecurityTest.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@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 e) { //empty } }
Example #27
Source File: TrustedScriptEngineTest.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Test public void nullClassFilterTest() { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); try { fac.getScriptEngine((ClassFilter)null); fail("should have thrown NPE"); } catch (final NullPointerException e) { //empty } }
Example #28
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void nullClassFilterTest() { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); try { fac.getScriptEngine((ClassFilter)null); fail("should have thrown NPE"); } catch (final NullPointerException e) { //empty } }
Example #29
Source File: ClassFilterTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static ClassFilter getClassFilter() { return new ClassFilter() { @Override public boolean exposeToScripts(final String s) { return true; } }; }
Example #30
Source File: TrustedScriptEngineTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void nullClassFilterTest() { final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); try { fac.getScriptEngine((ClassFilter)null); fail("should have thrown NPE"); } catch (final NullPointerException e) { //empty } }