[jboss-cvs] JBossAS SVN: r111829 - in trunk: testsuite/imports/sections and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 25 11:32:17 EDT 2011


Author: jaikiran
Date: 2011-07-25 11:32:17 -0400 (Mon, 25 Jul 2011)
New Revision: 111829

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/
   trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SecuredSingletonBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SingletonSecurity.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/unit/
   trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/unit/SingletonSecurityTestCase.java
   trunk/testsuite/src/resources/ejb3/singleton/security/
   trunk/testsuite/src/resources/ejb3/singleton/security/roles.properties
   trunk/testsuite/src/resources/ejb3/singleton/security/users.properties
Modified:
   trunk/component-matrix/pom.xml
   trunk/testsuite/imports/sections/ejb3.xml
Log:
JBAS-8807 Upgrade to latest EJB3 version to fix EJBTHREE-2263 related to secured singleton beans

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2011-07-25 15:07:21 UTC (rev 111828)
+++ trunk/component-matrix/pom.xml	2011-07-25 15:32:17 UTC (rev 111829)
@@ -88,7 +88,7 @@
     <version.org.jboss.cluster.cache.ispn>1.0.0.Final</version.org.jboss.cluster.cache.ispn>
     <version.org.jboss.common.core>2.2.17.GA</version.org.jboss.common.core>
     <version.org.jboss.deployers>2.2.1.GA</version.org.jboss.deployers>
-    <version.org.jboss.ejb3.depchain>1.0.1</version.org.jboss.ejb3.depchain>
+    <version.org.jboss.ejb3.depchain>1.0.2</version.org.jboss.ejb3.depchain>
     <!-- This to move into the EJB3 BOM -->
     <version.org.jboss.ejb3.embedded>1.0.0-alpha-4</version.org.jboss.ejb3.embedded>
     <version.org.jboss.ejb.api>1.0-alpha-1</version.org.jboss.ejb.api>

Modified: trunk/testsuite/imports/sections/ejb3.xml
===================================================================
--- trunk/testsuite/imports/sections/ejb3.xml	2011-07-25 15:07:21 UTC (rev 111828)
+++ trunk/testsuite/imports/sections/ejb3.xml	2011-07-25 15:32:17 UTC (rev 111829)
@@ -197,6 +197,7 @@
    		<jar destfile="${build.lib}/ejb31singleton.jar">
    			   <fileset dir="${build.classes}">
    				   <include name="org/jboss/test/ejb3/singleton/**" />
+                   <exclude name="org/jboss/test/ejb3/singleton/security/**" />
    			   </fileset>
    		   </jar>
    </target>
@@ -236,7 +237,8 @@
       jbas7556,
    	  jbas7883,
       ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface, ejb3war, jbpapp3026, ejb31singleton,ejb31async, 
-      ejb3-portable-jndi-names">
+      ejb3-portable-jndi-names,
+      singleton-security">
       <mkdir dir="${build.lib}" />
 
       <!-- A jar with a simple ejb3 session -->
@@ -246,5 +248,18 @@
          </fileset>
       </jar>
    </target>
