[jboss-cvs] JBossAS SVN: r63843 - in trunk/ejb3: src/main/org/jboss/ejb3 and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 5 14:13:59 EDT 2007


Author: bdecoste
Date: 2007-07-05 14:13:59 -0400 (Thu, 05 Jul 2007)
New Revision: 63843

Added:
   trunk/ejb3/src/resources/test/security/META-INF/ejb-jar.xml
Modified:
   trunk/ejb3/build-test.xml
   trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean2.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/security/FacadeTargetBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/security/Level1CallerBean.java
Log:
[EJBTHREE-997] impl and test for security-role-ref

Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/build-test.xml	2007-07-05 18:13:59 UTC (rev 63843)
@@ -2869,6 +2869,9 @@
             <include name="roles.properties"/>
             <include name="security-spec.sar"/>
          </fileset>
+      	<fileset dir="${resources}/test/security">
+      	    <include name="META-INF/ejb-jar.xml"/>
+      	</fileset>
       </jar>
 
       <jar jarfile="${build.lib}/timer-runas-security.jar">

Modified: trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -27,6 +27,7 @@
 import java.io.ObjectOutput;
 import java.security.Identity;
 import java.security.Principal;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
@@ -56,12 +57,13 @@
 import org.jboss.ejb3.tx.TxUtil;
 import org.jboss.ejb3.tx.UserTransactionImpl;
 import org.jboss.logging.Logger;
-import org.jboss.metadata.SecurityRoleRefMetaData;
 import org.jboss.security.RealmMapping;
 import org.jboss.security.RunAsIdentity;
 import org.jboss.security.SecurityAssociation;
 import org.jboss.security.SimplePrincipal;
 
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
+
 /**
  * Comment
  *
@@ -224,12 +226,12 @@
       EJBContainer ejbc = (EJBContainer)container;
       if(ejbc.getXml() != null)
       {
-         List<SecurityRoleRefMetaData> securityRoleRefs = ejbc.getXml().getSecurityRoleReferences();
-         for(SecurityRoleRefMetaData srmd: securityRoleRefs)
+         Collection<SecurityRoleRef> securityRoleRefs = ejbc.getXml().getSecurityRoleRefs();
+         for(SecurityRoleRef roleRef: securityRoleRefs)
          {
-            String rname = srmd.getName(); 
-            if(roleName.equals(rname))
-               roleName = srmd.getLink();
+            String refName = roleRef.getRoleName(); 
+            if(roleName.equals(refName))
+               roleName = roleRef.getRoleLink();
          } 
       } 
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -25,7 +25,6 @@
 import java.net.URL;
 
 import org.jboss.logging.Logger;
-import org.jboss.metadata.SecurityRoleRefMetaData;
 import org.jboss.metamodel.descriptor.DDObjectFactory;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
@@ -38,6 +37,7 @@
 import org.jboss.metamodel.descriptor.ResourceRef;
 import org.jboss.metamodel.descriptor.RunAs;
 import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
 import org.jboss.util.xml.JBossEntityResolver;
 import org.jboss.util.StringPropertyReplacer;
 import org.jboss.ws.integration.ServiceRefMetaData;
@@ -257,7 +257,7 @@
 
       if (localName.equals("security-role-ref"))
       {
-         child = new SecurityRoleRefMetaData();
+         child = new SecurityRoleRef();
       }
       else if (localName.equals("security-identity"))
       {
@@ -291,7 +291,7 @@
       {
          if (localName.equals("security-role-ref"))
          {
-            child = new SecurityRoleRefMetaData();
+            child = new SecurityRoleRef();
          }
          else if (localName.equals("cmp-field"))
          {
@@ -698,9 +698,9 @@
       parent.addEnterpriseBean(ejb);
    }
 
-   public void addChild(SessionEnterpriseBean parent, SecurityRoleRefMetaData child, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(SessionEnterpriseBean parent, SecurityRoleRef roleRef, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      parent.addSecurityRoleReference(child);
+      parent.addSecurityRoleRef(roleRef);
    }
 
    public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName)
@@ -811,11 +811,6 @@
       parent.addCmpField(field);
    }
 
-   public void addChild(EntityEnterpriseBean parent, SecurityRoleRefMetaData child, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.addSecurityRoleReference(child);
-   }
-
    /**
     * Called when parsing character is complete.
     */
@@ -1313,15 +1308,15 @@
    /**
     * <!ELEMENT security-role-ref (rolename,role-link))>
     */
-   public void setValue(SecurityRoleRefMetaData parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   public void setValue(SecurityRoleRef parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("role-name"))
       {
-         parent.setName(value);
+         parent.setRoleName(value);
       }
       else if (localName.equals("role-link"))
       {
-         parent.setLink(value);
+         parent.setRoleLink(value);
       }
    }
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBean.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBean.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -29,12 +29,12 @@
 import javax.ejb.TransactionManagementType;
 
 import org.jboss.logging.Logger;
-import org.jboss.metadata.SecurityRoleRefMetaData;
 import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
 import org.jboss.metamodel.descriptor.InjectionTarget;
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
 
 /**
  * Represents an EJB element of the ejb-jar.xml deployment descriptor for the
@@ -97,7 +97,7 @@
    private Ejb3PortComponent portComponent;
    
    /** The security-role-ref element(s) info */
-   private ArrayList<SecurityRoleRefMetaData> securityRoleReferences = new ArrayList<SecurityRoleRefMetaData>();
+   private Collection<SecurityRoleRef> securityRoleRefs = new HashSet<SecurityRoleRef>();
    
    
    public void addXmlAnnotation(XmlAnnotation annotation)
@@ -372,21 +372,16 @@
       this.securityIdentity = securityIdentity;
    }
    
