0001: /*
0002: * JBoss, Home of Professional Open Source.
0003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
0004: * as indicated by the @author tags. See the copyright.txt file in the
0005: * distribution for a full listing of individual contributors.
0006: *
0007: * This is free software; you can redistribute it and/or modify it
0008: * under the terms of the GNU Lesser General Public License as
0009: * published by the Free Software Foundation; either version 2.1 of
0010: * the License, or (at your option) any later version.
0011: *
0012: * This software is distributed in the hope that it will be useful,
0013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0015: * Lesser General Public License for more details.
0016: *
0017: * You should have received a copy of the GNU Lesser General Public
0018: * License along with this software; if not, write to the Free
0019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
0021: */
0022: package org.jboss.metadata;
0023:
0024: import java.net.URLClassLoader;
0025: import java.util.ArrayList;
0026: import java.util.Collection;
0027: import java.util.HashMap;
0028: import java.util.HashSet;
0029: import java.util.Iterator;
0030: import java.util.List;
0031: import java.util.Map;
0032: import java.util.Set;
0033:
0034: import javax.management.MalformedObjectNameException;
0035:
0036: import org.jboss.deployment.DeploymentException;
0037: import org.jboss.logging.Logger;
0038: import org.jboss.metadata.serviceref.ServiceRefDelegate;
0039: import org.jboss.mx.loading.LoaderRepositoryFactory;
0040: import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
0041: import org.jboss.mx.util.ObjectNameFactory;
0042: import org.jboss.security.RunAsIdentity;
0043: import org.jboss.security.SecurityRoleMetaData;
0044: import org.jboss.ws.integration.ServiceRefMetaData;
0045: import org.w3c.dom.Element;
0046:
0047: /** A representation of the web.xml and jboss-web.xml deployment
0048: * descriptors as used by the AbstractWebContainer web container integration
0049: * support class.
0050: *
0051: * @see XmlLoadable
0052: * @see org.jboss.web.AbstractWebContainer
0053: *
0054: * @author Scott.Stark@jboss.org
0055: * @version $Revision: 62620 $
0056: */
0057: public class WebMetaData extends MetaData {
0058: private static Logger log = Logger.getLogger(WebMetaData.class);
0059:
0060: /** The web.xml servlet <String, String> */
0061: private HashMap servletClassNames = new HashMap();
0062: /** The web.xml servlet-mapping <String, String> */
0063: private HashMap servletMappings = new HashMap();
0064: /** The web.xml resource-refs <String, String> */
0065: private HashMap resourceReferences = new HashMap();
0066: /** The web.xml resource-env-refs <String, String> */
0067: private HashMap resourceEnvReferences = new HashMap();
0068: /** The web.xml message-destination-refs <String, MessageDestinationRefMetaData> */
0069: private HashMap messageDestinationReferences = new HashMap();
0070: /** The web.xml message-destination <String, MessageDestinationMetaData> */
0071: private HashMap messageDestinations = new HashMap();
0072: /** web.xml env-entrys */
0073: private ArrayList environmentEntries = new ArrayList();
0074: /** web.xml security-constraint <WebSecurityMetaData> */
0075: private ArrayList securityContraints = new ArrayList();
0076: /** The HashMap<String, SecurityRoleMetaData> for the security-roles */
0077: private HashMap securityRoles = new HashMap();
0078: /** web.xml ejb-refs */
0079: private HashMap ejbReferences = new HashMap();
0080: /** web.xml ejb-local-refs */
0081: private HashMap ejbLocalReferences = new HashMap();
0082: /** The web.xml service-refs */
0083: private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
0084: /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
0085: private HashMap securityRoleReferences = new HashMap();
0086: /** The web.xml servlet/run-as <String servlet-name, String role> */
0087: private HashMap runAsNames = new HashMap();
0088: /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity> */
0089: private HashMap runAsIdentity = new HashMap();
0090: /** The web.xml distributable flag */
0091: private boolean distributable = false;
0092: /** The jboss-web.xml class-loading.java2ClassLoadingCompliance flag */
0093: private boolean java2ClassLoadingCompliance = false;
0094: /** The jboss-web.xml class-loading jboss class loader flag */
0095: private boolean useJBossWebLoader = false;
0096: /** The jboss-web.xml class-loading/loader-repository */
0097: private LoaderRepositoryConfig loaderConfig;
0098: /** The war context root as specified at the jboss-web.xml descriptor level. */
0099: private String contextRoot;
0100: /** The JACC context id for the container */
0101: private String jaccContextID;
0102: /** The jboss-web.xml server container virtual hosts the war should be deployed into */
0103: private ArrayList virtualHosts = new ArrayList();
0104: /** The jboss-web.xml JNDI name of the security domain implementation */
0105: private String securityDomain;
0106: /** JBAS-1824: Flag whether WebResourcePermission(url,null) needed for rolename '*' */
0107: private boolean jaccRoleNameStar = false;
0108:
0109: /** The jboss-web.xml securityDomain flushOnSessionInvalidation attribute */
0110: private boolean flushOnSessionInvalidation;
0111: /** A HashMap<String, String> for webservice description publish locations */
0112: private HashMap wsdlPublishLocationMap = new HashMap();
0113: /** True if this is a web service deployment */
0114: private boolean webServiceDeployment;
0115: /** The optional JBossWS config-name */
0116: private String configName;
0117: /** The optional JBossWS config-file */
0118: private String configFile;
0119: /** The web context class loader used to create the java:comp context */
0120: private ClassLoader encLoader;
0121: /** The web context class loader, used to create the ws4ee service endpoint */
0122: private ClassLoader cxtLoader;
0123: /** ArrayList<ObjectName> of the web app dependencies */
0124: private ArrayList depends = new ArrayList();
0125:
0126: public static final int SESSION_INVALIDATE_ACCESS = 0;
0127: public static final int SESSION_INVALIDATE_SET_AND_GET = 1;
0128: public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET = 2;
0129: public static final int SESSION_INVALIDATE_SET = 3;
0130:
0131: private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
0132:
0133: public static final int REPLICATION_TYPE_SYNC = 0;
0134: public static final int REPLICATION_TYPE_ASYNC = 1;
0135:
0136: /**
0137: * @deprecated Since JBoss3.2.6.
0138: */
0139: private int replicationType = REPLICATION_TYPE_SYNC;
0140:
0141: /** Specify the session replication granularity level: session --- whole session level,
0142: * attribute --- per attribute change, field --- fine grained user object level.
0143: *
0144: */
0145: public static final int REPLICATION_GRANULARITY_SESSION = 0;
0146: public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1;
0147: public static final int REPLICATION_GRANULARITY_FIELD = 2;
0148: private int replicationGranularity = REPLICATION_GRANULARITY_SESSION;
0149:
0150: /**
0151: * If the replication granularity is FIELD, specify whether to use batch mode
0152: * for pojo replication or not.
0153: */
0154: private boolean replicationFieldBatchMode = true;
0155:
0156: /** Should the context use session cookies or use default */
0157: private int sessionCookies = SESSION_COOKIES_DEFAULT;
0158:
0159: public static final int SESSION_COOKIES_DEFAULT = 0;
0160: public static final int SESSION_COOKIES_ENABLED = 1;
0161: public static final int SESSION_COOKIES_DISABLED = 2;
0162:
0163: /** The ClassLoader to load additional resources */
0164: private URLClassLoader resourceCl;
0165:
0166: /** Set the ClassLoader to load additional resources */
0167: public void setResourceClassLoader(URLClassLoader resourceCl) {
0168: this .resourceCl = resourceCl;
0169: }
0170:
0171: /** Return an iterator of the env-entry mappings.
0172: @return Iterator of EnvEntryMetaData objects.
0173: */
0174: public Iterator getEnvironmentEntries() {
0175: return environmentEntries.iterator();
0176: }
0177:
0178: /**
0179: *
0180: * @param environmentEntries - Collection<EnvEntryMetaData>
0181: */
0182: public void setEnvironmentEntries(Collection environmentEntries) {
0183: this .environmentEntries.clear();
0184: this .environmentEntries.addAll(environmentEntries);
0185: }
0186:
0187: /** Return an iterator of the ejb-ref mappings.
0188: @return Iterator of EjbRefMetaData objects.
0189: */
0190: public Iterator getEjbReferences() {
0191: return ejbReferences.values().iterator();
0192: }
0193:
0194: /**
0195: *
0196: * @param ejbReferences - Map<String, EjbRefMetaData>
0197: */
0198: public void setEjbReferences(Map ejbReferences) {
0199: this .ejbReferences.clear();
0200: this .ejbReferences.putAll(ejbReferences);
0201: }
0202:
0203: /** Return an iterator of the ejb-local-ref mappings.
0204: @return Iterator of EjbLocalRefMetaData objects.
0205: */
0206: public Iterator getEjbLocalReferences() {
0207: return ejbLocalReferences.values().iterator();
0208: }
0209:
0210: /**
0211: *
0212: * @param ejbReferences - Map<String, EjbRefMetaData>
0213: */
0214: public void setEjbLocalReferences(Map ejbReferences) {
0215: this .ejbLocalReferences.clear();
0216: this .ejbLocalReferences.putAll(ejbReferences);
0217: }
0218:
0219: /** Return an iterator of the resource-ref mappings.
0220: @return Iterator of ResourceRefMetaData objects.
0221: */
0222: public Iterator getResourceReferences() {
0223: return resourceReferences.values().iterator();
0224: }
0225:
0226: /**
0227: *
0228: * @param resourceReferences - Map<String, ResourceRefMetaData>
0229: */
0230: public void setResourceReferences(Map resourceReferences) {
0231: this .resourceReferences.clear();
0232: this .resourceReferences.putAll(resourceReferences);
0233: }
0234:
0235: /** Return an iterator of the resource-ref mappings.
0236: @return Iterator of ResourceEnvRefMetaData objects.
0237: */
0238: public Iterator getResourceEnvReferences() {
0239: return resourceEnvReferences.values().iterator();
0240: }
0241:
0242: /**
0243: *
0244: * @param resourceReferences - Map<String, ResourceEnvRefMetaData>
0245: */
0246: public void setResourceEnvReferences(Map resourceReferences) {
0247: this .resourceEnvReferences.clear();
0248: this .resourceEnvReferences.putAll(resourceReferences);
0249: }
0250:
0251: /**
0252: * Return an iterator of message-destination-refs.
0253: *
0254: * @return Iterator of MessageDestinationRefMetaData objects.
0255: */
0256: public Iterator getMessageDestinationReferences() {
0257: return messageDestinationReferences.values().iterator();
0258: }
0259:
0260: /**
0261: *
0262: * @param messageDestinationReferences - Map<String, MessageDestinationRefMetaData>
0263: */
0264: public void setMessageDestinationReferences(
0265: Map messageDestinationReferences) {
0266: this .messageDestinationReferences.clear();
0267: this .messageDestinationReferences
0268: .putAll(messageDestinationReferences);
0269: }
0270:
0271: /**
0272: * Get a message destination metadata
0273: *
0274: * @param name the name of the message destination
0275: * @return the message destination metadata
0276: */
0277: public MessageDestinationMetaData getMessageDestination(String name) {
0278: return (MessageDestinationMetaData) messageDestinations
0279: .get(name);
0280: }
0281:
0282: /**
0283: *
0284: * @param messageDestinations - Map<String, MessageDestinationMetaData>
0285: */
0286: public void setMessageDestination(Map messageDestinations) {
0287: this .messageDestinations.clear();
0288: this .messageDestinations.putAll(messageDestinations);
0289: }
0290:
0291: public Map<String, ServiceRefMetaData> getServiceReferences() {
0292: return serviceReferences;
0293: }
0294:
0295: public void setServiceReferences(
0296: Map<String, ServiceRefMetaData> serviceReferences) {
0297: this .serviceReferences.clear();
0298: this .serviceReferences.putAll(serviceReferences);
0299: }
0300:
0301: /** This the the jboss-web.xml descriptor context-root and it
0302: *is only meaningful if a war is deployed outside of an ear.
0303: */
0304: public String getContextRoot() {
0305: return contextRoot;
0306: }
0307:
0308: public void setContextRoot(String contextRoot) {
0309: this .contextRoot = contextRoot;
0310: }
0311:
0312: public String getConfigFile() {
0313: return configFile;
0314: }
0315:
0316: public void setConfigFile(String configFile) {
0317: this .configFile = configFile;
0318: }
0319:
0320: public String getConfigName() {
0321: return configName;
0322: }
0323:
0324: public void setConfigName(String configName) {
0325: this .configName = configName;
0326: }
0327:
0328: /** Get the optional wsdl publish location from jboss-web.xml. */
0329: public String getWsdlPublishLocationByName(String name) {
0330: return (String) wsdlPublishLocationMap.get(name);
0331: }
0332:
0333: /**
0334: *
0335: * @param wsdlPublishLocationMap - Map<String, String>
0336: */
0337: public void setWsdlPublishLocationMap(Map wsdlPublishLocationMap) {
0338: this .wsdlPublishLocationMap.clear();
0339: this .wsdlPublishLocationMap.putAll(wsdlPublishLocationMap);
0340: }
0341:
0342: public boolean isWebServiceDeployment() {
0343: return webServiceDeployment;
0344: }
0345:
0346: public void setWebServiceDeployment(boolean webServiceDeployment) {
0347: this .webServiceDeployment = webServiceDeployment;
0348: }
0349:
0350: public String getJaccContextID() {
0351: return jaccContextID;
0352: }
0353:
0354: public void setJaccContextID(String jaccContextID) {
0355: this .jaccContextID = jaccContextID;
0356: }
0357:
0358: /** Return the optional security-domain jboss-web.xml element.
0359: @return The jndiName of the security manager implementation that is
0360: responsible for security of the web application. May be null if
0361: there was no security-domain specified in the jboss-web.xml
0362: descriptor.
0363: */
0364: public String getSecurityDomain() {
0365: return securityDomain;
0366: }
0367:
0368: /** Set the security domain for this web application
0369: */
0370: public void setSecurityDomain(String securityDomain) {
0371: this .securityDomain = securityDomain;
0372: }
0373:
0374: /**
0375: * JBAS-1824: Specify whether a WebResourcePermission(url,null)
0376: * needs to be generated by the container
0377: * @return
0378: */
0379: public boolean isJaccRoleNameStar() {
0380: return jaccRoleNameStar;
0381: }
0382:
0383: /**
0384: * JBAS-1824: Specify whether a WebResourcePermission(url,null)
0385: * needs to be generated by the container
0386: * @return
0387: */
0388: public void setJaccRoleNameStar(boolean jaccRoleNameStar) {
0389: this .jaccRoleNameStar = jaccRoleNameStar;
0390: }
0391:
0392: /** The flag indicating whether the associated security domain cache
0393: * should be flushed when the session is invalidated.
0394: * @return true if the flush should occur, false otherwise.
0395: */
0396: public boolean isFlushOnSessionInvalidation() {
0397: return flushOnSessionInvalidation;
0398: }
0399:
0400: /** The flag indicating whether the associated security domain cache
0401: * should be flushed when the session is invalidated.
0402: * @param flag - true if the flush should occur, false otherwise.
0403: */
0404: public void setFlushOnSessionInvalidation(boolean flag) {
0405: this .flushOnSessionInvalidation = flag;
0406: }
0407:
0408: /** Get the security-constraint settings
0409: */
0410: public Iterator getSecurityContraints() {
0411: return securityContraints.iterator();
0412: }
0413:
0414: /**
0415: *
0416: * @param securityContraints - Collection<WebSecurityMetaData>
0417: */
0418: public void setSecurityConstraints(Collection securityContraints) {
0419: this .securityContraints.clear();
0420: this .securityContraints.addAll(securityContraints);
0421: }
0422:
0423: /**
0424: * @return <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
0425: */
0426: public Map getSecurityRoleRefs() {
0427: return this .securityRoleReferences;
0428: }
0429:
0430: /**
0431: *
0432: * @param servletName
0433: * @return List<SecurityRoleRefMetaData> for the given servlet name
0434: */
0435: public List getSecurityRoleRefs(String servletName) {
0436: List roles = (List) this .securityRoleReferences
0437: .get(servletName);
0438: return roles;
0439: }
0440:
0441: /**
0442: *
0443: * @param securityRoleReferences - <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
0444: */
0445: public void setSecurityRoleReferences(Map securityRoleReferences) {
0446: this .securityRoleReferences.clear();
0447: this .securityRoleReferences.putAll(securityRoleReferences);
0448: }
0449:
0450: /**
0451: * Get the security-role names from the web.xml descriptor
0452: * @return Set<String> of the security-role names from the web.xml
0453: */
0454: public Set getSecurityRoleNames() {
0455: return new HashSet(securityRoles.keySet());
0456: }
0457:
0458: /** Get the optional map of security role/user mapping.
0459: * @return Map<String, SecurityRoleMetaData>
0460: */
0461: public Map getSecurityRoles() {
0462: return new HashMap(securityRoles);
0463: }
0464:
0465: /**
0466: *
0467: * @param securityRoles - Map<String, SecurityRoleMetaData>
0468: */
0469: public void setSecurityRoles(Map securityRoles) {
0470: this .securityRoles.clear();
0471: this .securityRoles.putAll(securityRoles);
0472: }
0473:
0474: /**
0475: *
0476: * @param userName
0477: * @return Set<String>
0478: */
0479: public Set getSecurityRoleNamesByPrincipal(String userName) {
0480: HashSet roleNames = new HashSet();
0481: Iterator it = securityRoles.values().iterator();
0482: while (it.hasNext()) {
0483: SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it
0484: .next();
0485: if (srMetaData.getPrincipals().contains(userName))
0486: roleNames.add(srMetaData.getRoleName());
0487: }
0488: return roleNames;
0489: }
0490:
0491: /**
0492: * Access the RunAsIdentity associated with the given servlet
0493: * @param servletName - the servlet-name from the web.xml
0494: * @return RunAsIdentity for the servet if one exists, null otherwise
0495: */
0496: public RunAsIdentity getRunAsIdentity(String servletName) {
0497: RunAsIdentity runAs = (RunAsIdentity) runAsIdentity
0498: .get(servletName);
0499: if (runAs == null) {
0500: // Check for a web.xml run-as only specification
0501: synchronized (runAsIdentity) {
0502: String roleName = (String) runAsNames.get(servletName);
0503: if (roleName != null) {
0504: runAs = new RunAsIdentity(roleName, null);
0505: runAsIdentity.put(servletName, runAs);
0506: }
0507: }
0508: }
0509: return runAs;
0510: }
0511:
0512: /**
0513: *
0514: * @return servlet/run-as <String servlet-name, RunAsIdentity>
0515: */
0516: public Map getRunAsIdentity() {
0517: return runAsIdentity;
0518: }
0519:
0520: /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity>
0521: */
0522: public void setRunAsIdentity(Map runAsIdentity) {
0523: this .runAsIdentity.clear();
0524: this .runAsIdentity.putAll(runAsIdentity);
0525: }
0526:
0527: /**
0528: * Get the servlet-name values from the web.xml descriptor
0529: * @return Set<String> of the servlet-names from the servlet-mappings
0530: */
0531: public HashMap getServletMappings() {
0532: return servletMappings;
0533: }
0534:
0535: /** The web.xml servlet-mapping */
0536: /**
0537: * servlet-mapping/serlvet-name to url-pattern mapping
0538: * @param servletMappings - Map<String, String>
0539: */
0540: public void setServletMappings(Map servletMappings) {
0541: this .servletMappings.clear();
0542: this .servletMappings.putAll(servletMappings);
0543: }
0544:
0545: /**
0546: * Get the servlet-name values from the web.xml descriptor
0547: * @return Set<String> of the servlet-names from the servlet-mappings
0548: */
0549: public Set getServletNames() {
0550: return new HashSet(servletMappings.keySet());
0551: }
0552:
0553: /**
0554: * Get the servlet-name/servlet-class mapping from the web.xml descriptor
0555: * @return Map<String, String> of the servlet-name/servlet-class mapping from web.xml
0556: */
0557: public Map getServletClassMap() {
0558: return new HashMap(servletClassNames);
0559: }
0560:
0561: /**
0562: * Merge the security role/principal mapping defined in jboss-web.xml
0563: * with the one defined at jboss-app.xml.
0564: */
0565: public void mergeSecurityRoles(Map applRoles) {
0566: Iterator it = applRoles.entrySet().iterator();
0567: while (it.hasNext()) {
0568: Map.Entry entry = (Map.Entry) it.next();
0569: String roleName = (String) entry.getKey();
0570: SecurityRoleMetaData appRole = (SecurityRoleMetaData) entry
0571: .getValue();
0572: SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) securityRoles
0573: .get(roleName);
0574: if (srMetaData != null) {
0575: Set principalNames = appRole.getPrincipals();
0576: srMetaData.addPrincipalNames(principalNames);
0577: } else {
0578: securityRoles.put(roleName, entry.getValue());
0579: }
0580: }
0581: }
0582:
0583: /** The servlet container virtual host the war should be deployed into. If
0584: null then the servlet container default host should be used.
0585: */
0586: public Iterator getVirtualHosts() {
0587: return virtualHosts.iterator();
0588: }
0589:
0590: /**
0591: *
0592: * @param virtualHosts - Collection<String>
0593: */
0594: public void setVirtualHosts(Collection virtualHosts) {
0595: this .virtualHosts.clear();
0596: this .virtualHosts.addAll(virtualHosts);
0597: }
0598:
0599: /**
0600: The distributable flag.
0601: @return true if the web-app is marked distributable
0602: */
0603: public boolean getDistributable() {
0604: return distributable;
0605: }
0606:
0607: /**
0608: * Mark the web-app as distributable
0609: * @param distributable - true for distributable
0610: */
0611: public void setDistributable(boolean distributable) {
0612: this .distributable = distributable;
0613: }
0614:
0615: /** Access the web application depends
0616: * @return Iterator of JMX ObjectNames the web app depends on.
0617: */
0618: public Collection getDepends() {
0619: return depends;
0620: }
0621:
0622: /**
0623: @param depends - Collection<ObjectName> of the web app dependencies
0624: */
0625: public void setDepends(Collection depends) {
0626: this .depends.clear();
0627: this .depends.addAll(depends);
0628: }
0629:
0630: /** A flag indicating if the normal Java2 parent first class loading model
0631: * should be used over the servlet 2.3 web container first model.
0632: * @return true for parent first, false for the servlet 2.3 model
0633: */
0634: public boolean getJava2ClassLoadingCompliance() {
0635: return java2ClassLoadingCompliance;
0636: }
0637:
0638: public void setJava2ClassLoadingCompliance(boolean flag) {
0639: java2ClassLoadingCompliance = flag;
0640: }
0641:
0642: public boolean isUseJBossWebLoader() {
0643: return useJBossWebLoader;
0644: }
0645:
0646: public void setUseJBossWebLoader(boolean flag) {
0647: useJBossWebLoader = flag;
0648: }
0649:
0650: public LoaderRepositoryConfig getLoaderConfig() {
0651: return loaderConfig;
0652: }
0653:
0654: public void setLoaderConfig(LoaderRepositoryConfig loaderConfig) {
0655: this .loaderConfig = loaderConfig;
0656: }
0657:
0658: public ClassLoader getENCLoader() {
0659: return encLoader;
0660: }
0661:
0662: public void setENCLoader(ClassLoader encLoader) {
0663: this .encLoader = encLoader;
0664: }
0665:
0666: public ClassLoader getContextLoader() {
0667: return cxtLoader;
0668: }
0669:
0670: /** Make sure this is called during performDeploy */
0671: public void setContextLoader(ClassLoader cxtLoader) {
0672: this .cxtLoader = cxtLoader;
0673: }
0674:
0675: public int getSessionCookies() {
0676: return this .sessionCookies;
0677: }
0678:
0679: public void setSessionCookies(int sessionCookies) {
0680: this .sessionCookies = sessionCookies;
0681: }
0682:
0683: public int getInvalidateSessionPolicy() {
0684: return this .invalidateSessionPolicy;
0685: }
0686:
0687: public void setInvalidateSessionPolicy(int invalidateSessionPolicy) {
0688: this .invalidateSessionPolicy = invalidateSessionPolicy;
0689: }
0690:
0691: public int getReplicationType() {
0692: return replicationType;
0693: }
0694:
0695: public int getReplicationGranularity() {
0696: return replicationGranularity;
0697: }
0698:
0699: public void setReplicationGranularity(int replicationGranularity) {
0700: this .replicationGranularity = replicationGranularity;
0701: }
0702:
0703: public boolean getReplicationFieldBatchMode() {
0704: return replicationFieldBatchMode;
0705: }
0706:
0707: public void importXml(Element element) throws DeploymentException {
0708: String rootTag = element.getOwnerDocument()
0709: .getDocumentElement().getTagName();
0710: if (rootTag.equals("web-app")) {
0711: importWebXml(element);
0712: } else if (rootTag.equals("jboss-web")) {
0713: importJBossWebXml(element);
0714: }
0715: }
0716:
0717: /** Parse the elements of the web-app element used by the integration layer.
0718: */
0719: protected void importWebXml(Element webApp)
0720: throws DeploymentException {
0721: // Parse the web-app/servlet/security-role-ref + run-as elements
0722: Iterator iterator = getChildrenByTagName(webApp, "servlet");
0723: while (iterator.hasNext()) {
0724: Element servlet = (Element) iterator.next();
0725: String servletName = getElementContent(getUniqueChild(
0726: servlet, "servlet-name"));
0727: String servletClass = getElementContent(getOptionalChild(
0728: servlet, "servlet-class"));
0729: if (servletClass != null) {
0730: servletClassNames.put(servletName, servletClass);
0731: }
0732:
0733: Iterator roleRefs = getChildrenByTagName(servlet,
0734: "security-role-ref");
0735: ArrayList roleNames = new ArrayList();
0736: while (roleRefs.hasNext()) {
0737: Element roleRefElem = (Element) roleRefs.next();
0738: SecurityRoleRefMetaData roleRef = new SecurityRoleRefMetaData();
0739: roleRef.importEjbJarXml(roleRefElem);
0740: roleNames.add(roleRef);
0741: }
0742: securityRoleReferences.put(servletName, roleNames);
0743:
0744: // Check for a run-as/role-name
0745: Element runAs = getOptionalChild(servlet, "run-as");
0746: if (runAs != null) {
0747: String runAsName = getElementContent(getOptionalChild(
0748: runAs, "role-name"));
0749: runAsNames.put(servletName, runAsName);
0750: }
0751: }
0752:
0753: // Parse the web-app/servlet-mapping elements
0754: iterator = getChildrenByTagName(webApp, "servlet-mapping");
0755: while (iterator.hasNext()) {
0756: Element servletMapping = (Element) iterator.next();
0757: String servletName = getElementContent(getUniqueChild(
0758: servletMapping, "servlet-name"));
0759: String urlPattern = getElementContent(getUniqueChild(
0760: servletMapping, "url-pattern"));
0761: servletMappings.put(servletName, urlPattern);
0762: }
0763:
0764: // Parse the web-app/resource-ref elements
0765: iterator = getChildrenByTagName(webApp, "resource-ref");
0766: while (iterator.hasNext()) {
0767: Element resourceRef = (Element) iterator.next();
0768: ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
0769: resourceRefMetaData.importEjbJarXml(resourceRef);
0770: resourceReferences.put(resourceRefMetaData.getRefName(),
0771: resourceRefMetaData);
0772: }
0773:
0774: // Parse the resource-env-ref elements
0775: iterator = getChildrenByTagName(webApp, "resource-env-ref");
0776: while (iterator.hasNext()) {
0777: Element resourceRef = (Element) iterator.next();
0778: ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
0779: refMetaData.importEjbJarXml(resourceRef);
0780: resourceEnvReferences.put(refMetaData.getRefName(),
0781: refMetaData);
0782: }
0783:
0784: // set the message destination references
0785: iterator = getChildrenByTagName(webApp,
0786: "message-destination-ref");
0787: while (iterator.hasNext()) {
0788: Element messageDestinationRef = (Element) iterator.next();
0789: MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
0790: messageDestinationRefMetaData
0791: .importEjbJarXml(messageDestinationRef);
0792: messageDestinationReferences.put(
0793: messageDestinationRefMetaData.getRefName(),
0794: messageDestinationRefMetaData);
0795: }
0796:
0797: // set the message destinations (optional)
0798: iterator = getChildrenByTagName(webApp, "message-destination");
0799: while (iterator.hasNext()) {
0800: Element messageDestination = (Element) iterator.next();
0801: try {
0802: MessageDestinationMetaData messageDestinationMetaData = new MessageDestinationMetaData();
0803: messageDestinationMetaData
0804: .importEjbJarXml(messageDestination);
0805: messageDestinations.put(messageDestinationMetaData
0806: .getName(), messageDestinationMetaData);
0807: } catch (Throwable t) {
0808: throw new DeploymentException("Error in web.xml "
0809: + "for message destination: " + t.getMessage());
0810: }
0811: }
0812:
0813: // Parse the web-app/env-entry elements
0814: iterator = getChildrenByTagName(webApp, "env-entry");
0815: while (iterator.hasNext()) {
0816: Element envEntry = (Element) iterator.next();
0817: EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
0818: envEntryMetaData.importEjbJarXml(envEntry);
0819: environmentEntries.add(envEntryMetaData);
0820: }
0821:
0822: // Get the security-constraints
0823: iterator = getChildrenByTagName(webApp, "security-constraint");
0824: while (iterator.hasNext()) {
0825: Element contraints = (Element) iterator.next();
0826: WebSecurityMetaData wsmd = new WebSecurityMetaData();
0827: securityContraints.add(wsmd);
0828: // Process the web-resource-collections
0829: Iterator iter2 = getChildrenByTagName(contraints,
0830: "web-resource-collection");
0831: while (iter2.hasNext()) {
0832: Element wrcElement = (Element) iter2.next();
0833: Element wrName = getUniqueChild(wrcElement,
0834: "web-resource-name");
0835: String name = getElementContent(wrName);
0836: WebSecurityMetaData.WebResourceCollection wrc = wsmd
0837: .addWebResource(name);
0838: Iterator iter21 = getChildrenByTagName(wrcElement,
0839: "url-pattern");
0840: while (iter21.hasNext()) {
0841: Element urlPattern = (Element) iter21.next();
0842: String pattern = getElementContent(urlPattern);
0843: wrc.addPattern(pattern);
0844: }
0845:
0846: Iterator iter22 = getChildrenByTagName(wrcElement,
0847: "http-method");
0848: while (iter22.hasNext()) {
0849: Element httpMethod = (Element) iter22.next();
0850: String method = getElementContent(httpMethod);
0851: wrc.addHttpMethod(method);
0852: }
0853: }
0854:
0855: // Process the auth-constraints
0856: Element authContraint = getOptionalChild(contraints,
0857: "auth-constraint");
0858: if (authContraint != null) {
0859: Iterator iter3 = getChildrenByTagName(authContraint,
0860: "role-name");
0861: while (iter3.hasNext()) {
0862: Element roleName = (Element) iter3.next();
0863: String name = getElementContent(roleName);
0864: wsmd.addRole(name);
0865: }
0866: if (wsmd.getRoles().size() == 0)
0867: wsmd.setExcluded(true);
0868: } else {
0869: wsmd.setUnchecked(true);
0870: }
0871:
0872: // Process the user-data-constraint
0873: Element userData = getOptionalChild(contraints,
0874: "user-data-constraint");
0875: if (userData != null) {
0876: Element transport = getUniqueChild(userData,
0877: "transport-guarantee");
0878: String type = getElementContent(transport);
0879: wsmd.setTransportGuarantee(type);
0880: }
0881: }
0882:
0883: // Get the web-app/security-role elements (optional)
0884: iterator = getChildrenByTagName(webApp, "security-role");
0885: while (iterator.hasNext()) {
0886: Element securityRole = (Element) iterator.next();
0887: String roleName = getElementContent(getUniqueChild(
0888: securityRole, "role-name"));
0889: securityRoles.put(roleName, new SecurityRoleMetaData(
0890: roleName));
0891: }
0892:
0893: // Parse the web-app/ejb-ref elements
0894: iterator = getChildrenByTagName(webApp, "ejb-ref");
0895: while (iterator.hasNext()) {
0896: Element ejbRef = (Element) iterator.next();
0897: EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
0898: ejbRefMetaData.importEjbJarXml(ejbRef);
0899: ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
0900: }
0901:
0902: // Parse the web-app/ejb-local-ref elements
0903: iterator = getChildrenByTagName(webApp, "ejb-local-ref");
0904: while (iterator.hasNext()) {
0905: Element ejbRef = (Element) iterator.next();
0906: EjbLocalRefMetaData ejbRefMetaData = new EjbLocalRefMetaData();
0907: ejbRefMetaData.importEjbJarXml(ejbRef);
0908: ejbLocalReferences.put(ejbRefMetaData.getName(),
0909: ejbRefMetaData);
0910: }
0911:
0912: // Parse the service-ref elements
0913: iterator = MetaData.getChildrenByTagName(webApp, "service-ref");
0914: while (iterator.hasNext()) {
0915: Element serviceRef = (Element) iterator.next();
0916: ServiceRefMetaData refMetaData = new ServiceRefDelegate()
0917: .newServiceRefMetaData();
0918: refMetaData.importStandardXml(serviceRef);
0919: serviceReferences.put(refMetaData.getServiceRefName(),
0920: refMetaData);
0921: }
0922:
0923: // Is the web-app marked distributable?
0924: iterator = getChildrenByTagName(webApp, "distributable");
0925: if (iterator.hasNext()) {
0926: distributable = true;
0927: }
0928: }
0929:
0930: /** Parse the elements of the jboss-web element used by the integration layer.
0931: */
0932: protected void importJBossWebXml(Element jbossWeb)
0933: throws DeploymentException {
0934: // Parse the jboss-web/root-context element
0935: Element contextRootElement = getOptionalChild(jbossWeb,
0936: "context-root");
0937: if (contextRootElement != null)
0938: contextRoot = getElementContent(contextRootElement);
0939:
0940: // Parse the jboss-web/security-domain element
0941: Element securityDomainElement = getOptionalChild(jbossWeb,
0942: "security-domain");
0943: if (securityDomainElement != null) {
0944: securityDomain = getElementContent(securityDomainElement);
0945: // Check the flushOnSessionInvalidation attribute
0946: Boolean flag = Boolean.valueOf(securityDomainElement
0947: .getAttribute("flushOnSessionInvalidation"));
0948: flushOnSessionInvalidation = flag.booleanValue();
0949: }
0950:
0951: //Parse the jboss-web/jacc-star-role-allow element
0952: Element jaccStarRoleElement = getOptionalChild(jbossWeb,
0953: "jacc-star-role-allow");
0954: if (jaccStarRoleElement != null) {
0955: jaccRoleNameStar = "true"
0956: .equalsIgnoreCase(getElementContent(jaccStarRoleElement));
0957: }
0958:
0959: // Parse the jboss-web/virtual-host elements
0960: for (Iterator virtualHostElements = getChildrenByTagName(
0961: jbossWeb, "virtual-host"); virtualHostElements
0962: .hasNext();) {
0963: Element virtualHostElement = (Element) virtualHostElements
0964: .next();
0965: String virtualHostName = getElementContent(virtualHostElement);
0966: virtualHosts.add(virtualHostName);
0967: } // end of for ()
0968:
0969: // Parse the jboss-web/resource-ref elements
0970: Iterator iterator = getChildrenByTagName(jbossWeb,
0971: "resource-ref");
0972: while (iterator.hasNext()) {
0973: Element resourceRef = (Element) iterator.next();
0974: String resRefName = getElementContent(getUniqueChild(
0975: resourceRef, "res-ref-name"));
0976: ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences
0977: .get(resRefName);
0978: if (refMetaData == null) {
0979: throw new DeploymentException("resource-ref "
0980: + resRefName
0981: + " found in jboss-web.xml but not in web.xml");
0982: }
0983: refMetaData.importJbossXml(resourceRef);
0984: }
0985:
0986: // Parse the jboss-web/resource-env-ref elements
0987: iterator = getChildrenByTagName(jbossWeb, "resource-env-ref");
0988: while (iterator.hasNext()) {
0989: Element resourceRef = (Element) iterator.next();
0990: String resRefName = getElementContent(getUniqueChild(
0991: resourceRef, "resource-env-ref-name"));
0992: ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences
0993: .get(resRefName);
0994: if (refMetaData == null) {
0995: throw new DeploymentException("resource-env-ref "
0996: + resRefName
0997: + " found in jboss-web.xml but not in web.xml");
0998: }
0999: refMetaData.importJbossXml(resourceRef);
1000: }
1001:
1002: // update the message destination references (optional)
1003: iterator = getChildrenByTagName(jbossWeb,
1004: "message-destination-ref");
1005: while (iterator.hasNext()) {
1006: Element messageDestinationRef = (Element) iterator.next();
1007: String messageDestinationRefName = getElementContent(getUniqueChild(
1008: messageDestinationRef,
1009: "message-destination-ref-name"));
1010: MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences
1011: .get(messageDestinationRefName);
1012: if (messageDestinationRefMetaData == null)
1013: throw new DeploymentException(
1014: "message-destination-ref "
1015: + messageDestinationRefName
1016: + " found in jboss-web.xml but not in web.xml");
1017: messageDestinationRefMetaData
1018: .importJbossXml(messageDestinationRef);
1019: }
1020:
1021: // set the message destinations (optional)
1022: iterator = getChildrenByTagName(jbossWeb, "message-destination");
1023: while (iterator.hasNext()) {
1024: Element messageDestination = (Element) iterator.next();
1025: try {
1026: String messageDestinationName = getUniqueChildContent(
1027: messageDestination, "message-destination-name");
1028: MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations
1029: .get(messageDestinationName);
1030: if (messageDestinationMetaData == null)
1031: throw new DeploymentException(
1032: "message-destination "
1033: + messageDestinationName
1034: + " found in jboss-web.xml but not in web.xml");
1035: messageDestinationMetaData
1036: .importJbossXml(messageDestination);
1037: } catch (Throwable t) {
1038: throw new DeploymentException("Error in web.xml "
1039: + "for message destination: " + t.getMessage());
1040: }
1041: }
1042:
1043: // set the security roles (optional)
1044: iterator = getChildrenByTagName(jbossWeb, "security-role");
1045: while (iterator.hasNext()) {
1046: Element securityRole = (Element) iterator.next();
1047: String roleName = getElementContent(getUniqueChild(
1048: securityRole, "role-name"));
1049: SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData) securityRoles
1050: .get(roleName);
1051: if (securityRoleMetaData == null)
1052: throw new DeploymentException("Security role '"
1053: + roleName + "' defined in jboss-web.xml"
1054: + " is not defined in web.xml");
1055:
1056: Iterator itPrincipalNames = getChildrenByTagName(
1057: securityRole, "principal-name");
1058: while (itPrincipalNames.hasNext()) {
1059: String principalName = getElementContent((Element) itPrincipalNames
1060: .next());
1061: securityRoleMetaData.addPrincipalName(principalName);
1062: }
1063: }
1064:
1065: // Parse the jboss-web/ejb-ref elements
1066: iterator = getChildrenByTagName(jbossWeb, "ejb-ref");
1067: while (iterator.hasNext()) {
1068: Element ejbRef = (Element) iterator.next();
1069: String ejbRefName = getElementContent(getUniqueChild(
1070: ejbRef, "ejb-ref-name"));
1071: EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences
1072: .get(ejbRefName);
1073: if (ejbRefMetaData == null) {
1074: throw new DeploymentException("ejb-ref " + ejbRefName
1075: + " found in jboss-web.xml but not in web.xml");
1076: }
1077: ejbRefMetaData.importJbossXml(ejbRef);
1078: }
1079:
1080: // Parse the jboss-web/ejb-local-ref elements
1081: iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref");
1082: while (iterator.hasNext()) {
1083: Element ejbLocalRef = (Element) iterator.next();
1084: String ejbLocalRefName = getElementContent(getUniqueChild(
1085: ejbLocalRef, "ejb-ref-name"));
1086: EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences
1087: .get(ejbLocalRefName);
1088: if (ejbLocalRefMetaData == null) {
1089: throw new DeploymentException("ejb-local-ref "
1090: + ejbLocalRefName
1091: + " found in jboss-web.xml but not in web.xml");
1092: }
1093: ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
1094: }
1095:
1096: // Parse the service-ref elements
1097: iterator = MetaData.getChildrenByTagName(jbossWeb,
1098: "service-ref");
1099: while (iterator.hasNext()) {
1100: Element serviceRef = (Element) iterator.next();
1101: String serviceRefName = MetaData.getUniqueChildContent(
1102: serviceRef, "service-ref-name");
1103: ServiceRefMetaData refMetaData = (ServiceRefMetaData) serviceReferences
1104: .get(serviceRefName);
1105: if (refMetaData == null) {
1106: throw new DeploymentException("service-ref "
1107: + serviceRefName
1108: + " found in jboss-web.xml but not in web.xml");
1109: }
1110: refMetaData.importJBossXml(serviceRef);
1111: }
1112:
1113: // WebserviceDescriptions
1114: iterator = getChildrenByTagName(jbossWeb,
1115: "webservice-description");
1116: while (iterator.hasNext()) {
1117: Element wsd = (Element) iterator.next();
1118: String wsdName = getElementContent(getUniqueChild(wsd,
1119: "webservice-description-name"));
1120: configName = MetaData.getOptionalChildContent(wsd,
1121: "config-name");
1122: configFile = MetaData.getOptionalChildContent(wsd,
1123: "config-file");
1124: String wsdlPublishLocation = getOptionalChildContent(wsd,
1125: "wsdl-publish-location");
1126: wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation);
1127: }
1128:
1129: // Parse the jboss-web/depends elements
1130: for (Iterator dependsElements = getChildrenByTagName(jbossWeb,
1131: "depends"); dependsElements.hasNext();) {
1132: Element dependsElement = (Element) dependsElements.next();
1133: String dependsName = getElementContent(dependsElement);
1134: depends.add(ObjectNameFactory.create(dependsName));
1135: } // end of for ()
1136:
1137: // Parse the jboss-web/use-session-cookies element
1138: iterator = getChildrenByTagName(jbossWeb, "use-session-cookies");
1139: if (iterator.hasNext()) {
1140: Element useCookiesElement = (Element) iterator.next();
1141: String useCookiesElementContent = getElementContent(useCookiesElement);
1142: Boolean useCookies = Boolean
1143: .valueOf(useCookiesElementContent);
1144:
1145: if (useCookies.booleanValue()) {
1146: sessionCookies = SESSION_COOKIES_ENABLED;
1147: } else {
1148: sessionCookies = SESSION_COOKIES_DISABLED;
1149: }
1150: }
1151:
1152: // Parse the jboss-web/session-replication element
1153:
1154: Element sessionReplicationRootElement = getOptionalChild(
1155: jbossWeb, "replication-config");
1156: if (sessionReplicationRootElement != null) {
1157: // manage "replication-trigger" first ...
1158: //
1159: Element replicationTriggerElement = getOptionalChild(
1160: sessionReplicationRootElement,
1161: "replication-trigger");
1162: if (replicationTriggerElement != null) {
1163: String repMethod = getElementContent(replicationTriggerElement);
1164: if ("SET_AND_GET".equalsIgnoreCase(repMethod))
1165: this .invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET;
1166: else if ("SET_AND_NON_PRIMITIVE_GET"
1167: .equalsIgnoreCase(repMethod))
1168: this .invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
1169: else if ("SET".equalsIgnoreCase(repMethod))
1170: this .invalidateSessionPolicy = SESSION_INVALIDATE_SET;
1171: else
1172: throw new DeploymentException(
1173: "replication-trigger value set to a non-valid value: '"
1174: + repMethod
1175: + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml");
1176: }
1177:
1178: // ... then manage "replication-type".
1179: //
1180: Element replicationTypeElement = getOptionalChild(
1181: sessionReplicationRootElement, "replication-type");
1182: if (replicationTypeElement != null) {
1183: String repType = getElementContent(replicationTypeElement);
1184: if ("SYNC".equalsIgnoreCase(repType))
1185: this .replicationType = REPLICATION_TYPE_SYNC;
1186: else if ("ASYNC".equalsIgnoreCase(repType))
1187: this .replicationType = REPLICATION_TYPE_ASYNC;
1188: else
1189: throw new DeploymentException(
1190: "replication-type value set to a non-valid value: '"
1191: + repType
1192: + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml");
1193: }
1194:
1195: // ... then manage "replication-type".
1196: //
1197: Element replicationGranularityElement = MetaData
1198: .getOptionalChild(sessionReplicationRootElement,
1199: "replication-granularity");
1200: if (replicationGranularityElement != null) {
1201: String repType = MetaData
1202: .getElementContent(replicationGranularityElement);
1203: if ("SESSION".equalsIgnoreCase(repType))
1204: this .replicationGranularity = REPLICATION_GRANULARITY_SESSION;
1205: else if ("ATTRIBUTE".equalsIgnoreCase(repType))
1206: this .replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE;
1207: else if ("FIELD".equalsIgnoreCase(repType))
1208: this .replicationGranularity = REPLICATION_GRANULARITY_FIELD;
1209: else
1210: throw new DeploymentException(
1211: "replication-granularity value set to a non-valid value: '"
1212: + repType
1213: + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml");
1214: }
1215:
1216: Element batchModeElement = MetaData.getOptionalChild(
1217: sessionReplicationRootElement,
1218: "replication-field-batch-mode");
1219: if (batchModeElement != null) {
1220: Boolean flag = Boolean.valueOf(MetaData
1221: .getElementContent(batchModeElement));
1222: replicationFieldBatchMode = flag.booleanValue();
1223: }
1224: }
1225:
1226: // Check for a war level class loading config
1227: Element classLoading = MetaData.getOptionalChild(jbossWeb,
1228: "class-loading");
1229: if (classLoading != null) {
1230: String flagString = classLoading
1231: .getAttribute("java2ClassLoadingCompliance");
1232: if (flagString.length() == 0)
1233: flagString = "true";
1234: boolean flag = Boolean.valueOf(flagString).booleanValue();
1235: setJava2ClassLoadingCompliance(flag);
1236: // Check for a loader-repository for scoping
1237: Element loader = MetaData.getOptionalChild(classLoading,
1238: "loader-repository");
1239: if (loader != null) {
1240: useJBossWebLoader = true;
1241: try {
1242: loaderConfig = LoaderRepositoryFactory
1243: .parseRepositoryConfig(loader);
1244: } catch (MalformedObjectNameException e) {
1245: throw new DeploymentException(e);
1246: }
1247: }
1248: }
1249:
1250: // Parse the jboss-web/servlet elements
1251: iterator = getChildrenByTagName(jbossWeb, "servlet");
1252: while (iterator.hasNext()) {
1253: Element servlet = (Element) iterator.next();
1254: String servletName = getElementContent(getUniqueChild(
1255: servlet, "servlet-name"));
1256: String principalName = getOptionalChildContent(servlet,
1257: "run-as-principal");
1258: // Get the web.xml run-as primary role
1259: String webXmlRunAs = (String) runAsNames.get(servletName);
1260: if (principalName != null) {
1261: if (webXmlRunAs == null) {
1262: throw new DeploymentException(
1263: "run-as-principal: "
1264: + principalName
1265: + " found in jboss-web.xml but there was no run-as in web.xml");
1266: }
1267: // See if there are any additional roles for this principal
1268: Set extraRoles = getSecurityRoleNamesByPrincipal(principalName);
1269: RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs,
1270: principalName, extraRoles);
1271: runAsIdentity.put(servletName, runAs);
1272: } else if (webXmlRunAs != null) {
1273: RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs,
1274: null);
1275: runAsIdentity.put(servletName, runAs);
1276: }
1277: }
1278:
1279: }
1280: }
|