Package javax.script

Examples of javax.script.ScriptEngine.eval()


        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        ScriptEngine engine = getEngine(overlord);

        try {
            engine.eval("java.lang.System.setProperty('java.naming.factory.url.pkgs', 'counterfeit');");
        } catch (ScriptException e) {
            Assert.assertTrue(
                e.getMessage().contains(
                    "access denied (\"java.util.PropertyPermission\" \"java.naming.factory.url.pkgs\" \"write\")"),
                "The script shouldn't have write access to the system properties.");
View Full Code Here


    public void testEjbsAccessibleThroughLocalClient() throws ScriptException, IOException {
        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        ScriptEngine engine = getEngine(overlord);

        engine.eval("SubjectManager.getSubjectByName('rhqadmin');");
    }

    public void testLocalEjbsInaccessibleThroughJndiLookup() throws ScriptException, IOException {
        Subject overlord = LookupUtil.getSubjectManager().getOverlord();
View Full Code Here

            + SystemManagerBean.class.getSimpleName()
            + "!"
            + SystemManagerBean.class.getName().replace("Bean", "Local");

        try {
            engine.eval(""
                + "var ctx = new javax.naming.InitialContext();\n"
                + "var systemManager = ctx.lookup('"
                + jndiName
                + "');\n"
                + "systemManager.isDebugModeEnabled();");
View Full Code Here

            + SystemManagerBean.class.getSimpleName()
            + "!"
            + SystemManagerBean.class.getName().replace("Bean", "Local");

        try {
            engine.eval(""
                + "var env = new java.util.Hashtable();\n"
                + "env.put('"
                + Context.URL_PKG_PREFIXES
                + "', 'org.jboss.as.naming.interfaces');\n"
                + "var ctx = new javax.naming.InitialContext(env);\n"
View Full Code Here

            + SystemManagerBean.class.getSimpleName()
            + "!"
            + SystemManagerBean.class.getName().replace("Bean", "Remote");

        try {
            engine.eval(""
                + "var ctx = new javax.naming.InitialContext();\n"
                + "var systemManager = ctx.lookup('"
                + jndiName
                + "');\n"
                + "systemManager.getSystemSettings(subject);");
View Full Code Here

            public void testInvoke(String methodCall) throws ScriptException {
                String code = sessionManager + methodCall;

                try {
                    engine.eval(code);
                    failIfSecurityManagerEnabled("The script shouldn't have been able to call a method on a SessionManager: "
                        + methodCall);
                } catch (ScriptException e) {
                    checkIsDesiredSecurityException(e);
                }
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        ScriptEngine engine = getEngine(overlord);

        try {
            engine.eval(""
                + "var ctx = new javax.naming.InitialContext();\n"
                + "var datasource = ctx.lookup('" + RHQConstants.DATASOURCE_JNDI_NAME + "');\n"
                + "con = datasource.getConnection();");

            failIfSecurityManagerEnabled("The script shouldn't have been able to obtain the datasource from the JNDI.");
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        ScriptEngine engine = getEngine(overlord);

        try {
            engine.eval(""
                + "var ctx = new javax.naming.InitialContext();\n"
                + "var entityManagerFactory = ctx.lookup('" + RHQConstants.ENTITY_MANAGER_JNDI_NAME + "');\n"
                + "var entityManager = entityManagerFactory.createEntityManager();\n"
                + "entityManager.find(java.lang.Class.forName('org.rhq.core.domain.resource.Resource'), java.lang.Integer.valueOf('10001'));");
View Full Code Here

            checkIsDesiredSecurityException(e);
        }

        //try harder with manually specifying the initial context factory
        try {
            engine.eval(""
                + "var env = new java.util.Hashtable();"
                + "env.put('java.naming.factory.initial', 'org.jboss.as.naming.InitialContextFactory');"
                //+ "env.put('java.naming.factory.url.pkgs', 'org.jboss.naming:org.jnp.interfaces');"
                + "var ctx = new javax.naming.InitialContext(env);\n"
                + "var entityManagerFactory = ctx.lookup('" + RHQConstants.ENTITY_MANAGER_JNDI_NAME + "');\n"
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        ScriptEngine engine = getEngine(overlord);

        try {
            engine.eval("var resource = ProxyFactory.getResource(10001);");
        } catch (ScriptException e) {
            //if the script fails (there is no resource with ID 10001)
            //it should not be because of an access control exception
            checkIsNotASecurityException(e);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.