[jboss-cvs] JBossAS SVN: r61364 - in branches/Branch_4_2/testsuite: src/main/org/jboss/test/security/ejb and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Mar 16 00:52:20 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-03-16 00:52:19 -0400 (Fri, 16 Mar 2007)
New Revision: 61364
Modified:
branches/Branch_4_2/testsuite/imports/sections/security.xml
branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/ejb/SFSBTxSynchronizationBean.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/test/ejb/SFSBIntegrationTestCase.java
branches/Branch_4_2/testsuite/src/resources/security/sfsb/ejb-jar.xml
branches/Branch_4_2/testsuite/src/resources/security/sfsb/jboss.xml
Log:
JBAS-3781:In the presence of caller RAI, do not push a null subject context
Modified: branches/Branch_4_2/testsuite/imports/sections/security.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/security.xml 2007-03-16 04:46:25 UTC (rev 61363)
+++ branches/Branch_4_2/testsuite/imports/sections/security.xml 2007-03-16 04:52:19 UTC (rev 61364)
@@ -433,6 +433,7 @@
</fileset>
<fileset dir="${build.classes}">
<include name="org/jboss/test/security/ejb/SFSB**"/>
+ <include name="org/jboss/test/security/ejb/Stateful**"/>
<include name="org/jboss/test/security/interfaces/Stateful**"/>
</fileset>
</jar>
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/ejb/SFSBTxSynchronizationBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/ejb/SFSBTxSynchronizationBean.java 2007-03-16 04:46:25 UTC (rev 61363)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/ejb/SFSBTxSynchronizationBean.java 2007-03-16 04:52:19 UTC (rev 61364)
@@ -27,9 +27,13 @@
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
-import javax.ejb.SessionSynchronization;
+import javax.ejb.SessionSynchronization;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
import org.apache.log4j.Logger;
+import org.jboss.test.security.interfaces.StatefulSession;
+import org.jboss.test.security.interfaces.StatefulSessionHome;
/**
* SFSB that has the session synchronization methods that invoke
@@ -79,6 +83,24 @@
log.debug("echo, arg="+arg);
Principal p = sessionContext.getCallerPrincipal();
log.debug("echo, callerPrincipal="+p);
+
+ //Now check whether we are able to call the bean with run-as role
+ try
+ {
+ InitialContext jndiContext = new InitialContext();
+ Object obj = jndiContext.lookup("java:comp/env/ejb/RunAsSFSB");
+ obj = PortableRemoteObject.narrow(obj, StatefulSessionHome.class);
+ StatefulSessionHome home = (StatefulSessionHome) obj;
+ log.debug("Found StatefulSessionHome");
+ // The create should be allowed to call getCallerPrincipal
+ StatefulSession bean = home.create("testStatefulCreateCaller");
+ // Need to invoke a method to ensure an ejbCreate call
+ bean.echo("testStatefulCreateCaller");
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
return arg;
}
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/test/ejb/SFSBIntegrationTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/test/ejb/SFSBIntegrationTestCase.java 2007-03-16 04:46:25 UTC (rev 61363)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/security/test/ejb/SFSBIntegrationTestCase.java 2007-03-16 04:52:19 UTC (rev 61364)
@@ -38,6 +38,7 @@
/**
* Stateful Session Beans Integration Tests
* JBAS-3976: Null security context exception thrown for no login
+ * JBAS-3781: Do not push null subject context when caller RAI is present
* @author Anil.Saldhana at redhat.com
* @since Mar 15, 2007
* @version $Revision$
@@ -52,6 +53,9 @@
/**
* Call a SFSB method that has container transaction and each of
* the SessionSynchronization callback methods call the getCallerPrincipal
+ *
+ * Also the SFSB has a ejb ref to another SFSB which is secured and declares
+ * a run-as role
* @throws Exception
*/
public void testCallerPrincipalInSessionSynchronization() throws Exception
Modified: branches/Branch_4_2/testsuite/src/resources/security/sfsb/ejb-jar.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/sfsb/ejb-jar.xml 2007-03-16 04:46:25 UTC (rev 61363)
+++ branches/Branch_4_2/testsuite/src/resources/security/sfsb/ejb-jar.xml 2007-03-16 04:52:19 UTC (rev 61364)
@@ -14,7 +14,28 @@
<ejb-class>org.jboss.test.security.ejb.SFSBTxSynchronizationBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
+ <ejb-ref>
+ <ejb-ref-name>ejb/RunAsSFSB</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <home>org.jboss.test.security.interfaces.StatefulSessionHome</home>
+ <remote>org.jboss.test.security.interfaces.StatefulSession</remote>
+ <ejb-link>RunAsStatefulSession</ejb-link>
+ </ejb-ref>
+ <security-identity>
+ <run-as>
+ <role-name>InternalUser</role-name>
+ </run-as>
+ </security-identity>
</session>
+ <session>
+ <description>A secured stateful session bean</description>
+ <ejb-name>RunAsStatefulSession</ejb-name>
+ <home>org.jboss.test.security.interfaces.StatefulSessionHome</home>
+ <remote>org.jboss.test.security.interfaces.StatefulSession</remote>
+ <ejb-class>org.jboss.test.security.ejb.StatefulSessionBean</ejb-class>
+ <session-type>Stateful</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
</enterprise-beans>
<assembly-descriptor>
@@ -22,20 +43,26 @@
<description>The role required to invoke the echo method</description>
<role-name>Echo</role-name>
</security-role>
- <method-permission>
+ <method-permission>
<unchecked/>
<method>
<ejb-name>StatefulSession</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
+ <method-permission>
+ <role-name>InternalUser</role-name>
+ <method>
+ <ejb-name>RunAsStatefulSession</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
<container-transaction>
<method>
<ejb-name>StatefulSession</ejb-name>
- <method-name>*</method-name>
+ <method-name>echo</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
-
</ejb-jar>
Modified: branches/Branch_4_2/testsuite/src/resources/security/sfsb/jboss.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/sfsb/jboss.xml 2007-03-16 04:46:25 UTC (rev 61363)
+++ branches/Branch_4_2/testsuite/src/resources/security/sfsb/jboss.xml 2007-03-16 04:52:19 UTC (rev 61364)
@@ -15,8 +15,16 @@
<enterprise-beans>
<session>
+ <ejb-name>RunAsStatefulSession</ejb-name>
+ <jndi-name>spec.RunAsStatefulSession</jndi-name>
+ </session>
+ <session>
<ejb-name>StatefulSession</ejb-name>
<jndi-name>spec.StatefulSession</jndi-name>
+ <ejb-ref>
+ <ejb-ref-name>ejb/RunAsSFSB</ejb-ref-name>
+ <jndi-name>spec.RunAsStatefulSession</jndi-name>
+ </ejb-ref>
</session>
</enterprise-beans>
</jboss>
More information about the jboss-cvs-commits
mailing list