[jboss-cvs] JBossAS SVN: r58053 - in branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3: . metamodel
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 3 00:06:01 EST 2006
Author: anil.saldhana at jboss.com
Date: 2006-11-03 00:06:00 -0500 (Fri, 03 Nov 2006)
New Revision: 58053
Removed:
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/SecurityRoleMetaData.java
Modified:
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/AssemblyDescriptor.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
Log:
EJBTHREE-775: consider deployment level roles. The ejb3 metamodel has now a link to the ejb21 metamodel due to SecurityRoleMetaData that originates from J2EEApplicationMetaData
Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2006-11-03 05:03:27 UTC (rev 58052)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2006-11-03 05:06:00 UTC (rev 58053)
@@ -22,10 +22,17 @@
package org.jboss.ejb3;
import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployment.J2eeApplicationMetaData;
+import org.jboss.ejb3.metamodel.AssemblyDescriptor;
import org.jboss.ejb3.metamodel.EjbJarDD;
import org.jboss.ejb3.metamodel.EjbJarDDObjectFactory;
-import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.metadata.SecurityRoleMetaData;
import javassist.bytecode.ClassFile;
@@ -44,6 +51,16 @@
this.dd = EjbJarDDObjectFactory.parse(di.getDeploymentUnit().getEjbJarXml());
this.dd = JBossDDObjectFactory.parse(di.getDeploymentUnit().getJbossXml(), dd);
+ //Merge any parent settings (Eg:jboss-app.xml)
+ DeploymentUnit du = di.getDeploymentUnit();
+ if(du instanceof JmxDeploymentUnit)
+ {
+ JmxDeploymentUnit jdu = (JmxDeploymentUnit)du;
+ J2eeApplicationMetaData jmetadata = (J2eeApplicationMetaData) jdu.getParentMetaData();
+ if(jmetadata != null)
+ mergeParentMetaData(dd, jmetadata);
+ }
+
InterceptorInfoRepository repository = this.di.getDeploymentUnit().getInterceptorInfoRepository();
repository.initialise(dd);
}
@@ -53,6 +70,39 @@
{
return new Ejb3DescriptorHandler(di, cf, dd);
}
+
+ /**
+ * Merge custom settings from jboss-app.xml
+ * @param di
+ * @param jmetadata
+ */
+ private void mergeParentMetaData(EjbJarDD dd, J2eeApplicationMetaData jmetadata)
+ {
+ AssemblyDescriptor ad = dd.getAssemblyDescriptor();
+ //merge security roles
+ mergeSecurityRoles(ad.getSecurityRoleMetaData(), jmetadata.getSecurityRoles());
+ }
+
+ private void mergeSecurityRoles(Map securityRoles, Map applRoles)
+ {
+ Iterator it = applRoles.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ String roleName = (String)entry.getKey();
+ SecurityRoleMetaData appRole = (SecurityRoleMetaData)entry.getValue();
+ SecurityRoleMetaData srMetaData = (SecurityRoleMetaData)securityRoles.get(roleName);
+ if (srMetaData != null)
+ {
+ Set principalNames = appRole.getPrincipals();
+ srMetaData.addPrincipalNames(principalNames);
+ }
+ else
+ {
+ securityRoles.put(roleName, entry.getValue());
+ }
+ }
+ }
}
private static class AnnotationFactory extends Ejb3HandlerFactory
Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/AssemblyDescriptor.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/AssemblyDescriptor.java 2006-11-03 05:03:27 UTC (rev 58052)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/AssemblyDescriptor.java 2006-11-03 05:06:00 UTC (rev 58053)
@@ -32,6 +32,7 @@
import org.jboss.logging.Logger;
+import org.jboss.metadata.SecurityRoleMetaData;
import org.jboss.metamodel.descriptor.SecurityRole;
/**
@@ -193,6 +194,42 @@
}
return roleNames;
}
+
+ /**
+ * Get a map of principals versus set of roles
+ * that may be configured by the user at the deployment level
+ * @return
+ */
+ public Map getPrincipalVersusRolesMap()
+ {
+ Map principalRolesMap = null;
+
+ Iterator iter = securityRoleMetaData.keySet().iterator();
+ while(iter.hasNext())
+ {
+ if(principalRolesMap == null)
+ principalRolesMap = new HashMap();
+ String rolename = (String)iter.next();
+ SecurityRoleMetaData srm = (SecurityRoleMetaData) securityRoleMetaData.get(rolename);
+ Iterator principalIter = srm.getPrincipals().iterator();
+ while(principalIter.hasNext())
+ {
+ String pr = (String)principalIter.next();
+ Set roleset = (Set)principalRolesMap.get(pr);
+ if(roleset == null)
+ roleset = new HashSet();
+ if(!roleset.contains(rolename))
+ roleset.add(rolename);
+ principalRolesMap.put(pr, roleset);
+ }
+ }
+ return principalRolesMap;
+ }
+
+ public Map<String,SecurityRoleMetaData> getSecurityRoleMetaData()
+ {
+ return this.securityRoleMetaData;
+ }
public String toString()
{
Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2006-11-03 05:03:27 UTC (rev 58052)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2006-11-03 05:06:00 UTC (rev 58053)
@@ -37,6 +37,7 @@
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
+import org.jboss.metadata.SecurityRoleMetaData;
import org.jboss.metamodel.descriptor.DDObjectFactory;
import org.jboss.metamodel.descriptor.EjbLocalRef;
import org.jboss.metamodel.descriptor.EjbRef;
@@ -284,7 +285,7 @@
}
if (localName.equals("security-role"))
{
- child = new SecurityRoleMetaData();
+ child = new SecurityRoleMetaData("dummy_to_be_replaced_in_setValue");
}
return child;
@@ -1124,7 +1125,7 @@
{
if (localName.equals("role-name"))
{
- srm.setRoleName(getValue(localName, value));
+ srm.setRoleName(getValue(localName, value));
}
else if (localName.equals("principal-name"))
{
Deleted: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/SecurityRoleMetaData.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/SecurityRoleMetaData.java 2006-11-03 05:03:27 UTC (rev 58052)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/SecurityRoleMetaData.java 2006-11-03 05:06:00 UTC (rev 58053)
@@ -1,82 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.ejb3.metamodel;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * The meta data object for the security-role-mapping element.
- *
- * The security-role-mapping element maps the user principal
- * to a different principal on the server. It can for example
- * be used to map a run-as-principal to more than one role.
- *
- * <security-role>
- <role-name>Employee</role-name>
- <principal-name>javajoe</principal-name>
- <principal-name>j2ee</principal-name>
- </security-role>
- *
- * @author Anil.Saldhana at jboss.org
- * @version $Revision: 37459 $
- */
-public class SecurityRoleMetaData
-{
- private String roleName;
- private Set principals;
-
- public SecurityRoleMetaData()
- {
- this.principals = new HashSet();
- }
- public SecurityRoleMetaData(String roleName)
- {
- this.roleName = roleName;
- this.principals = new HashSet();
- }
-
- public void addPrincipalName(String principalName)
- {
- principals.add(principalName);
- }
-
- public void addPrincipalNames(Set principalNames)
- {
- principals.addAll(principalNames);
- }
-
- public void setRoleName(String rol)
- {
- this.roleName = rol;
- }
-
- public String getRoleName()
- {
- return roleName;
- }
-
- public Set getPrincipals()
- {
- return principals;
- }
-}
More information about the jboss-cvs-commits
mailing list