-   public void addSecurityRoleReference(SecurityRoleRefMetaData srmd)
+   public void addSecurityRoleRef(SecurityRoleRef roleRef)
    {
-      this.securityRoleReferences.add(srmd);
+      this.securityRoleRefs.add(roleRef);
    }
 
-   public ArrayList<SecurityRoleRefMetaData> getSecurityRoleReferences()
+   public Collection<SecurityRoleRef> getSecurityRoleRefs()
    {
-      return securityRoleReferences;
+      return securityRoleRefs;
    }
 
-   public void setSecurityRoleReferences(ArrayList<SecurityRoleRefMetaData> securityRoleReferences)
-   {
-      this.securityRoleReferences = securityRoleReferences;
-   }
-
    public Ejb3PortComponent getPortComponent()
    {
       return portComponent;

Added: trunk/ejb3/src/resources/test/security/META-INF/ejb-jar.xml
===================================================================
--- trunk/ejb3/src/resources/test/security/META-INF/ejb-jar.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/security/META-INF/ejb-jar.xml	2007-07-05 18:13:59 UTC (rev 63843)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://example.org/ns/dd resources/test/dd/ejb-jar_2_1.xsd">
+   <display-name>SecurityTests</display-name>
+   <enterprise-beans>
+      <session>
+         <ejb-name>CallerBean</ejb-name>
+         <security-role-ref>
+            <role-name>EchoCaller</role-name>
+            <role-link>Echo</role-link>
+         </security-role-ref>
+      </session>
+      <session>
+         <ejb-name>CallerBean2</ejb-name>
+         <security-role-ref>
+            <role-name>EchoCaller</role-name>
+            <role-link>Echo</role-link>
+         </security-role-ref>
+      </session>
+      <session>
+         <ejb-name>CallerFacadeTargetSFSB</ejb-name>
+         <security-role-ref>
+            <role-name>EchoCaller</role-name>
+            <role-link>Echo</role-link>
+         </security-role-ref>
+      </session>
+   </enterprise-beans>
+</ejb-jar>

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -63,8 +63,8 @@
       log.info("echo, arg=" + arg);
       Principal p = sessionContext.getCallerPrincipal();
       log.info("echo, callerPrincipal=" + p);
-      boolean isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole('Echo')=" + isEchoCaller);
+      boolean isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole('EchoCaller')=" + isEchoCaller);
       boolean isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole('InternalRole')=" + isInternalRole);
       
@@ -89,8 +89,8 @@
          throw new EJBException("Failed to invoke Callee.echo", e);
       }
 
-      isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole#2('Echo')=" + isEchoCaller);
+      isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole#2('EchoCaller')=" + isEchoCaller);
       isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole#2('InternalRole')=" + isInternalRole);
 

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean2.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean2.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/security/CallerBean2.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -64,8 +64,8 @@
       log.info("echo, arg=" + arg);
       Principal p = sessionContext.getCallerPrincipal();
       log.info("echo, callerPrincipal=" + p);
-      boolean isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole('Echo')=" + isEchoCaller);
+      boolean isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole('EchoCaller')=" + isEchoCaller);
       boolean isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole('InternalRole')=" + isInternalRole);
 
@@ -86,8 +86,8 @@
          throw new EJBException("Failed to invoke Callee.echo", e);
       }
 
-      isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole#2('Echo')=" + isEchoCaller);
+      isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole#2('EchoCaller')=" + isEchoCaller);
       isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole#2('InternalRole')=" + isInternalRole);
 

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/security/FacadeTargetBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/security/FacadeTargetBean.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/security/FacadeTargetBean.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -61,8 +61,8 @@
       log.debug("echo, arg=" + arg);
       Principal p = sessionContext.getCallerPrincipal();
       log.debug("echo, callerPrincipal=" + p);
-      boolean isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.debug("echo, isCallerInRole('Echo')=" + isEchoCaller);
+      boolean isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.debug("echo, isCallerInRole('EchoCaller')=" + isEchoCaller);
 
       if (isEchoCaller == false)
          throw new SecurityException("isEchoCaller == false");
@@ -81,8 +81,8 @@
          throw new EJBException("Failed to invoke Callee.echo", e);
       }
 
-      isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.debug("echo, post calls isCallerInRole('Echo')=" + isEchoCaller);
+      isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.debug("echo, post calls isCallerInRole('EchoCaller')=" + isEchoCaller);
       if (isEchoCaller == false)
          throw new SecurityException("isEchoCaller == false post calls");
 

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/security/Level1CallerBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/security/Level1CallerBean.java	2007-07-05 17:09:42 UTC (rev 63842)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/security/Level1CallerBean.java	2007-07-05 18:13:59 UTC (rev 63843)
@@ -65,8 +65,8 @@
       log.info("echo, arg=" + arg);
       Principal p = sessionContext.getCallerPrincipal();
       log.info("echo, callerPrincipal=" + p);
-      boolean isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole('Echo')=" + isEchoCaller);
+      boolean isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole('EchoCaller')=" + isEchoCaller);
       boolean isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole('InternalRole')=" + isInternalRole);
       
@@ -88,8 +88,8 @@
          throw new EJBException("Failed to invoke Callee.echo", e);
       }
 
-      isEchoCaller = sessionContext.isCallerInRole("Echo");
-      log.info("echo, isCallerInRole#2('Echo')=" + isEchoCaller);
+      isEchoCaller = sessionContext.isCallerInRole("EchoCaller");
+      log.info("echo, isCallerInRole#2('EchoCaller')=" + isEchoCaller);
       isInternalRole = sessionContext.isCallerInRole("InternalRole");
       log.info("echo, isCallerInRole#2('InternalRole')=" + isInternalRole);
 




More information about the jboss-cvs-commits mailing list