modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardScriptPermissions.java
| 6
modules/enterprise/server/client-api/pom.xml
| 333 +++++++++-
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClientProxy.java
| 4
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessInterceptor.java
| 45 -
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessPermission.java
| 36 -
modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/security/test/EjbAccessTest.java
| 175 +++++
modules/enterprise/server/client-api/src/test/resources/META-INF/ejb-jar.xml
| 34 +
modules/enterprise/server/client-api/src/test/resources/META-INF/jboss.xml
| 168 +++++
modules/enterprise/server/client-api/src/test/resources/hibernate.properties
| 26
modules/enterprise/server/client-api/src/test/resources/jms-ra.rar
|binary
modules/enterprise/server/client-api/src/test/resources/security.policy
| 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
| 36 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessInterceptor.java
| 46 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessPermission.java
| 36 +
modules/enterprise/server/jar/src/main/resources/META-INF/ejb-jar.xml
| 2
15 files changed, 860 insertions(+), 97 deletions(-)
New commits:
commit ca4757776c008f12a053c816d7b9cf8c6a310596
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Dec 10 01:19:40 2011 +0100
Adding EjbAccessTest to make sure the CLI scripts can access the business
layer only through the designated interface. No direct local or remote
EJB access is possible.
diff --git
a/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardScriptPermissions.java
b/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardScriptPermissions.java
index 894c953..5822d44 100644
---
a/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardScriptPermissions.java
+++
b/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardScriptPermissions.java
@@ -20,6 +20,7 @@
package org.rhq.bindings;
import java.io.FilePermission;
+import java.io.SerializablePermission;
import java.lang.reflect.ReflectPermission;
import java.net.SocketPermission;
import java.security.Permission;
@@ -83,6 +84,11 @@ public class StandardScriptPermissions extends PermissionCollection {
add(new PropertyPermission("*", "read"));
add(new ReflectPermission("suppressAccessChecks"));
+
+ //these 2 are required for server-side scripts to be able to
+ //invoke remote EJBs.
+ add(new SerializablePermission("enableSubclassImplementation"));
+ add(new RuntimePermission("reflectionFactoryAccess"));
}
public void add(Permission permission) {
diff --git a/modules/enterprise/server/client-api/pom.xml
b/modules/enterprise/server/client-api/pom.xml
index b125b3b..6932b60 100644
--- a/modules/enterprise/server/client-api/pom.xml
+++ b/modules/enterprise/server/client-api/pom.xml
@@ -17,9 +17,28 @@
<properties>
<persistence-api.version>1.0</persistence-api.version>
+ <rhq.server.datasource>java:/RHQDS</rhq.server.datasource>
+ <rhq.server.ds-mapping>PostgreSQL</rhq.server.ds-mapping>
+
+ <!-- dependency versions -->
+
<jboss-embeddable-ejb3.version>1.0.0.Alpha9</jboss-embeddable-ejb3.version>
+
+ <clean.db>true</clean.db>
</properties>
<dependencies>
+
+ <!-- Note, the test deps are intentionally placed above the other scoped deps
because of classpath
+ reasons. Maven orders the [test] classpath in the order listed in the pom.
We specifically
+ need the embeddable-ejb3 jar above the standard ejb3 jars because we need the
embeddble packages
+ loaded when testing. -->
+ <dependency>
+ <groupId>jboss.jboss-embeddable-ejb3</groupId>
+ <artifactId>jboss-ejb3-all</artifactId>
+ <version>${jboss-embeddable-ejb3.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-script-bindings</artifactId>
@@ -48,21 +67,319 @@
<!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
-
+
+ <!-- Test deps - this insane list of deps is needed to get the embedded JBoss
server with RHQ server deployed running -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>hibernate-entitymanager</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
+ <!-- The Sun javamail jar isn't available from a public repo due to
licensing issues,
+ so use the Geronimo one instead. -->
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz-oracle</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-annotations-ejb3</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <!-- includes the org.jboss.ejb3.StrictMaxPool class, which is needed by the
PoolClass annotation used on some
+ of our SLSB's -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbosssx</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>3.1.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>2.7.7</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>trove</groupId>
+ <artifactId>trove</artifactId>
+ <version>1.0.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- for the transaction interrupt EJB3 interceptor -->
+ <dependency>
+ <groupId>org.jboss.transaction</groupId>
+ <artifactId>jboss-jta</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
section. -->
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>5.5.20</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>tomcat-jk</artifactId>
+ <version>4.1.31</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Needed by com.jboss.jbossnetwork.apl.actions.xml.XPathProcessor; TODO:
Remove once APL has been excised. -->
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.29</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jettison-provider</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-links</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <version>2.0.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.18</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+
<plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
-
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <!-- <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine> -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- Everything but the web service tests, this is the standard test
execution -->
+ <configuration>
+
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <groups>${rhq.testng.includedGroups}</groups>
+ <systemPropertyVariables>
+ <embeddedDeployment>true</embeddedDeployment>
+
<deploymentDirectory>target/test-classes</deploymentDirectory>
+
<hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <clean.db>${clean.db}</clean.db>
+ </systemPropertyVariables>
+ <argLine>-Djava.security.manager
-Djava.security.policy==target/test-classes/security.policy</argLine>
+ <additionalClasspathElements>
+ <!-- The below is required for tests to run against Oracle.
-->
+
<additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
</configuration>
- </plugin>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
+ <!-- in order to get JMS to work properly in embedded test container,
extract jms-rs.rar classes -->
+ <execution>
+ <id>Extract JMS classes from RAR needed for JMS tests</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <unzip src="src/test/resources/jms-ra.rar"
dest="target">
+ <patternset>
+ <include name="jms-ra.jar"/>
+ </patternset>
+ </unzip>
+ <unzip src="target/jms-ra.jar"
dest="target/test-classes">
+ <patternset>
+ <include name="org/**"/>
+ </patternset>
+ </unzip>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git
a/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/security/test/EjbAccessTest.java
b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/security/test/EjbAccessTest.java
new file mode 100644
index 0000000..9c9d1bb
--- /dev/null
+++
b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/security/test/EjbAccessTest.java
@@ -0,0 +1,175 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.client.security.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.SerializablePermission;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.PermissionCollection;
+import java.util.Collections;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.rhq.bindings.SandboxedScriptEngine;
+import org.rhq.bindings.ScriptEngineFactory;
+import org.rhq.bindings.StandardBindings;
+import org.rhq.bindings.StandardScriptPermissions;
+import org.rhq.bindings.util.PackageFinder;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.enterprise.client.LocalClient;
+import org.rhq.enterprise.server.security.AllowEjbAccessPermission;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+@Test
+public class EjbAccessTest extends AbstractEJB3Test {
+
+ public void testEjbsAccessibleThroughPrivilegedCode() {
+ LookupUtil.getSubjectManager().getOverlord();
+ }
+
+ 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();
+
+ ScriptEngine engine = getEngine(overlord);
+
+ try {
+ engine.eval(""
+ + "context = new javax.naming.InitialContext();\n"
+ + "subjectManager =
context.lookup('SubjectManagerBean/local');\n"
+ + "subjectManager.getOverlord();");
+
+ Assert.fail("The script shouldn't have been able to call local SLSB
method.");
+ } catch (ScriptException e) {
+ assert e.getMessage().contains(AllowEjbAccessPermission.class.getName());
+ }
+ }
+
+ public void testRemoteEjbsInaccessibleThroughJndiLookup() throws ScriptException,
IOException {
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ ScriptEngine engine = getEngine(overlord);
+
+ try {
+ engine.eval(""
+ + "context = new javax.naming.InitialContext();\n"
+ + "subjectManager =
context.lookup('SubjectManagerBean/remote');\n"
+ + "subjectManager.getSubjectByName('rhqadmin');");
+
+ Assert.fail("The script shouldn't have been able to call remote SLSB
method directly.");
+ } catch (ScriptException e) {
+ //TODO java.io.IOException: access denied (java.io.SerializablePermission
enableSubclassImplementation)
+ assert e.getMessage().contains(AllowEjbAccessPermission.class.getName());
+ }
+ }
+
+ public void testScriptCantUseSessionManager() throws ScriptException, IOException {
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ ScriptEngine engine = getEngine(overlord);
+
+ try {
+
engine.eval("org.rhq.enterprise.server.auth.SessionManager.getInstance();");
+
+ Assert.fail("The script shouldn't have been able to get instance of
SessionManager.");
+ } catch (ScriptException e) {
+ assert e.getMessage().contains(AllowEjbAccessPermission.class.getName());
+ }
+ }
+
+ @SuppressWarnings("unused")
+ public void testScriptCantUseSessionManagerMethods() throws Exception {
+
+ //The code below cannot work in Rhino because as of now, Rhino modifies
+ //the return value of Class.getDeclaredField() to be null when there
+ //is a security manager installed.
+ //This has been filed as a bug at Oracle
(
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7119959)
+
+ if (true) {
+ return;
+ }
+
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ final ScriptEngine engine = getEngine(overlord);
+
+ class G {
+ private String obtainSessionManagerUsingReflection = ""
+ + "var sessionManagerClass =
java.lang.Class.forName(\"org.rhq.enterprise.server.auth.SessionManager\");\n"
+ + "println(sessionManagerClass);\n"
+ + "var managerField =
sessionManagerClass.getDeclaredField(\"_manager\");\n"
+ + "println(managerField);\n"
+ + "managerField.setAccessible(true);\n"
+ + "var manager = managerField.get(null);\n"
+ + "println(manager);\n"
+ + "manager.";
+
+ public void testInvoke(String methodCall) throws ScriptException {
+ String code = obtainSessionManagerUsingReflection + methodCall;
+
+ try {
+ engine.eval(code);
+ Assert.fail("The script shouldn't have been able to a method
on a SessionManager.");
+ } catch (ScriptException e) {
+ assert
e.getMessage().contains(AllowEjbAccessPermission.class.getName());
+ }
+ }
+ };
+ G manager = new G();
+
+ manager.testInvoke("getLastAccess(0);");
+ manager.testInvoke("getOverlord()");
+ manager.testInvoke("getSubject(2);");
+ manager.testInvoke("invalidate(0);");
+ manager.testInvoke("invalidate(\"\");");
+ manager.testInvoke("put(new org.rhq.core.domain.auth.Subject());");
+ manager.testInvoke("put(new org.rhq.core.domain.auth.Subject(), 0);");
+ }
+
+ private ScriptEngine getEngine(Subject subject) throws ScriptException, IOException
{
+ StandardBindings bindings = new StandardBindings(new PrintWriter(System.out), new
LocalClient(subject));
+ ScriptEngine engine = ScriptEngineFactory.getScriptEngine("JavaScript",
new PackageFinder(Collections.<File>emptyList()), bindings);
+
+ PermissionCollection perms = new StandardScriptPermissions();
+ perms.add(new SerializablePermission("enableSubclassImplementation"));
+
+ return new SandboxedScriptEngine(engine, perms);
+ }
+}
diff --git a/modules/enterprise/server/client-api/src/test/resources/META-INF/ejb-jar.xml
b/modules/enterprise/server/client-api/src/test/resources/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..caa7513
--- /dev/null
+++ b/modules/enterprise/server/client-api/src/test/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+ <description>RHQ</description>
+ <display-name>RHQ</display-name>
+
+ <assembly-descriptor>
+
+ <!-- This interceptor checks that the alert CLI scripts don't try to
circumvent our access objects by accessing the local SLSB beans directly. -->
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.rhq.enterprise.server.security.AllowEjbAccessInterceptor</interceptor-class>
+ </interceptor-binding>
+
+ <!-- all our EJB3 SLSBs can define custom @RequiredPermissions annotations for
authorization checks-->
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.rhq.enterprise.server.authz.RequiredPermissionsInterceptor</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.rhq.enterprise.server.common.TransactionInterruptInterceptor</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.rhq.enterprise.server.common.PerformanceMonitorInterceptor</interceptor-class>
+ </interceptor-binding>
+
+ </assembly-descriptor>
+
+</ejb-jar>
diff --git a/modules/enterprise/server/client-api/src/test/resources/META-INF/jboss.xml
b/modules/enterprise/server/client-api/src/test/resources/META-INF/jboss.xml
new file mode 100644
index 0000000..b7c5c66
--- /dev/null
+++ b/modules/enterprise/server/client-api/src/test/resources/META-INF/jboss.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+
+ <enterprise-beans>
+
+ <!--
+ The AlertConditionLogManagerBean, AlertConditionManagerBean,
AlertDampeningManagerBean,
+ AlertDefinitionManagerBean, AlertManagerBean, AuthorizationManagerBean,
CachedConditionManagerBean, and
+ SubjectManager SLSB's are all invoked, either directly or indirectly, by the
AlertConditionConsumerBean MDB.
+ Since MDB invocations are always done in new threads, using the default SLSB
pool impl (ThreadlocalPool) would
+ cause a new instance of these SLSB's to be created every time they were
invoked by AlertConditionConsumerBean.
+ This would be bad if only because existing instances would
+ not be reused, but it is really bad because the instances would also never get
destroyed, causing heap space to
+ gradually leak until the Server eventually ran out of memory. Hence, we must use
a StrictMaxPool, which
+ will use a fixed pool of instances of this SLSB, instead of a ThreadlocalPool.
Because lots of alert
+ definitions could result in many concurrent calls to AlertConditionConsumerBean,
and because most of these
+ SLSB's are also invoked by other callers (i.e. Agents, GUI's, or
CLI's), we set the max pool size to 100 to
+ minimize the chances of AlertConditionConsumerBean invocations, which are the
most critical, from having to
+ block and potentially getting backed up in the queue. We set the pool timeout
extremely high to essentially
+ prevent queued callers from timing out. Note, MDB's are configured in
ejb3-interceptors-aop.xml to use a strict
+ max pool with a max of 15 and a timeout of 10000, so AlertConditionConsumerBean
might become a bottleneck for
+ systems with a lot of alerts defined. (ips, 05/10/11)
+
+ For more details, see
https://bugzilla.redhat.com/show_bug.cgi?id=693232 .
+ -->
+
+ <session>
+ <ejb-name>AlertConditionLogManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>AlertConditionManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>AlertDampeningManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>AlertDefinitionManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>AlertManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>AuthorizationManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>CachedConditionManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>SubjectManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>100</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+
+ <!--
+ The CacheConsistencyManagerBean, CloudManagerBean, ServerManagerBean,
StatusManagerBean, and SystemManagerBean
+ SLSB's are all invoked, either directly or indirectly, by EJB timers. Since
EJB timer invocations are always
+ done in new threads, using the default SLSB pool impl (ThreadlocalPool) would
cause a new instance of this
+ SLSB to be created every time it was invoked by an EJB timer. This would be bad
if only because an existing
+ instance would not be reused, but it is really bad because the instance would
also never get destroyed, causing
+ heap space to gradually leak until the Server eventually ran out of memory.
Hence, we must use a
+ StrictMaxPool, which will use a fixed pool of instances of this SLSB, instead of
a ThreadlocalPool.
+ The timer invocations will only require one or two instances at any given time,
but because most of these
+ SLSB's are also invoked by other callers (i.e. Agents, GUI's, or
CLI's, we set the max pool size to 30, to
+ minimize the chances of EJB timer invocations, which are the most critical, from
having to block and
+ potentially getting backed up in the queue. We set the pool timeout extremely
high to essentially prevent
+ queued callers from timing out. (ips, 05/10/11)
+
+ For more details, see
https://bugzilla.redhat.com/show_bug.cgi?id=693232 .
+ -->
+
+ <session>
+ <ejb-name>CacheConsistencyManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>30</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>CloudManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>30</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>ServerManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>30</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>StatusManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>30</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ <session>
+ <ejb-name>SystemManagerBean</ejb-name>
+ <pool-config>
+ <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-max-size>30</pool-max-size>
+ <pool-timeout>1000000000</pool-timeout>
+ </pool-config>
+ </session>
+
+ </enterprise-beans>
+
+</jboss>
diff --git a/modules/enterprise/server/client-api/src/test/resources/hibernate.properties
b/modules/enterprise/server/client-api/src/test/resources/hibernate.properties
new file mode 100644
index 0000000..1951b84
--- /dev/null
+++ b/modules/enterprise/server/client-api/src/test/resources/hibernate.properties
@@ -0,0 +1,26 @@
+# FOR SOME STRANGE REASON, THIS FILE NEEDS TO BE HERE FOR THE HIBERNATE TO CORRECTLY
+# INITIALIZE. I DON'T KNOW WHY THE STANDARD default.persistence.properties FILE
DOESN'T
+# WORK IN THIS MODULE.
+
+hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
+#hibernate.connection.release_mode=after_statement
+#hibernate.transaction.flush_before_completion=false
+#hibernate.transaction.auto_close_session=false
+#hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
+#hibernate.hbm2ddl.auto=create-drop
+#hibernate.hbm2ddl.auto=create
+hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
+# Clustered cache with TreeCache
+#hibernate.cache.provider_class=org.jboss.ejb3.entity.TreeCacheProviderHook
+#hibernate.treecache.mbean.object_name=jboss.cache:service=EJB3EntityTreeCache
+#hibernate.dialect=org.hibernate.dialect.HSQLDialect
+hibernate.jndi.java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+hibernate.jndi.java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+hibernate.bytecode.use_reflection_optimizer=false
+# I don't think this is honored, but EJB3Deployer uses it
+hibernate.bytecode.provider=javassist
+hibernate.jdbc.use_streams_for_binary=true
+hibernate.show_sql=false
+hibernate.format_sql=true
+hibernate.default_batch_fetch_size=16
+hibernate.jdbc.batch_size=20
diff --git a/modules/enterprise/server/client-api/src/test/resources/jms-ra.rar
b/modules/enterprise/server/client-api/src/test/resources/jms-ra.rar
new file mode 100644
index 0000000..c4807c6
Binary files /dev/null and
b/modules/enterprise/server/client-api/src/test/resources/jms-ra.rar differ
diff --git a/modules/enterprise/server/client-api/src/test/resources/security.policy
b/modules/enterprise/server/client-api/src/test/resources/security.policy
new file mode 100644
index 0000000..8860b47
--- /dev/null
+++ b/modules/enterprise/server/client-api/src/test/resources/security.policy
@@ -0,0 +1,10 @@
+// We need the SecurityManager installed to enable sandboxing of CLI scripts
+// but we don't define any other security measures on the RHQ server itself.
+//
+// Granting all permissions allows us to run the RHQ server as if no security
+// manager was in place (which is assumed by default by JBoss AS) but be able
+// to use it when we need it for our own purposes.
+
+grant {
+ permission java.security.AllPermission;
+};
commit ef5673fb4482fd08cdec672740afc2f12a3d2b0b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Dec 10 01:17:50 2011 +0100
Making SessionManager behave the same as EJBs wrt the AccessEjbPermission.
It is very security-sensitive so we shouldn't allow scripts to just access
it and cause havoc in user sessions.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index 39b6076..b4a19b7 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -25,30 +25,42 @@ import java.util.Map;
import java.util.Random;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.enterprise.server.security.AllowEjbAccessPermission;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* This is the JON Server's own session ID generator. It is outside any
container-provided session mechanism. Its sole
* purpose is to provide session IDs to logged in {@link Subject}s. It will timeout those
sessions regardless of any
* container-provided session-timeout mechanism.
- *
+ * <p>
+ * Because this is a very security-sensitive class, any public method requires the caller
to
+ * have the {@link AllowEjbAccessPermission} as any other calls to the EJB layer. This is
so that the
+ * malicious users can't trick the EJB layer into thinking that some users are logged
in or log out other
+ * users.
+ * <p>
+ * Also, for security reasons, this class is final so that malicious code can't
subclass it and modify its
+ * behavior.
+ *
* <p>This object is a {@link #getInstance() singleton}.</p>
*/
-public class SessionManager {
+public final class SessionManager {
+
+ private static final AllowEjbAccessPermission ACCESS_PERMISSION = new
AllowEjbAccessPermission();
+
/**
* Our source for random session IDs.
*/
- private static Random _random = new Random();
+ private static final Random _random = new Random();
/**
* Our session cache that is keyed on the session ID.
*/
- private static Map<Integer, AuthSession> _cache = new HashMap<Integer,
AuthSession>();
+ private static final Map<Integer, AuthSession> _cache = new HashMap<Integer,
AuthSession>();
/**
* The singleton instance
*/
- private static SessionManager _manager = new SessionManager();
+ private static final SessionManager _manager = new SessionManager();
/**
* The timeout for all user sessions.
@@ -78,7 +90,7 @@ public class SessionManager {
/**
* Return the singleton object.
- *
+ *
* @return the {@link SessionManager}
*/
public static SessionManager getInstance() {
@@ -95,6 +107,7 @@ public class SessionManager {
* sessionId will be assigned.
*/
public Subject put(Subject subject) {
+ checkPermission();
return put(subject, DEFAULT_TIMEOUT);
}
@@ -108,6 +121,7 @@ public class SessionManager {
* that Subject is overlord). The sessionId will be assigned.
*/
public synchronized Subject put(Subject subject, long timeout) {
+ checkPermission();
Integer key;
do {
@@ -141,6 +155,7 @@ public class SessionManager {
* @throws SessionTimeoutException
*/
public synchronized Subject getSubject(int sessionId) throws
SessionNotFoundException, SessionTimeoutException {
+ checkPermission();
Integer id = new Integer(sessionId);
AuthSession session = _cache.get(id);
@@ -162,6 +177,7 @@ public class SessionManager {
* @param sessionId session id to invalidate
*/
public synchronized void invalidate(int sessionId) {
+ checkPermission();
_cache.remove(new Integer(sessionId));
// while we are here, let's go through the entire session cache and remove
expired sessions
@@ -187,6 +203,7 @@ public class SessionManager {
* @param username username for the sessions to be invalidated
*/
public synchronized void invalidate(String username) {
+ checkPermission();
List<Integer> doomedSessionIds = new
ArrayList<Integer>(_cache.size());
for (AuthSession s : _cache.values()) {
if (username.equals(s.getSubject(false).getName())) {
@@ -201,6 +218,7 @@ public class SessionManager {
}
public long getlastAccess(int sessionId) {
+ checkPermission();
AuthSession session = _cache.get(sessionId);
if (session == null) {
return -1;
@@ -209,6 +227,7 @@ public class SessionManager {
}
public Subject getOverlord() {
+ checkPermission();
if (overlordSubject == null) {
overlordSubject =
LookupUtil.getSubjectManager().getSubjectById(OVERLORD_SUBJECT_ID);
@@ -256,4 +275,9 @@ public class SessionManager {
return copy;
}
+
+ private static void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
+ }
}
\ No newline at end of file
commit 0b0632e5641e91f3549e5addbc2c18bb27132c5a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Dec 10 01:16:26 2011 +0100
moving the EJB access permission and the interceptor back to the server
jar.
diff --git
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessInterceptor.java
b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessInterceptor.java
deleted file mode 100644
index d3dcdb2..0000000
---
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessInterceptor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.client.security;
-
-import java.security.AccessController;
-import java.security.Permission;
-
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.InvocationContext;
-
-/**
- *
- *
- * @author Lukas Krejci
- */
-public class AllowEjbAccessInterceptor {
-
- private static final Permission PERM = new AllowEjbAccessPermission();
-
- @AroundInvoke
- public Object intercept(InvocationContext invocationContext) throws Exception {
- //check that the caller has permissions to access the EJBs.
- //normal code does, only alert CLI scripts that try to circumvent our
- //manager proxies don't.
- AccessController.checkPermission(PERM);
- return invocationContext.proceed();
- }
-}
diff --git
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessPermission.java
b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessPermission.java
deleted file mode 100644
index 19ee165..0000000
---
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/security/AllowEjbAccessPermission.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.client.security;
-
-import java.security.BasicPermission;
-
-/**
- *
- *
- * @author Lukas Krejci
- */
-public class AllowEjbAccessPermission extends BasicPermission {
-
- private static final long serialVersionUID = 1L;
-
- public AllowEjbAccessPermission() {
- super("rhq.allow.ejb.access");
- }
-}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessInterceptor.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessInterceptor.java
new file mode 100644
index 0000000..350453fb
--- /dev/null
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessInterceptor.java
@@ -0,0 +1,46 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.security;
+
+import java.security.Permission;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class AllowEjbAccessInterceptor {
+
+ private static final Permission PERM = new AllowEjbAccessPermission();
+
+ @AroundInvoke
+ public Object intercept(InvocationContext invocationContext) throws Exception {
+ //check that the caller has permissions to access the EJBs.
+ //normal code does, only alert CLI scripts that try to circumvent our
+ //manager proxies don't.
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) sm.checkPermission(PERM);
+
+ return invocationContext.proceed();
+ }
+}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessPermission.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessPermission.java
new file mode 100644
index 0000000..67f418d
--- /dev/null
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/security/AllowEjbAccessPermission.java
@@ -0,0 +1,36 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.security;
+
+import java.security.BasicPermission;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class AllowEjbAccessPermission extends BasicPermission {
+
+ private static final long serialVersionUID = 1L;
+
+ public AllowEjbAccessPermission() {
+ super("rhq.allow.ejb.access");
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/resources/META-INF/ejb-jar.xml
b/modules/enterprise/server/jar/src/main/resources/META-INF/ejb-jar.xml
index 2700ae3..caa7513 100644
--- a/modules/enterprise/server/jar/src/main/resources/META-INF/ejb-jar.xml
+++ b/modules/enterprise/server/jar/src/main/resources/META-INF/ejb-jar.xml
@@ -12,7 +12,7 @@
<!-- This interceptor checks that the alert CLI scripts don't try to
circumvent our access objects by accessing the local SLSB beans directly. -->
<interceptor-binding>
<ejb-name>*</ejb-name>
-
<interceptor-class>org.rhq.enterprise.client.security.AllowEjbAccessInterceptor</interceptor-class>
+
<interceptor-class>org.rhq.enterprise.server.security.AllowEjbAccessInterceptor</interceptor-class>
</interceptor-binding>
<!-- all our EJB3 SLSBs can define custom @RequiredPermissions annotations for
authorization checks-->
commit 248f6d5a2e08b7367490a47b892ccf8080fa1545
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Dec 7 17:50:25 2011 +0100
be paranoid even in the comments ;)
diff --git
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClientProxy.java
b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClientProxy.java
index 7fcdac3..e9f1e4d 100644
---
a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClientProxy.java
+++
b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClientProxy.java
@@ -62,7 +62,9 @@ public class LocalClientProxy extends
AbstractRhqFacadeProxy<LocalClient> {
//run this through the privileged block to elevate the privs of the script
//the scripts don't have the AllowEjbAccessPermission but this code has
- //all perms.
+ //all perms (or at least all perms assigned to it by the current context,
+ //which at the time of writing is defined by the rhq-server.policy file
+ //which gives all code all permissions).
return AccessController.doPrivileged(new
PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {