[jboss-cvs] JBossAS SVN: r62378 - in trunk/embedded: src/main/resources/javase and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 17 11:15:18 EDT 2007


Author: bill.burke at jboss.com
Date: 2007-04-17 11:15:18 -0400 (Tue, 17 Apr 2007)
New Revision: 62378

Added:
   trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/Secured.java
   trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/SecuredBean.java
   trunk/embedded/src/test/resources/ejb/roles.properties
   trunk/embedded/src/test/resources/ejb/users.properties
Modified:
   trunk/embedded/build-test.xml
   trunk/embedded/src/main/resources/javase/jndi.properties
   trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java
Log:
finish distribution

Modified: trunk/embedded/build-test.xml
===================================================================
--- trunk/embedded/build-test.xml	2007-04-17 14:43:13 UTC (rev 62377)
+++ trunk/embedded/build-test.xml	2007-04-17 15:15:18 UTC (rev 62378)
@@ -166,6 +166,7 @@
          </fileset>
          <fileset dir="${resources}/ejb">
             <include name="META-INF/persistence.xml"/>
+            <include name="*.properties"/>
          </fileset>
       </jar>
       <jar jarfile="${build.lib}/mdb-test.jar">

Modified: trunk/embedded/src/main/resources/javase/jndi.properties
===================================================================
--- trunk/embedded/src/main/resources/javase/jndi.properties	2007-04-17 14:43:13 UTC (rev 62377)
+++ trunk/embedded/src/main/resources/javase/jndi.properties	2007-04-17 15:15:18 UTC (rev 62378)
@@ -1,4 +1,4 @@
 # DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING
 #
-java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.initial=org.jboss.naming.JBossRemotingContextFactory
 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/Secured.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/Secured.java	                        (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/Secured.java	2007-04-17 15:15:18 UTC (rev 62378)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.embedded.test.ejb;
+
+import javax.annotation.security.RolesAllowed;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Secured
+{
+   @RolesAllowed("Allowed")
+   void allowed();
+
+   @RolesAllowed("Nobody")
+   void nobody();
+}

Added: trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/SecuredBean.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/SecuredBean.java	                        (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/SecuredBean.java	2007-04-17 15:15:18 UTC (rev 62378)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.embedded.test.ejb;
+
+import org.jboss.annotation.security.SecurityDomain;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+ at SecurityDomain("other")
+ at Stateless
+public class SecuredBean implements Secured
+{
+   @RolesAllowed("allowed")
+   public void allowed()
+   {
+
+   }
+
+   @RolesAllowed("nobody")
+   public void nobody()
+   {
+
+   }
+}

Modified: trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java	2007-04-17 14:43:13 UTC (rev 62377)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java	2007-04-17 15:15:18 UTC (rev 62378)
@@ -30,6 +30,7 @@
 import org.jboss.embedded.DeploymentGroup;
 import org.jboss.embedded.test.ejb.DAO;
 import org.jboss.embedded.test.ejb.Customer;
+import org.jboss.embedded.test.ejb.Secured;
 import org.jboss.deployers.spi.DeploymentException;
 
 import javax.management.MBeanServer;
@@ -39,6 +40,9 @@
 import javax.management.ReflectionException;
 import javax.management.MalformedObjectNameException;
 import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.ejb.EJBAccessException;
+import java.util.Hashtable;
 
 /**
  * Comment
@@ -155,4 +159,47 @@
 
 
     }
+
+   public void testSecurity() throws Exception
+   {
+      DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+      group.addClasspath("ejb-test.jar");
+      group.process();
+
+      Hashtable env = new Hashtable();
+      env.put(Context.SECURITY_PRINCIPAL, "scott");
+      env.put(Context.SECURITY_CREDENTIALS, "invalidpassword");
+
+      InitialContext ctx = new InitialContext(env);
+      Secured secured = (Secured)ctx.lookup("SecuredBean/local");
+      boolean exceptionThrown = false;
+      try
+      {
+         secured.allowed();
+      }
+      catch (EJBAccessException ignored)
+      {
+         exceptionThrown = true;
+      }
+      assertTrue("Security exception not thrown for invalid password", exceptionThrown);
+      env.put(Context.SECURITY_CREDENTIALS, "password");
+      ctx = new InitialContext(env);
+
+      secured.allowed();
+
+      exceptionThrown = false;
+      try
+      {
+         secured.nobody();
+      }
+      catch (EJBAccessException ignored)
+      {
+         exceptionThrown = true;
+      }
+      assertTrue("Security exception not thrown for invalid role", exceptionThrown);
+
+      group.undeploy();
+
+
+   }
 }

Added: trunk/embedded/src/test/resources/ejb/roles.properties
===================================================================
--- trunk/embedded/src/test/resources/ejb/roles.properties	                        (rev 0)
+++ trunk/embedded/src/test/resources/ejb/roles.properties	2007-04-17 15:15:18 UTC (rev 62378)
@@ -0,0 +1 @@
+scott=allowed

Added: trunk/embedded/src/test/resources/ejb/users.properties
===================================================================
--- trunk/embedded/src/test/resources/ejb/users.properties	                        (rev 0)
+++ trunk/embedded/src/test/resources/ejb/users.properties	2007-04-17 15:15:18 UTC (rev 62378)
@@ -0,0 +1 @@
+scott=password




More information about the jboss-cvs-commits mailing list