[jboss-cvs] JBossAS SVN: r69991 - in trunk/webservices/src: resources/jbossws-jboss50.deployer/META-INF and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 21 05:09:44 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-02-21 05:09:44 -0500 (Thu, 21 Feb 2008)
New Revision: 69991
Added:
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB21.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB3.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebAppGeneratorDeploymentAspect.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/InMemoryWebAppGeneratorDeploymentAspect.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandler.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB21.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB3.java
Removed:
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB3.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebApp50GeneratorDeploymentAspect.java
Modified:
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebMetaDataModifier.java
trunk/webservices/src/main/org/jboss/wsf/container/jboss50/ModifyWebMetaDataDeploymentAspect.java
trunk/webservices/src/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-beans.xml
Log:
[JBWS-1967] Get rid of web.xml rewrite (WIP)
Copied: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB21.java (from rev 69990, trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java)
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB21.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB21.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,81 @@
+/*
+ * 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.wsf.container.jboss50;
+
+//$Id: SecurityHandlerEJB21.java 4013 2007-07-27 04:37:52Z thomas.diesler at jboss.com $
+
+import org.dom4j.Element;
+import org.jboss.metadata.common.ejb.IAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.SecurityHandler;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Generate a service endpoint deployment for EJB endpoints
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class FileBasedSecurityHandlerEJB21 implements SecurityHandler
+{
+ public void addSecurityDomain(Element jbossWeb, Deployment dep)
+ {
+ EJBArchiveMetaData ejbMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (ejbMetaData == null)
+ throw new IllegalStateException("Cannot obtain application meta data");
+
+ String securityDomain = ejbMetaData.getSecurityDomain();
+ if (securityDomain != null)
+ {
+ if (securityDomain.startsWith("java:/jaas/") == false)
+ securityDomain = "java:/jaas/" + securityDomain;
+
+ jbossWeb.addElement("security-domain").addText(securityDomain);
+ }
+ }
+
+ public void addSecurityRoles(Element webApp, Deployment dep)
+ {
+ // Fix: http://jira.jboss.org/jira/browse/JBWS-309
+ JBossMetaData jbmd = dep.getAttachment(JBossMetaData.class);
+ IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
+ if (assemblyDescriptor != null)
+ {
+ SecurityRolesMetaData srmd = assemblyDescriptor.getSecurityRoles();
+ if (srmd != null)
+ {
+ Iterator it = srmd.keySet().iterator();
+ while (it.hasNext())
+ {
+ webApp.addElement("security-role").addElement("role-name").addText((String)it.next());
+ }
+ }
+ }
+ }
+}
Copied: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB3.java (from rev 69990, trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB3.java)
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB3.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedSecurityHandlerEJB3.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,96 @@
+/*
+ * 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.wsf.container.jboss50;
+
+//$Id: SecurityHandlerEJB3.java 4011 2007-07-27 02:45:35Z thomas.diesler at jboss.com $
+
+import java.util.Iterator;
+
+import javax.annotation.security.RolesAllowed;
+
+import org.dom4j.Element;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.SecurityHandler;
+
+/**
+ * Generate a service endpoint deployment for EJB endpoints
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class FileBasedSecurityHandlerEJB3 implements SecurityHandler
+{
+ public void addSecurityDomain(Element jbossWeb, Deployment dep)
+ {
+ String securityDomain = null;
+
+ Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
+ if (ejb3Deployment != null)
+ {
+ Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
+ while (it.hasNext())
+ {
+ EJBContainer container = (EJBContainer)it.next();
+ SecurityDomain anSecurityDomain = (SecurityDomain)container.resolveAnnotation(SecurityDomain.class);
+ if (anSecurityDomain != null)
+ {
+ if (securityDomain != null && !securityDomain.equals(anSecurityDomain.value()))
+ throw new IllegalStateException("Multiple security domains not supported");
+
+ securityDomain = anSecurityDomain.value();
+ }
+ }
+ }
+
+ if (securityDomain != null)
+ {
+ if (securityDomain.startsWith("java:/jaas/") == false)
+ securityDomain = "java:/jaas/" + securityDomain;
+
+ jbossWeb.addElement("security-domain").addText(securityDomain);
+ }
+ }
+
+ public void addSecurityRoles(Element webApp, Deployment dep)
+ {
+ Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
+ if (ejb3Deployment != null)
+ {
+ Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
+ while (it.hasNext())
+ {
+ EJBContainer container = (EJBContainer)it.next();
+ RolesAllowed anRolesAllowed = (RolesAllowed)container.resolveAnnotation(RolesAllowed.class);
+ if (anRolesAllowed != null)
+ {
+ for (String role : anRolesAllowed.value())
+ {
+ webApp.addElement("security-role").addElement("role-name").addText(role);
+ }
+ }
+ }
+ }
+ }
+}
Copied: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebAppGeneratorDeploymentAspect.java (from rev 69990, trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebApp50GeneratorDeploymentAspect.java)
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebAppGeneratorDeploymentAspect.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebAppGeneratorDeploymentAspect.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,54 @@
+/*
+ * 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.wsf.container.jboss50;
+
+// $Id: WebAppDeployerDeployer.java 3772 2007-07-01 19:29:13Z thomas.diesler at jboss.com $
+
+import org.dom4j.Document;
+import org.jboss.wsf.framework.deployment.WebAppGeneratorDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.SecurityHandler;
+
+/**
+ * Add doctype declarations to the generated descriptors
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Oct-2007
+ */
+public class FileBasedWebAppGeneratorDeploymentAspect extends WebAppGeneratorDeploymentAspect
+{
+ @Override
+ protected Document createWebAppDescriptor(Deployment dep, SecurityHandler securityHandler)
+ {
+ Document document = super.createWebAppDescriptor(dep, securityHandler);
+ document.addDocType("web-app", "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", "http://java.sun.com/dtd/web-app_2_3.dtd");
+ return document;
+ }
+
+ @Override
+ protected Document createJBossWebAppDescriptor(Deployment dep, SecurityHandler securityHandler)
+ {
+ Document document = super.createJBossWebAppDescriptor(dep, securityHandler);
+ document.addDocType("jboss-web", "-//JBoss//DTD Web Application 5.0//EN", "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd");
+ return document;
+ }
+}
Modified: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebMetaDataModifier.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebMetaDataModifier.java 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/FileBasedWebMetaDataModifier.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -55,6 +55,9 @@
public RewriteResults modifyMetaData(Deployment dep)
{
URL warURL = (URL)dep.getProperty(WebMetaDataModifier.PROPERTY_WEBAPP_URL);
+ if (warURL == null)
+ throw new IllegalStateException("Cannot obtain generated webapp URL");
+
File warFile = new File(warURL.getFile());
if (warFile.isDirectory() == false)
throw new WebServiceException("Expected a war directory: " + warURL);
Added: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/InMemoryWebAppGeneratorDeploymentAspect.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/InMemoryWebAppGeneratorDeploymentAspect.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/InMemoryWebAppGeneratorDeploymentAspect.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,264 @@
+/*
+ * 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.wsf.container.jboss50;
+
+// $Id$
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.LoginConfigMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
+
+/**
+ * A deployment aspect that generates a webapp for an EJB endpoint
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Oct-2007
+ */
+public class InMemoryWebAppGeneratorDeploymentAspect extends DeploymentAspect
+{
+ private WebMetaDataSecurityHandler securityHandlerEJB21;
+ private WebMetaDataSecurityHandler securityHandlerEJB3;
+
+ public void setSecurityHandlerEJB21(WebMetaDataSecurityHandler handler)
+ {
+ this.securityHandlerEJB21 = handler;
+ }
+
+ public void setSecurityHandlerEJB3(WebMetaDataSecurityHandler handler)
+ {
+ this.securityHandlerEJB3 = handler;
+ }
+
+ @Override
+ public void create(Deployment dep)
+ {
+ String typeStr = dep.getType().toString();
+ if (typeStr.endsWith("EJB21"))
+ {
+ JBossWebMetaData jbwmd = generatWebDeployment((ArchiveDeployment)dep, securityHandlerEJB21);
+ dep.addAttachment(JBossWebMetaData.class, jbwmd);
+ }
+ else if (typeStr.endsWith("EJB3"))
+ {
+ JBossWebMetaData jbwmd = generatWebDeployment((ArchiveDeployment)dep, securityHandlerEJB3);
+ dep.addAttachment(JBossWebMetaData.class, jbwmd);
+ }
+ else
+ {
+ JBossWebMetaData jbwmd = generatWebDeployment((ArchiveDeployment)dep, null);
+ dep.addAttachment(JBossWebMetaData.class, jbwmd);
+ }
+ }
+
+ protected JBossWebMetaData generatWebDeployment(ArchiveDeployment dep, WebMetaDataSecurityHandler securityHandler)
+ {
+ JBossWebMetaData jbwmd = new JBossWebMetaData();
+ createWebAppDescriptor(dep, jbwmd, securityHandler);
+ createJBossWebAppDescriptor(dep, jbwmd, securityHandler);
+ return jbwmd;
+ }
+
+ protected void createWebAppDescriptor(Deployment dep, JBossWebMetaData jbwmd, WebMetaDataSecurityHandler securityHandler)
+ {
+ /*
+ <servlet>
+ <servlet-name>
+ <servlet-class>
+ </servlet>
+ */
+ JBossServletsMetaData servlets = jbwmd.getServlets();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ JBossServletMetaData servlet = new JBossServletMetaData();
+ servlet.setServletName(ep.getShortName());
+ servlet.setServletClass(ep.getTargetBeanName());
+ servlets.add(servlet);
+ }
+
+ /*
+ <servlet-mapping>
+ <servlet-name>
+ <url-pattern>
+ </servlet-mapping>
+ */
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ List<ServletMappingMetaData> servletMappings = jbwmd.getServletMappings();
+ if (servletMappings == null)
+ {
+ servletMappings = new ArrayList<ServletMappingMetaData>();
+ jbwmd.setServletMappings(servletMappings);
+ }
+ ServletMappingMetaData servletMapping = new ServletMappingMetaData();
+ servletMapping.setServletName(ep.getShortName());
+ servletMapping.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
+ servletMappings.add(servletMapping);
+ }
+
+ String authMethod = null;
+
+ // Add web-app/security-constraint for each port component
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ String ejbName = ep.getShortName();
+
+ Boolean secureWSDLAccess = null;
+ String transportGuarantee = null;
+ String beanAuthMethod = null;
+
+ WebContext anWebContext = (WebContext)ep.getTargetBeanClass().getAnnotation(WebContext.class);
+ if (anWebContext != null)
+ {
+ if (anWebContext.authMethod().length() > 0)
+ beanAuthMethod = anWebContext.authMethod();
+ if (anWebContext.transportGuarantee().length() > 0)
+ transportGuarantee = anWebContext.transportGuarantee();
+ if (anWebContext.secureWSDLAccess())
+ secureWSDLAccess = anWebContext.secureWSDLAccess();
+ }
+
+ EJBArchiveMetaData appMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (appMetaData != null && appMetaData.getBeanByEjbName(ejbName) != null)
+ {
+ EJBMetaData bmd = appMetaData.getBeanByEjbName(ejbName);
+ EJBSecurityMetaData smd = bmd.getSecurityMetaData();
+ if (smd != null)
+ {
+ beanAuthMethod = smd.getAuthMethod();
+ transportGuarantee = smd.getTransportGuarantee();
+ secureWSDLAccess = smd.getSecureWSDLAccess();
+ }
+ }
+
+ if (beanAuthMethod != null || transportGuarantee != null)
+ {
+ /*
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>TestUnAuthPort</web-resource-name>
+ <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+ */
+ List<SecurityConstraintMetaData> securityContraints = jbwmd.getSecurityContraints();
+ if (securityContraints == null)
+ {
+ securityContraints = new ArrayList<SecurityConstraintMetaData>();
+ jbwmd.setSecurityContraints(securityContraints);
+ }
+ SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
+ WebResourceCollectionsMetaData resourceCollections = securityConstraint.getResourceCollections();
+ if (resourceCollections == null)
+ {
+ resourceCollections = new WebResourceCollectionsMetaData();
+ securityConstraint.setResourceCollections(resourceCollections);
+ }
+ WebResourceCollectionMetaData wrc = new WebResourceCollectionMetaData();
+ wrc.setWebResourceName(ejbName);
+ wrc.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
+ ArrayList<String> httpMethods = new ArrayList<String>();
+ wrc.setHttpMethods(httpMethods);
+ if (Boolean.TRUE.equals(secureWSDLAccess))
+ {
+ httpMethods.add("GET");
+ }
+ httpMethods.add("POST");
+
+ // Optional auth-constraint
+ if (beanAuthMethod != null)
+ {
+ // Only the first auth-method gives the war login-config/auth-method
+ if (authMethod == null)
+ authMethod = beanAuthMethod;
+
+ AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
+ authConstraint.setRoleNames(Arrays.asList(new String[] { "*" }));
+ securityConstraint.setAuthConstraint(authConstraint);
+ }
+ // Optional user-data-constraint
+ if (transportGuarantee != null)
+ {
+ UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
+ userDataConstraint.setTransportGuarantee(TransportGuaranteeType.valueOf(transportGuarantee));
+ securityConstraint.setUserDataConstraint(userDataConstraint);
+ }
+ }
+ }
+
+ // Optional login-config/auth-method
+ if (authMethod != null && securityHandler != null)
+ {
+ LoginConfigMetaData loginConfig = jbwmd.getLoginConfig();
+ loginConfig.setAuthMethod(authMethod);
+ loginConfig.setRealmName("EJBServiceEndpointServlet Realm");
+
+ securityHandler.addSecurityRoles(jbwmd, dep);
+ }
+ }
+
+ protected void createJBossWebAppDescriptor(Deployment dep, JBossWebMetaData jbwmd, WebMetaDataSecurityHandler securityHandler)
+ {
+ /* Create a jboss-web
+ <jboss-web>
+ <security-domain>java:/jaas/cts</security-domain>
+ <context-root>/ws/ejbN/</context-root>
+ <virtual-host>some.domain.com</virtual-host>
+ </jboss-web>
+ */
+ if (securityHandler != null)
+ securityHandler.addSecurityDomain(jbwmd, dep);
+
+ // Get the context root for this deployment
+ String contextRoot = dep.getService().getContextRoot();
+ if (contextRoot == null)
+ throw new WSFDeploymentException("Cannot obtain context root");
+
+ jbwmd.setContextRoot(contextRoot);
+ }
+}
Property changes on: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/InMemoryWebAppGeneratorDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/ModifyWebMetaDataDeploymentAspect.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/ModifyWebMetaDataDeploymentAspect.java 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/ModifyWebMetaDataDeploymentAspect.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -23,17 +23,9 @@
//$Id: ModifyWebMetaDataDeployer.java 3150 2007-05-20 00:29:48Z thomas.diesler at jboss.com $
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.metadata.javaee.spec.ParamValueMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.spec.ListenerMetaData;
-import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
-import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
/**
* A deployer that modifies the web.xml meta data
@@ -43,130 +35,23 @@
*/
public class ModifyWebMetaDataDeploymentAspect extends DeploymentAspect
{
- @Override
- public void create(Deployment dep)
+ private WebMetaDataModifier webMetaDataModifier;
+
+ public void setWebMetaDataModifier(WebMetaDataModifier webMetaDataModifier)
{
- String servletClass = (String)dep.getProperty(WebMetaDataModifier.PROPERTY_WEBAPP_SERVLET_CLASS);
- if (servletClass == null)
- throw new IllegalStateException("Cannot obtain context property: " + WebMetaDataModifier.PROPERTY_WEBAPP_SERVLET_CLASS);
-
- modifyServletClass(dep, servletClass);
-
- String listenerClass = (String)dep.getProperty(WebMetaDataModifier.PROPERTY_WEBAPP_SERVLET_CONTEXT_LISTENER);
- if (listenerClass != null)
- modifyListener(dep, listenerClass);
-
- Map<String, String> contextParams = (Map<String, String>)dep.getProperty(WebMetaDataModifier.PROPERTY_WEBAPP_CONTEXT_PARAMETERS);
- if (contextParams != null)
- modifyContextParams(dep, contextParams);
+ this.webMetaDataModifier = webMetaDataModifier;
}
- private void modifyServletClass(Deployment dep, String servletClass)
+ @Override
+ public void create(Deployment dep)
{
- JBossWebMetaData webMetaData = dep.getAttachment(JBossWebMetaData.class);
- if (webMetaData != null)
+ try
{
- for (ServletMetaData servlet : webMetaData.getServlets())
- {
- String endpointClass = servlet.getServletClass();
-
- // JSP
- if (endpointClass == null || endpointClass.length() == 0)
- {
- log.debug("Ignore servlet class: " + endpointClass);
- continue;
- }
-
- // Nothing to do if we have an <init-param>
- if (!isAlreadyModified(servlet) && !isJavaxServlet(endpointClass, dep.getInitialClassLoader()))
- {
- servlet.setServletClass(servletClass);
- ParamValueMetaData initParam = new ParamValueMetaData();
- initParam.setParamName(Endpoint.SEPID_DOMAIN_ENDPOINT);
- initParam.setParamValue(endpointClass);
- List<ParamValueMetaData> initParams = servlet.getInitParam();
- if (initParams == null)
- {
- initParams = new ArrayList<ParamValueMetaData>();
- servlet.setInitParam(initParams);
- }
- initParams.add(initParam);
- }
- }
+ webMetaDataModifier.modifyMetaData(dep);
}
- }
-
- private void modifyListener(Deployment dep, String listenerClass)
- {
- JBossWebMetaData webMetaData = dep.getAttachment(JBossWebMetaData.class);
- if (webMetaData != null)
+ catch (Exception ex)
{
- ListenerMetaData listener = new ListenerMetaData();
- listener.setListenerClass(listenerClass);
- List<ListenerMetaData> listeners = webMetaData.getListeners();
- if (listeners == null)
- {
- listeners = new ArrayList<ListenerMetaData>();
- webMetaData.setListeners(listeners);
- }
- listeners.add(listener);
+ WSFDeploymentException.rethrow(ex);
}
}
-
- private void modifyContextParams(Deployment dep, Map<String, String> newParams)
- {
- JBossWebMetaData webMetaData = dep.getAttachment(JBossWebMetaData.class);
- if (webMetaData != null)
- {
- for (Map.Entry<String, String> entry : newParams.entrySet())
- {
- ParamValueMetaData ctxParam = new ParamValueMetaData();
- ctxParam.setParamName(entry.getKey());
- ctxParam.setParamValue(entry.getValue());
- List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
- if (contextParams == null)
- {
- contextParams = new ArrayList<ParamValueMetaData>();
- webMetaData.setContextParams(contextParams);
- }
- contextParams.add(ctxParam);
- }
- }
- }
-
- private boolean isJavaxServlet(String orgServletClass, ClassLoader loader)
- {
- boolean isServlet = false;
- if (loader != null)
- {
- try
- {
- Class servletClass = loader.loadClass(orgServletClass);
- isServlet = javax.servlet.Servlet.class.isAssignableFrom(servletClass);
- if (isServlet == true)
- {
- log.info("Ignore servlet: " + orgServletClass);
- }
- }
- catch (ClassNotFoundException e)
- {
- log.warn("Cannot load servlet class: " + orgServletClass);
- }
- }
- return isServlet;
- }
-
- private boolean isAlreadyModified(ServletMetaData servlet)
- {
- List<ParamValueMetaData> initParams = servlet.getInitParam();
- if (initParams != null)
- {
- for (ParamValueMetaData param : initParams)
- {
- if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(param.getParamName()))
- return true;
- }
- }
- return false;
- }
}
Deleted: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -1,81 +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.wsf.container.jboss50;
-
-//$Id: SecurityHandlerEJB21.java 4013 2007-07-27 04:37:52Z thomas.diesler at jboss.com $
-
-import org.dom4j.Element;
-import org.jboss.metadata.common.ejb.IAssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.SecurityHandler;
-import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Generate a service endpoint deployment for EJB endpoints
- *
- * @author Thomas.Diesler at jboss.org
- * @since 12-May-2006
- */
-public class SecurityHandlerEJB21 implements SecurityHandler
-{
- public void addSecurityDomain(Element jbossWeb, Deployment dep)
- {
- EJBArchiveMetaData ejbMetaData = dep.getAttachment(EJBArchiveMetaData.class);
- if (ejbMetaData == null)
- throw new IllegalStateException("Cannot obtain application meta data");
-
- String securityDomain = ejbMetaData.getSecurityDomain();
- if (securityDomain != null)
- {
- if (securityDomain.startsWith("java:/jaas/") == false)
- securityDomain = "java:/jaas/" + securityDomain;
-
- jbossWeb.addElement("security-domain").addText(securityDomain);
- }
- }
-
- public void addSecurityRoles(Element webApp, Deployment dep)
- {
- // Fix: http://jira.jboss.org/jira/browse/JBWS-309
- JBossMetaData jbmd = dep.getAttachment(JBossMetaData.class);
- IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
- if (assemblyDescriptor != null)
- {
- SecurityRolesMetaData srmd = assemblyDescriptor.getSecurityRoles();
- if (srmd != null)
- {
- Iterator it = srmd.keySet().iterator();
- while (it.hasNext())
- {
- webApp.addElement("security-role").addElement("role-name").addText((String)it.next());
- }
- }
- }
- }
-}
Deleted: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB3.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB3.java 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB3.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -1,96 +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.wsf.container.jboss50;
-
-//$Id: SecurityHandlerEJB3.java 4011 2007-07-27 02:45:35Z thomas.diesler at jboss.com $
-
-import java.util.Iterator;
-
-import javax.annotation.security.RolesAllowed;
-
-import org.dom4j.Element;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.SecurityHandler;
-
-/**
- * Generate a service endpoint deployment for EJB endpoints
- *
- * @author Thomas.Diesler at jboss.org
- * @since 12-May-2006
- */
-public class SecurityHandlerEJB3 implements SecurityHandler
-{
- public void addSecurityDomain(Element jbossWeb, Deployment dep)
- {
- String securityDomain = null;
-
- Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment != null)
- {
- Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
- while (it.hasNext())
- {
- EJBContainer container = (EJBContainer)it.next();
- SecurityDomain anSecurityDomain = (SecurityDomain)container.resolveAnnotation(SecurityDomain.class);
- if (anSecurityDomain != null)
- {
- if (securityDomain != null && !securityDomain.equals(anSecurityDomain.value()))
- throw new IllegalStateException("Multiple security domains not supported");
-
- securityDomain = anSecurityDomain.value();
- }
- }
- }
-
- if (securityDomain != null)
- {
- if (securityDomain.startsWith("java:/jaas/") == false)
- securityDomain = "java:/jaas/" + securityDomain;
-
- jbossWeb.addElement("security-domain").addText(securityDomain);
- }
- }
-
- public void addSecurityRoles(Element webApp, Deployment dep)
- {
- Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment != null)
- {
- Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
- while (it.hasNext())
- {
- EJBContainer container = (EJBContainer)it.next();
- RolesAllowed anRolesAllowed = (RolesAllowed)container.resolveAnnotation(RolesAllowed.class);
- if (anRolesAllowed != null)
- {
- for (String role : anRolesAllowed.value())
- {
- webApp.addElement("security-role").addElement("role-name").addText(role);
- }
- }
- }
- }
- }
-}
Deleted: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebApp50GeneratorDeploymentAspect.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebApp50GeneratorDeploymentAspect.java 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebApp50GeneratorDeploymentAspect.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -1,54 +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.wsf.container.jboss50;
-
-// $Id: WebAppDeployerDeployer.java 3772 2007-07-01 19:29:13Z thomas.diesler at jboss.com $
-
-import org.dom4j.Document;
-import org.jboss.wsf.framework.deployment.WebAppGeneratorDeploymentAspect;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.SecurityHandler;
-
-/**
- * Add doctype declarations to the generated descriptors
- *
- * @author Thomas.Diesler at jboss.org
- * @since 13-Oct-2007
- */
-public class WebApp50GeneratorDeploymentAspect extends WebAppGeneratorDeploymentAspect
-{
- @Override
- protected Document createWebAppDescriptor(Deployment dep, SecurityHandler securityHandler)
- {
- Document document = super.createWebAppDescriptor(dep, securityHandler);
- document.addDocType("web-app", "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", "http://java.sun.com/dtd/web-app_2_3.dtd");
- return document;
- }
-
- @Override
- protected Document createJBossWebAppDescriptor(Deployment dep, SecurityHandler securityHandler)
- {
- Document document = super.createJBossWebAppDescriptor(dep, securityHandler);
- document.addDocType("jboss-web", "-//JBoss//DTD Web Application 5.0//EN", "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd");
- return document;
- }
-}
Added: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandler.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandler.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandler.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,42 @@
+/*
+ * 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.wsf.container.jboss50;
+
+//$Id$
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Handle web app security meta data
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public interface WebMetaDataSecurityHandler
+{
+ /** Add the security domain to jboss-web.xml */
+ void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep);
+
+ /** Add the security roles to web.xml */
+ void addSecurityRoles(JBossWebMetaData webApp, Deployment dep);
+}
Property changes on: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB21.java (from rev 69990, trunk/webservices/src/main/org/jboss/wsf/container/jboss50/SecurityHandlerEJB21.java)
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB21.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB21.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,68 @@
+/*
+ * 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.wsf.container.jboss50;
+
+//$Id: SecurityHandlerEJB21.java 4013 2007-07-27 04:37:52Z thomas.diesler at jboss.com $
+
+import org.jboss.metadata.common.ejb.IAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+/**
+ * Handle web app security meta data for EJB21
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class WebMetaDataSecurityHandlerEJB21 implements WebMetaDataSecurityHandler
+{
+ public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+ {
+ EJBArchiveMetaData ejbMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (ejbMetaData == null)
+ throw new IllegalStateException("Cannot obtain application meta data");
+
+ String securityDomain = ejbMetaData.getSecurityDomain();
+ if (securityDomain != null)
+ {
+ if (securityDomain.startsWith("java:/jaas/") == false)
+ securityDomain = "java:/jaas/" + securityDomain;
+
+ jbossWeb.setSecurityDomain(securityDomain);
+ }
+ }
+
+ public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep)
+ {
+ JBossMetaData jbmd = dep.getAttachment(JBossMetaData.class);
+ IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
+ if (assemblyDescriptor != null)
+ {
+ SecurityRolesMetaData securityRoles = assemblyDescriptor.getSecurityRoles();
+ if (securityRoles != null)
+ webApp.setSecurityRoles(securityRoles);
+ }
+ }
+}
Added: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB3.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB3.java (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB3.java 2008-02-21 10:09:44 UTC (rev 69991)
@@ -0,0 +1,100 @@
+/*
+ * 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.wsf.container.jboss50;
+
+//$Id$
+
+import java.util.Iterator;
+
+import javax.annotation.security.RolesAllowed;
+
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Handle web app security meta data for EJB3
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class WebMetaDataSecurityHandlerEJB3 implements WebMetaDataSecurityHandler
+{
+ public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+ {
+ String securityDomain = null;
+
+ Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
+ if (ejb3Deployment != null)
+ {
+ Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
+ while (it.hasNext())
+ {
+ EJBContainer container = (EJBContainer)it.next();
+ SecurityDomain anSecurityDomain = (SecurityDomain)container.resolveAnnotation(SecurityDomain.class);
+ if (anSecurityDomain != null)
+ {
+ if (securityDomain != null && !securityDomain.equals(anSecurityDomain.value()))
+ throw new IllegalStateException("Multiple security domains not supported");
+
+ securityDomain = anSecurityDomain.value();
+ }
+ }
+ }
+
+ if (securityDomain != null)
+ {
+ if (securityDomain.startsWith("java:/jaas/") == false)
+ securityDomain = "java:/jaas/" + securityDomain;
+
+ jbossWeb.setSecurityDomain(securityDomain);
+ }
+ }
+
+ public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep)
+ {
+ Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
+ if (ejb3Deployment != null)
+ {
+ Iterator it = ejb3Deployment.getEjbContainers().values().iterator();
+ while (it.hasNext())
+ {
+ EJBContainer container = (EJBContainer)it.next();
+ RolesAllowed anRolesAllowed = (RolesAllowed)container.resolveAnnotation(RolesAllowed.class);
+ if (anRolesAllowed != null)
+ {
+ SecurityRolesMetaData securityRoles = webApp.getSecurityRoles();
+ for (String roleName : anRolesAllowed.value())
+ {
+ SecurityRoleMetaData role = new SecurityRoleMetaData();
+ role.setRoleName(roleName);
+ securityRoles.add(role);
+ }
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/webservices/src/main/org/jboss/wsf/container/jboss50/WebMetaDataSecurityHandlerEJB3.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/webservices/src/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-beans.xml
===================================================================
--- trunk/webservices/src/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-beans.xml 2008-02-21 06:16:44 UTC (rev 69990)
+++ trunk/webservices/src/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-beans.xml 2008-02-21 10:09:44 UTC (rev 69991)
@@ -2,91 +2,101 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Locate the single instance of the kernel -->
+ <!-- Locate the single instance of the kernel -->
<bean name="WSKernelLocator" class="org.jboss.wsf.spi.util.KernelLocator">
- <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+ <property name="kernel">
+ <inject bean="jboss.kernel:service=Kernel"/>
+ </property>
</bean>
- <!-- Locate the single instance of the MBeanServer -->
+ <!-- Locate the single instance of the MBeanServer -->
<bean name="WSMBeanServerLocator" class="org.jboss.wsf.framework.management.MBeanServerLocator">
- <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+ <property name="mbeanServer">
+ <inject bean="JMXKernel" property="mbeanServer"/>
+ </property>
</bean>
- <!-- The HTTPServer used by the JAXWS Endpoint API -->
+ <!-- The HTTPServer used by the JAXWS Endpoint API -->
<bean name="WSHTTPServer" class="org.jboss.wsf.container.jboss50.DeploymentAspectHttpServer"/>
- <!--
- *********************************************************************************************************************
- Web Service deployment
-
- There are two deployers registered with the JBoss Main Deployer.
- The order of which is important
-
- 1) EJBDeployer < WebServiceDeployerEJB
- 2) WebServiceDeployerPreJSE < WarDeployer
- 3) WarDeployer < WebServiceDeployerPostJSE
-
- Each WebServiceDeployer has a number of DeployerHooks registered with it
-
- - WebServiceDeployerEJB
- - WSDeployerHook_JAXRPC_EJB21
- - WSDeployerHook_JAXWS_EJB3
-
- - WebServiceDeployerPreJSE
- - WSDeployerHook_JAXRPC_JSE
- - WSDeployerHook_JAXWS_JSE
-
- Conceptually, each of these hooks implements the following pattern:
-
- DeployerHook.deploy(unit)
- if(isWebServiceDeployment)
- Deployment dep = createDeployment(unit)
- DeploymentAspectManager.deploy(dep)
-
- DeployerHook.undeploy(unit)
- Deployment dep = getDeployment(unit)
- DeploymentAspectManager.undeploy(dep)
-
- Each deployer hook has a web service DeploymentAspectManager injected into it.
- A web service DeploymentAspectManager maintains a list of DeploymentAspects, each of which
- handles a single aspect of web service deployment.
-
- Finally, each Endpoint is registered with the EndpointRegistry.
-
- *********************************************************************************************************************
- -->
+ <!-- *********************************************************************************************************************
+ Web Service deployment
+ There are two deployers registered with the JBoss Main Deployer.
+ The order of which is important
+
+ 1) EJBDeployer < WebServiceDeployerEJB
+ 2) WebServiceDeployerPreJSE < WarDeployer
+ 3) WarDeployer < WebServiceDeployerPostJSE
+
+ Each WebServiceDeployer has a number of DeployerHooks registered with it
+
+ - WebServiceDeployerEJB
+ - WSDeployerHook_JAXRPC_EJB21
+ - WSDeployerHook_JAXWS_EJB3
+
+ - WebServiceDeployerPreJSE
+ - WSDeployerHook_JAXRPC_JSE
+ - WSDeployerHook_JAXWS_JSE
+
+ Conceptually, each of these hooks implements the following pattern:
+
+ DeployerHook.deploy(unit)
+ if(isWebServiceDeployment)
+ Deployment dep = createDeployment(unit)
+ DeploymentAspectManager.deploy(dep)
+
+ DeployerHook.undeploy(unit)
+ Deployment dep = getDeployment(unit)
+ DeploymentAspectManager.undeploy(dep)
+
+ Each deployer hook has a web service DeploymentAspectManager injected into it.
+ A web service DeploymentAspectManager maintains a list of DeploymentAspects, each of which
+ handles a single aspect of web service deployment.
+
+ Finally, each Endpoint is registered with the EndpointRegistry.
+
+ ********************************************************************************************************************* -->
+
<!--
- A web service deployer that hooks in after the EJB deployers
+ A web service deployer that hooks in after the EJB deployers
-->
<bean name="WebServiceDeployerEJB" class="org.jboss.wsf.container.jboss50.WebServiceDeployerEJB">
- <property name="relOrderEJB2x"><inject bean="EJB2xDeployer" property="relativeOrder"/></property>
- <property name="relOrderEJB3"><inject bean="Ejb3Deployer" property="relativeOrder"/></property>
+ <property name="relOrderEJB2x">
+ <inject bean="EJB2xDeployer" property="relativeOrder"/>
+ </property>
+ <property name="relOrderEJB3">
+ <inject bean="Ejb3Deployer" property="relativeOrder"/>
+ </property>
<depends>EJB2xDeployer</depends>
<depends>Ejb3Deployer</depends>
</bean>
<!--
- A web service deployer that hooks in before the WAR deployer
+ A web service deployer that hooks in before the WAR deployer
-->
<bean name="WebServiceDeployerPreJSE" class="org.jboss.wsf.container.jboss50.WebServiceDeployerPreJSE">
- <property name="relOrderWar"><inject bean="WarDeployer" property="relativeOrder"/></property>
+ <property name="relOrderWar">
+ <inject bean="WarDeployer" property="relativeOrder"/>
+ </property>
<depends>WebAppParsingDeployer</depends>
</bean>
-
+
<!--
- A web service deployer that hooks in after the WAR deployer
- This deployer depends on the RuntimeClassloader being available.
+ A web service deployer that hooks in after the WAR deployer
+ This deployer depends on the RuntimeClassloader being available.
-->
<bean name="WebServiceDeployerPostJSE" class="org.jboss.wsf.container.jboss50.WebServiceDeployerPostJSE">
- <property name="relOrderWar"><inject bean="WarDeployer" property="relativeOrder"/></property>
+ <property name="relOrderWar">
+ <inject bean="WarDeployer" property="relativeOrder"/>
+ </property>
<depends>WebAppParsingDeployer</depends>
</bean>
<!--
- Register DeployerHooks with JBoss deployers
+ Register DeployerHooks with JBoss deployers
-->
-
+
<!-- Phase 1 of JSE JAX-RPC -->
<bean name="WSDeployerHook_JAXRPC_PRE_JSE" class="org.jboss.wsf.container.jboss50.JAXRPCDeployerHookPreJSE">
<property name="deploymentManagerName">WSDeploymentAspectManagerPreJSE</property>
@@ -117,7 +127,7 @@
</uninstall>
<depends>WebServiceDeployerPostJSE</depends>
</bean>
-
+
<bean name="WSDeployerHook_JAXRPC_EJB21" class="org.jboss.wsf.container.jboss50.JAXRPCDeployerHookEJB21">
<property name="deploymentManagerName">WSDeploymentAspectManagerEJB</property>
<install bean="WebServiceDeployerEJB" method="addDeployerHook">
@@ -132,7 +142,7 @@
</uninstall>
<depends>WebServiceDeployerEJB</depends>
</bean>
-
+
<!-- Phase 1 of JSE JAX-WS-->
<bean name="WSDeployerHook_JAXWS_PRE_JSE" class="org.jboss.wsf.container.jboss50.JAXWSDeployerHookPreJSE">
<property name="deploymentManagerName">WSDeploymentAspectManagerPreJSE</property>
@@ -163,7 +173,7 @@
</uninstall>
<depends>WebServiceDeployerPostJSE</depends>
</bean>
-
+
<bean name="WSDeployerHook_JAXWS_EJB3" class="org.jboss.wsf.container.jboss50.JAXWSDeployerHookEJB3">
<property name="deploymentManagerName">WSDeploymentAspectManagerEJB</property>
<install bean="WebServiceDeployerEJB" method="addDeployerHook">
@@ -180,13 +190,15 @@
</bean>
<!--
- Each DeploymentAspectManger maintains a list of DeploymentAspects
+ Each DeploymentAspectManger maintains a list of DeploymentAspects
-->
<bean name="WSDeploymentAspectManagerPreJSE" class="org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl">
<property name="name">WSDeploymentAspectManagerPreJSE</property>
</bean>
<bean name="WSDeploymentAspectManagerPostJSE" class="org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl">
- <property name="parent"><inject bean="WSDeploymentAspectManagerPreJSE"/></property>
+ <property name="parent">
+ <inject bean="WSDeploymentAspectManagerPreJSE"/>
+ </property>
<property name="name">WSDeploymentAspectManagerPostJSE</property>
</bean>
<bean name="WSDeploymentAspectManagerEJB" class="org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl">
@@ -197,8 +209,8 @@
</bean>
<!--
- The container deployment aspects
- -->
+ The container deployment aspects
+ -->
<bean name="WSContainerMetaDataDeploymentAspect" class="org.jboss.wsf.container.jboss50.ContainerMetaDataDeploymentAspect">
<property name="provides">ContainerMetaData, VFSRoot</property>
</bean>
@@ -219,15 +231,15 @@
<bean name="WSEndpointHandlerDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointHandlerDeploymentAspect">
<property name="requires">ContainerMetaData</property>
- <property name="provides">ContainerEndpointHandler</property>
+ <property name="provides">ContainerEndpointHandler</property>
</bean>
-
+
<bean name="WSEndpointLifecycleDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointLifecycleDeploymentAspect">
<property name="requires">LAST_DEPLOYMENT_ASPECT</property>
</bean>
-
+
<bean name="WSEndpointMetricsDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointMetricsDeploymentAspect">
- <property name="provides">EndpointMetrics</property>
+ <property name="provides">EndpointMetrics</property>
</bean>
<bean name="WSEndpointNameDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointNameDeploymentAspect">
@@ -242,6 +254,9 @@
<bean name="WSModifyWebMetaDataDeploymentAspect" class="org.jboss.wsf.container.jboss50.ModifyWebMetaDataDeploymentAspect">
<property name="requires">ContextProperties, StackDescriptor</property>
+ <property name="webMetaDataModifier">
+ <inject bean="WSMemoryWebMetaDataModifier"/>
+ </property>
</bean>
<bean name="WSRuntimeLoaderDeploymentAspect" class="org.jboss.wsf.container.jboss50.RuntimeLoaderDeploymentAspect">
@@ -256,27 +271,38 @@
<bean name="WSWebAppDeploymentAspect" class="org.jboss.wsf.container.jboss50.WebAppDeploymentAspect">
<property name="requires">WebMetaData, ContextProperties</property>
- <property name="webMetaDataModifier"><inject bean="WSWebMetaDataModifier"/></property>
- <property name="mainDeployer"><inject bean="MainDeployer"/></property>
+ <property name="webMetaDataModifier">
+ <inject bean="WSFileWebMetaDataModifier"/>
+ </property>
+ <property name="mainDeployer">
+ <inject bean="MainDeployer"/>
+ </property>
</bean>
- <bean name="WSWebAppGeneratorDeploymentAspect" class="org.jboss.wsf.container.jboss50.WebApp50GeneratorDeploymentAspect">
+ <bean name="WSWebAppGeneratorDeploymentAspect" class="org.jboss.wsf.container.jboss50.FileBasedWebAppGeneratorDeploymentAspect">
<property name="requires">URLPattern</property>
<property name="provides">WebMetaData</property>
- <property name="securityHandlerEJB21"><inject bean="WSSecurityHandlerEJB21"/></property>
- <property name="securityHandlerEJB3"><inject bean="WSSecurityHandlerEJB3"/></property>
+ <property name="securityHandlerEJB21">
+ <inject bean="WSSecurityHandlerEJB21"/>
+ </property>
+ <property name="securityHandlerEJB3">
+ <inject bean="WSSecurityHandlerEJB3"/>
+ </property>
</bean>
-
+
<!-- Deployment aspect helper beans -->
- <bean name="WSSecurityHandlerEJB21" class="org.jboss.wsf.container.jboss50.SecurityHandlerEJB21"/>
- <bean name="WSSecurityHandlerEJB3" class="org.jboss.wsf.container.jboss50.SecurityHandlerEJB3"/>
- <bean name="WSWebMetaDataModifier" class="org.jboss.wsf.container.jboss50.FileBasedWebMetaDataModifier"/>
+ <bean name="WSSecurityHandlerEJB21" class="org.jboss.wsf.container.jboss50.FileBasedSecurityHandlerEJB21"/>
+ <bean name="WSSecurityHandlerEJB3" class="org.jboss.wsf.container.jboss50.FileBasedSecurityHandlerEJB3"/>
+ <bean name="WSFileWebMetaDataModifier" class="org.jboss.wsf.container.jboss50.FileBasedWebMetaDataModifier"/>
+ <bean name="WSMemoryWebMetaDataModifier" class="org.jboss.wsf.container.jboss50.InMemoryWebMetaDataModifier"/>
<!-- Deployment aspect installers -->
-
+
<!-- Phase 1 -->
<bean name="WSDeploymentAspectInstallerPreJSE" class="org.jboss.wsf.framework.deployment.DeploymentAspectInstaller">
- <property name="manager"><inject bean="WSDeploymentAspectManagerPreJSE"/></property>
+ <property name="manager">
+ <inject bean="WSDeploymentAspectManagerPreJSE"/>
+ </property>
<property name="sortAspectsOnCreate">false</property>
<property name="aspects">
<set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
@@ -287,15 +313,17 @@
<inject bean="WSEndpointMetricsDeploymentAspect"/>
<inject bean="WSEndpointNameDeploymentAspect"/>
<inject bean="WSEndpointRegistryDeploymentAspect"/>
- <inject bean="WSModifyWebMetaDataDeploymentAspect"/>
+ <inject bean="WSModifyWebMetaDataDeploymentAspect"/>
<inject bean="WSURLPatternDeploymentAspect"/>
</set>
</property>
</bean>
-
+
<!-- Phase 2 -->
<bean name="WSDeploymentAspectInstallerPostJSE" class="org.jboss.wsf.framework.deployment.DeploymentAspectInstaller">
- <property name="manager"><inject bean="WSDeploymentAspectManagerPostJSE"/></property>
+ <property name="manager">
+ <inject bean="WSDeploymentAspectManagerPostJSE"/>
+ </property>
<property name="sortAspectsOnCreate">false</property>
<property name="aspects">
<set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
@@ -306,7 +334,9 @@
</bean>
<bean name="WSDeploymentAspectInstallerEJB" class="org.jboss.wsf.framework.deployment.DeploymentAspectInstaller">
- <property name="manager"><inject bean="WSDeploymentAspectManagerEJB"/></property>
+ <property name="manager">
+ <inject bean="WSDeploymentAspectManagerEJB"/>
+ </property>
<property name="sortAspectsOnCreate">false</property>
<property name="aspects">
<set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
@@ -327,7 +357,9 @@
</bean>
<bean name="WSDeploymentAspectInstallerEndpointAPI" class="org.jboss.wsf.framework.deployment.DeploymentAspectInstaller">
- <property name="manager"><inject bean="WSDeploymentAspectManagerEndpointAPI"/></property>
+ <property name="manager">
+ <inject bean="WSDeploymentAspectManagerEndpointAPI"/>
+ </property>
<property name="sortAspectsOnCreate">false</property>
<property name="aspects">
<set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
@@ -344,4 +376,4 @@
</property>
</bean>
-</deployment>
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list