+
+    <target name="singleton-security" depends="compile">
+        <mkdir dir="${build.lib}" />
+
+            <jar destfile="${build.lib}/ejb3-singleton-security.jar">
+                   <fileset dir="${build.classes}">
+                       <include name="org/jboss/test/ejb3/singleton/security/**" />
+                   </fileset>
+                   <fileset dir="${source.resources}/ejb3/singleton/security" includes="**">
+                   </fileset>
+               </jar>
+    </target>
+
   
 </project>

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SecuredSingletonBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SecuredSingletonBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SecuredSingletonBean.java	2011-07-25 15:32:17 UTC (rev 111829)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.ejb3.singleton.security;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.test.ejb3.singleton.security.unit.SingletonSecurityTestCase;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.EJBContext;
+import javax.ejb.Remote;
+import javax.ejb.Singleton;
+
+/**
+ * User: jpai
+ */
+ at Singleton
+ at SecurityDomain("other")
+ at Remote (SingletonSecurity.class)
+ at RemoteBinding (jndiBinding = SecuredSingletonBean.JNDI_NAME)
+public class SecuredSingletonBean implements SingletonSecurity {
+
+    public static final String JNDI_NAME = "SecuredSingletonBean-remote";
+
+    @Resource
+    private EJBContext ejbContext;
+
+    @Override
+    @RolesAllowed("role1")
+    public void allowedForRole1() {
+        if (!this.ejbContext.isCallerInRole("role1")) {
+            throw new RuntimeException("Only role1 was expected to be allowed to invoke this method");
+        }
+    }
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SingletonSecurity.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SingletonSecurity.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/SingletonSecurity.java	2011-07-25 15:32:17 UTC (rev 111829)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.ejb3.singleton.security;
+
+/**
+ * User: jpai
+ */
+public interface SingletonSecurity {
+
+    public void allowedForRole1();
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/unit/SingletonSecurityTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/unit/SingletonSecurityTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/singleton/security/unit/SingletonSecurityTestCase.java	2011-07-25 15:32:17 UTC (rev 111829)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.ejb3.singleton.security.unit;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.ejb3.singleton.security.SecuredSingletonBean;
+import org.jboss.test.ejb3.singleton.security.SingletonSecurity;
+
+import javax.ejb.EJBAccessException;
+import javax.naming.InitialContext;
+
+/**
+ * Tests that invocations on a secured singleton bean work as expected
+ * <p/>
+ * User: Jaikiran Pai
+ */
+public class SingletonSecurityTestCase extends JBossTestCase {
+
+    public SingletonSecurityTestCase(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+        return getDeploySetup(SingletonSecurityTestCase.class, "ejb3-singleton-security.jar");
+    }
+
+    /**
+     * Test a method invocation on a singleton bean with the correct expected role.
+     *
+     * @throws Exception
+     */
+    public void testInvocationOnSecuredMethodWithCorrectRole() throws Exception {
+        final SingletonSecurity securedSingleton = InitialContext.doLookup(SecuredSingletonBean.JNDI_NAME);
+        final SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
+        securityClient.setSimple("user1", "pass1");
+        try {
+            // login
+            securityClient.login();
+            // expects role1, so should succeed
+            securedSingleton.allowedForRole1();
+        } finally {
+            securityClient.logout();
+        }
+
+    }
+
+    /**
+     * Test a method invocation on a singleton bean with an incorrect role.
+     *
+     * @throws Exception
+     */
+    public void testInvocationOnSecuredMethodWithInCorrectRole() throws Exception {
+        final SingletonSecurity securedSingleton = InitialContext.doLookup(SecuredSingletonBean.JNDI_NAME);
+        final SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
+        securityClient.setSimple("user2", "pass2");
+        try {
+            // login
+            securityClient.login();
+            try {
+                // expects role1, so should fail
+                securedSingleton.allowedForRole1();
+                Assert.fail("Call to secured method, with incorrect role, was expected to fail");
+            } catch (EJBAccessException ejbae) {
+                // expected
+            }
+        } finally {
+            securityClient.logout();
+        }
+
+    }
+
+    /**
+     * Test a method invocation on a singleton bean without logging in.
+     *
+     * @throws Exception
+     */
+    public void testInvocationOnSecuredMethodWithoutLogin() throws Exception {
+        final SingletonSecurity securedSingleton = InitialContext.doLookup(SecuredSingletonBean.JNDI_NAME);
+        try {
+            securedSingleton.allowedForRole1();
+            Assert.fail("Call to secured method was expected to fail");
+        } catch (EJBAccessException ejbae) {
+            // expected
+        }
+
+    }
+}

Added: trunk/testsuite/src/resources/ejb3/singleton/security/roles.properties
===================================================================
--- trunk/testsuite/src/resources/ejb3/singleton/security/roles.properties	                        (rev 0)
+++ trunk/testsuite/src/resources/ejb3/singleton/security/roles.properties	2011-07-25 15:32:17 UTC (rev 111829)
@@ -0,0 +1,23 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2010, Red Hat, Inc., and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+user1=role1
+user2=role2

Added: trunk/testsuite/src/resources/ejb3/singleton/security/users.properties
===================================================================
--- trunk/testsuite/src/resources/ejb3/singleton/security/users.properties	                        (rev 0)
+++ trunk/testsuite/src/resources/ejb3/singleton/security/users.properties	2011-07-25 15:32:17 UTC (rev 111829)
@@ -0,0 +1,24 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2010, Red Hat, Inc., and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+user1=pass1
+user2=pass2
+



More information about the jboss-cvs-commits mailing list