1 22 package org.jboss.metadata; 23 24 import java.net.URLClassLoader ; 25 import java.util.ArrayList ; 26 import java.util.Collection ; 27 import java.util.HashMap ; 28 import java.util.HashSet ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Map ; 32 import java.util.Set ; 33 34 import javax.management.MalformedObjectNameException ; 35 36 import org.jboss.deployment.DeploymentException; 37 import org.jboss.logging.Logger; 38 import org.jboss.metadata.web.ErrorPage; 39 import org.jboss.metadata.web.Filter; 40 import org.jboss.metadata.web.FilterMapping; 41 import org.jboss.metadata.web.LoginConfig; 42 import org.jboss.metadata.web.ParamValue; 43 import org.jboss.metadata.web.PassivationConfig; 44 import org.jboss.metadata.web.ReplicationConfig; 45 import org.jboss.metadata.web.Servlet; 46 import org.jboss.metadata.web.ServletMapping; 47 import org.jboss.metadata.web.SessionConfig; 48 import org.jboss.metamodel.descriptor.ResourceEnvRef; 49 import org.jboss.metamodel.descriptor.ResourceRef; 50 import org.jboss.mx.loading.LoaderRepositoryFactory; 51 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig; 52 import org.jboss.mx.util.ObjectNameFactory; 53 import org.jboss.security.RunAsIdentity; 54 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData; 55 import org.w3c.dom.Element ; 56 57 67 public class WebMetaData extends MetaData 68 { 69 private static Logger log = Logger.getLogger(WebMetaData.class); 70 71 72 private String description; 73 74 private String displayName; 75 76 private String altDDPath; 77 78 private List <ParamValue> contextParams = new ArrayList <ParamValue>(); 79 80 private List <ParamValue> initParams = new ArrayList <ParamValue>(); 81 82 private HashMap <String , Servlet> servlets = new HashMap <String , Servlet>(); 83 84 private HashMap <String , ServletMapping> servletMappings = new HashMap <String , ServletMapping>(); 85 86 private HashMap <String , ResourceRefMetaData> resourceReferences = 87 new HashMap <String , ResourceRefMetaData>(); 88 89 private HashMap <String , ResourceEnvRefMetaData> resourceEnvReferences = 90 new HashMap <String , ResourceEnvRefMetaData>(); 91 92 private HashMap <String , MessageDestinationRefMetaData> messageDestinationReferences 93 = new HashMap <String , MessageDestinationRefMetaData>(); 94 95 private HashMap <String , MessageDestinationMetaData> messageDestinations = 96 new HashMap <String , MessageDestinationMetaData>(); 97 98 protected HashMap <String , Filter> filters = new HashMap <String , Filter>(); 99 100 protected HashMap <String , FilterMapping> filterMappings = 101 new HashMap <String , FilterMapping>(); 102 protected HashMap listeners = new HashMap (); 103 protected List <SessionConfig> sessionConfigs = new ArrayList <SessionConfig>(); 104 105 protected List <WebSecurityMetaData> securityConstraints = 106 new ArrayList <WebSecurityMetaData>(); 107 protected LoginConfig loginConfig; 108 protected HashMap <String , ErrorPage> errorPages = new HashMap <String , ErrorPage>(); 109 protected List <String > dependencies = new ArrayList <String >(); 110 protected ReplicationConfig replicationConfig; 111 protected PassivationConfig passivationConfig; 112 113 114 private ArrayList <EnvEntryMetaData> environmentEntries = new ArrayList <EnvEntryMetaData>(); 115 116 private HashMap <String , SecurityRoleMetaData> securityRoles = new HashMap <String , SecurityRoleMetaData>(); 117 118 private HashMap ejbReferences = new HashMap (); 119 120 private HashMap <String , EjbLocalRefMetaData> ejbLocalReferences = new HashMap <String , EjbLocalRefMetaData>(); 121 122 private HashMap serviceReferences = new HashMap (); 123 124 private HashMap securityRoleReferences = new HashMap (); 125 126 private HashMap runAsNames = new HashMap (); 127 128 private HashMap runAsIdentity = new HashMap (); 129 130 private boolean distributable = false; 131 132 private boolean java2ClassLoadingCompliance = false; 133 134 private LoaderRepositoryConfig loaderConfig; 135 136 private String contextRoot; 137 138 private String jaccContextID; 139 140 private ArrayList virtualHosts = new ArrayList (); 141 142 private String securityDomain; 143 144 private boolean flushOnSessionInvalidation; 145 146 private HashMap wsdlPublishLocationMap = new HashMap (); 147 148 private boolean webServiceDeployment; 149 150 private String configName; 151 152 private String configFile; 153 154 private ClassLoader encLoader; 155 156 private ClassLoader cxtLoader; 157 158 private ArrayList depends = new ArrayList (); 159 160 164 private HashMap arbitraryMetadata = new HashMap (); 165 166 public static final int SESSION_INVALIDATE_ACCESS =0; 167 public static final int SESSION_INVALIDATE_SET_AND_GET =1; 168 public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET =2; 169 public static final int SESSION_INVALIDATE_SET =3; 170 171 private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET; 172 173 public static final int REPLICATION_TYPE_SYNC = 0; 174 public static final int REPLICATION_TYPE_ASYNC = 1; 175 176 179 private int replicationType = REPLICATION_TYPE_SYNC; 180 181 185 public static final int REPLICATION_GRANULARITY_SESSION = 0; 186 public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1; 187 public static final int REPLICATION_GRANULARITY_FIELD = 2; 188 private int replicationGranularity = REPLICATION_GRANULARITY_SESSION; 189 190 194 private boolean replicationFieldBatchMode = true; 195 196 200 private boolean sessionPassivationMode = false; 201 202 207 private int sessionPassivationMinIdleTime = -1; 208 209 214 private int sessionPassivationMaxIdleTime = -1; 215 216 219 private int maxActiveSessions = -1; 220 221 222 223 private int sessionCookies = SESSION_COOKIES_DEFAULT; 224 225 public static final int SESSION_COOKIES_DEFAULT=0; 226 public static final int SESSION_COOKIES_ENABLED=1; 227 public static final int SESSION_COOKIES_DISABLED=2; 228 229 230 private URLClassLoader resourceCl; 231 232 public String getDescription() 233 { 234 return description; 235 } 236 237 public void setDescription(String description) 238 { 239 this.description = description; 240 } 241 242 public String getDisplayName() 243 { 244 return displayName; 245 } 246 247 public void setDisplayName(String displayName) 248 { 249 this.displayName = displayName; 250 } 251 252 public String getAltDDPath() 253 { 254 return altDDPath; 255 } 256 public void setAltDDPath(String altDDPath) 257 { 258 this.altDDPath = altDDPath; 259 } 260 261 public List <ParamValue> getContextParams() 262 { 263 return contextParams; 264 } 265 public void addContextParam(ParamValue pv) 266 { 267 contextParams.add(pv); 268 } 269 public List <ParamValue> getInitParams() 270 { 271 return initParams; 272 } 273 public void addInitParam(ParamValue pv) 274 { 275 initParams.add(pv); 276 } 277 278 public HashMap getArbitraryMetadata() 279 { 280 return arbitraryMetadata; 281 } 282 283 284 public void setResourceClassLoader(URLClassLoader resourceCl) 285 { 286 this.resourceCl = resourceCl; 287 } 288 289 public void addFilter(Filter filter) 290 { 291 filters.put(filter.getName(), filter); 292 } 293 294 public Collection getFilterMappings() 295 { 296 return filterMappings.values(); 297 } 298 299 public void addFilterMapping(FilterMapping mapping) 300 { 301 filterMappings.put(mapping.getFilterName(), mapping); 302 } 303 304 public Collection getListeners() 305 { 306 return listeners.values(); 307 } 308 309 public void addListener(Listener listener) 310 { 311 listeners.put(listener.getListenerClass(), listener); 312 } 313 314 public Collection getServlets() 315 { 316 return servlets.values(); 317 } 318 319 public void addServlet(Servlet servlet) 320 { 321 String servletName = servlet.getName(); 322 servlets.put(servletName, servlet); 323 } 324 325 public void updateServlet(Servlet updatedServlet) 326 { 327 Servlet servlet = (Servlet)servlets.get(updatedServlet.getName()); 328 if (servlet != null) 329 { 330 servlet.setRunAsPrincipals(updatedServlet.getRunAsPrincipals()); 331 } 332 else 333 { 334 servlets.put(updatedServlet.getName(), updatedServlet); 335 } 336 } 337 338 public Collection getServletMappings() 339 { 340 return servletMappings.values(); 341 } 342 343 public void addServletMapping(ServletMapping mapping) 344 { 345 servletMappings.put(mapping.getName(), mapping); 346 } 347 348 public Collection getSessionConfigs() 349 { 350 return sessionConfigs; 351 } 352 353 public void addSessionConfig(SessionConfig config) 354 { 355 sessionConfigs.add(config); 356 } 357 358 public void addSecurityRole(SecurityRoleMetaData securityRole) 359 { 360 securityRoles.put(securityRole.getRoleName(), securityRole); 361 } 362 363 public void updateSecurityRole(SecurityRoleMetaData updatedRole) 364 { 365 SecurityRoleMetaData role = securityRoles.get(updatedRole.getRoleName()); 366 if (role != null) 367 { 368 role.setRoleName(updatedRole.getRoleName()); 369 } 370 else 371 { 372 securityRoles.put(updatedRole.getRoleName(), updatedRole); 373 } 374 } 375 376 public Collection getSecurityConstraints() 377 { 378 return securityConstraints; 379 } 380 381 public void addSecurityConstraint(WebSecurityMetaData constraint) 382 { 383 securityConstraints.add(constraint); 384 } 385 386 public LoginConfig getLoginConfig() 387 { 388 return loginConfig; 389 } 390 391 public void setLoginConfig(LoginConfig loginConfig) 392 { 393 this.loginConfig = loginConfig; 394 } 395 396 public Collection getErrorPages() 397 { 398 return errorPages.values(); 399 } 400 401 public void addErrorPage(ErrorPage errorPage) 402 { 403 errorPages.put(errorPage.getErrorCode(), errorPage); 404 } 405 406 public Collection getMessageDestinations() 407 { 408 return messageDestinations.values(); 409 } 410 411 public void addEjbLocalRef(EjbLocalRefMetaData ref) 412 { 413 this.ejbLocalReferences.put(ref.getName(), ref); 414 } 415 public void addEjbRef(EjbRefMetaData ref) 416 { 417 this.ejbReferences.put(ref.getName(), ref); 418 } 419 public void addEnvEntry(EnvEntryMetaData ref) 420 { 421 this.environmentEntries.add(ref); 422 } 423 public void addMessageDestinationRef(MessageDestinationRefMetaData ref) 424 { 425 this.messageDestinationReferences.put(ref.getRefName(), ref); 426 } 427 public void addMessageDestination(MessageDestinationMetaData destination) 428 { 429 log.debug("addMessageDestination, "+destination); 430 messageDestinations.put(destination.getName(), destination); 431 } 432 public void updateMessageDestination(MessageDestinationMetaData updatedDestination) 433 { 434 MessageDestinationMetaData destination = (MessageDestinationMetaData) 435 messageDestinations.get(updatedDestination.getName()); 436 if (destination != null) 437 { 438 destination.setJNDIName(updatedDestination.getMappedName()); 439 } 440 else 441 { 442 messageDestinations.put(updatedDestination.getName(), updatedDestination); 443 } 444 } 445 public void addResourceEnvRef(ResourceEnvRefMetaData ref) 446 { 447 this.resourceEnvReferences.put(ref.getRefName(), ref); 448 } 449 public void updateResourceEnvRef(ResourceEnvRefMetaData updatedRef) 450 { 451 ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData)resourceEnvReferences.get(updatedRef.getRefName()); 452 if (ref != null) 453 { 454 ref.setJndiName(updatedRef.getJndiName()); 455 } 456 else 457 { 458 this.addResourceEnvRef(updatedRef); 459 } 460 } 461 462 public void addResourceRef(ResourceRefMetaData ref) 463 { 464 this.resourceReferences.put(ref.getRefName(), ref); 465 } 466 public void updateResourceRef(ResourceRefMetaData updatedRef) 467 { 468 ResourceRefMetaData ref = (ResourceRefMetaData)resourceReferences.get(updatedRef.getRefName()); 469 if (ref != null) 470 { 471 ref.setJndiName(updatedRef.getJndiName()); 472 ref.setResURL(updatedRef.getResURL()); 473 ref.setResourceName(updatedRef.getResourceName()); 474 } 475 else 476 { 477 this.addResourceRef(updatedRef); 478 } 479 } 480 481 public void addDependency(String depends) 482 { 483 dependencies.add(depends); 484 } 485 486 public Collection <String > getDependencies() 487 { 488 return dependencies; 489 } 490 491 public ReplicationConfig getReplicationConfig() 492 { 493 return replicationConfig; 494 } 495 496 public void setReplicationConfig(ReplicationConfig replicationConfig) 497 { 498 this.replicationConfig = replicationConfig; 499 } 500 501 public PassivationConfig getPassivationConfig() 502 { 503 return passivationConfig; 504 } 505 506 public void setPassivationConfig(PassivationConfig passivationConfig) 507 { 508 this.passivationConfig = passivationConfig; 509 } 510 511 514 public Iterator <EnvEntryMetaData> getEnvironmentEntries() 515 { 516 return environmentEntries.iterator(); 517 } 518 522 public void setEnvironmentEntries(Collection environmentEntries) 523 { 524 this.environmentEntries.clear(); 525 this.environmentEntries.addAll(environmentEntries); 526 } 527 528 531 public Iterator getEjbReferences() 532 { 533 return ejbReferences.values().iterator(); 534 } 535 539 public void setEjbReferences(Map ejbReferences) 540 { 541 this.ejbReferences.clear(); 542 this.ejbReferences.putAll(ejbReferences); 543 } 544 545 548 public Iterator <EjbLocalRefMetaData> getEjbLocalReferences() 549 { 550 return ejbLocalReferences.values().iterator(); 551 } 552 public Map <String , EjbLocalRefMetaData> getEjbLocalReferenceMap() 553 { 554 return ejbLocalReferences; 555 } 556 560 public void setEjbLocalReferences(Map ejbReferences) 561 { 562 this.ejbLocalReferences.clear(); 563 this.ejbLocalReferences.putAll(ejbReferences); 564 } 565 566 569 public Iterator getResourceReferences() 570 { 571 return resourceReferences.values().iterator(); 572 } 573 577 public void setResourceReferences(Map resourceReferences) 578 { 579 this.resourceReferences.clear(); 580 this.resourceReferences.putAll(resourceReferences); 581 } 582 583 586 public Iterator getResourceEnvReferences() 587 { 588 return resourceEnvReferences.values().iterator(); 589 } 590 594 public void setResourceEnvReferences(Map resourceReferences) 595 { 596 this.resourceEnvReferences.clear(); 597 this.resourceEnvReferences.putAll(resourceReferences); 598 } 599 600 605 public Iterator getMessageDestinationReferences() 606 { 607 return messageDestinationReferences.values().iterator(); 608 } 609 613 public void setMessageDestinationReferences(Map messageDestinationReferences) 614 { 615 this.messageDestinationReferences.clear(); 616 this.messageDestinationReferences.putAll(messageDestinationReferences); 617 } 618 619 625 public MessageDestinationMetaData getMessageDestination(String name) 626 { 627 return (MessageDestinationMetaData) messageDestinations.get(name); 628 } 629 633 public void setMessageDestination(Map messageDestinations) 634 { 635 this.messageDestinations.clear(); 636 this.messageDestinations.putAll(messageDestinations); 637 } 638 639 642 public Iterator getServiceReferences() 643 { 644 return serviceReferences.values().iterator(); 645 } 646 650 public void setServiceReferences(Map serviceReferences) 651 { 652 this.serviceReferences.clear(); 653 this.serviceReferences.putAll(serviceReferences); 654 } 655 656 659 public String getContextRoot() 660 { 661 return contextRoot; 662 } 663 public void setContextRoot(String contextRoot) 664 { 665 this.contextRoot = contextRoot; 666 } 667 668 public String getConfigFile() 669 { 670 return configFile; 671 } 672 673 public void setConfigFile(String configFile) 674 { 675 this.configFile = configFile; 676 } 677 678 public String getConfigName() 679 { 680 return configName; 681 } 682 683 public void setConfigName(String configName) 684 { 685 this.configName = configName; 686 } 687 688 public HashMap getWsdlPublishLocations() 689 { 690 return wsdlPublishLocationMap; 691 } 692 693 694 public String getWsdlPublishLocationByName(String name) 695 { 696 return (String )wsdlPublishLocationMap.get(name); 697 } 698 702 public void setWsdlPublishLocationMap(Map wsdlPublishLocationMap) 703 { 704 this.wsdlPublishLocationMap.clear(); 705 this.wsdlPublishLocationMap.putAll(wsdlPublishLocationMap); 706 } 707 708 public boolean isWebServiceDeployment() 709 { 710 return webServiceDeployment; 711 } 712 713 public void setWebServiceDeployment(boolean webServiceDeployment) 714 { 715 this.webServiceDeployment = webServiceDeployment; 716 } 717 718 public String getJaccContextID() 719 { 720 return jaccContextID; 721 } 722 public void setJaccContextID(String jaccContextID) 723 { 724 this.jaccContextID = jaccContextID; 725 } 726 727 733 public String getSecurityDomain() 734 { 735 return securityDomain; 736 } 737 738 740 public void setSecurityDomain(String securityDomain) 741 { 742 this.securityDomain = securityDomain; 743 } 744 745 749 public boolean isFlushOnSessionInvalidation() 750 { 751 return flushOnSessionInvalidation; 752 } 753 757 public void setFlushOnSessionInvalidation(boolean flag) 758 { 759 this.flushOnSessionInvalidation = flag; 760 } 761 762 764 public Iterator <WebSecurityMetaData> getSecurityContraints() 765 { 766 return securityConstraints.iterator(); 767 } 768 769 773 public void setSecurityConstraints(Collection <WebSecurityMetaData> securityContraints) 774 { 775 this.securityConstraints.clear(); 776 this.securityConstraints.addAll(securityContraints); 777 } 778 779 782 public Map getSecurityRoleRefs() 783 { 784 return this.securityRoleReferences; 785 } 786 791 public List getSecurityRoleRefs(String servletName) 792 { 793 List roles = (List ) this.securityRoleReferences.get(servletName); 794 return roles; 795 } 796 800 public void setSecurityRoleReferences(Map securityRoleReferences) 801 { 802 this.securityRoleReferences.clear(); 803 this.securityRoleReferences.putAll(securityRoleReferences); 804 } 805 806 810 public Set getSecurityRoleNames() 811 { 812 return new HashSet (securityRoles.keySet()); 813 } 814 815 818 public Map getSecurityRoles() 819 { 820 return new HashMap (securityRoles); 821 } 822 826 public void setSecurityRoles(Map securityRoles) 827 { 828 this.securityRoles.clear(); 829 this.securityRoles.putAll(securityRoles); 830 } 831 832 837 public Set getSecurityRoleNamesByPrincipal(String userName) 838 { 839 HashSet roleNames = new HashSet (); 840 Iterator it = securityRoles.values().iterator(); 841 while (it.hasNext()) 842 { 843 SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it.next(); 844 if (srMetaData.getPrincipals().contains(userName)) 845 roleNames.add(srMetaData.getRoleName()); 846 } 847 return roleNames; 848 } 849 850 855 public Map getPrincipalVersusRolesMap() 856 { 857 Map principalRolesMap = null; 858 859 Iterator iter = securityRoles.keySet().iterator(); 860 while(iter.hasNext()) 861 { 862 if(principalRolesMap == null) 863 principalRolesMap = new HashMap (); 864 String rolename = (String )iter.next(); 865 SecurityRoleMetaData srm = (SecurityRoleMetaData) securityRoles.get(rolename); 866 Iterator principalIter = srm.getPrincipals().iterator(); 867 while(principalIter.hasNext()) 868 { 869 String pr = (String )principalIter.next(); 870 Set roleset = (Set )principalRolesMap.get(pr); 871 if(roleset == null) 872 roleset = new HashSet (); 873 if(!roleset.contains(rolename)) 874 roleset.add(rolename); 875 principalRolesMap.put(pr, roleset); 876 } 877 } 878 return principalRolesMap; 879 } 880 881 886 public RunAsIdentity getRunAsIdentity(String servletName) 887 { 888 RunAsIdentity runAs = (RunAsIdentity) runAsIdentity.get(servletName); 889 if( runAs == null ) 890 { 891 synchronized( runAsIdentity ) 893 { 894 String roleName = (String ) runAsNames.get(servletName); 895 if( roleName != null ) 896 { 897 runAs = new RunAsIdentity(roleName, null); 898 runAsIdentity.put(servletName, runAs); 899 } 900 } 901 } 902 return runAs; 903 } 904 908 public Map getRunAsIdentity() 909 { 910 return runAsIdentity; 911 } 912 914 public void setRunAsIdentity(Map runAsIdentity) 915 { 916 this.runAsIdentity.clear(); 917 this.runAsIdentity.putAll(runAsIdentity); 918 } 919 920 924 public Set getServletNames() 925 { 926 return new HashSet (servletMappings.keySet()); 927 } 928 929 933 public void mergeSecurityRoles(Map <String , SecurityRoleMetaData> applRoles) 934 { 935 Iterator <Map.Entry <String , SecurityRoleMetaData>> it = applRoles.entrySet().iterator(); 936 while (it.hasNext()) 937 { 938 Map.Entry <String , SecurityRoleMetaData> entry = it.next(); 939 String roleName = entry.getKey(); 940 SecurityRoleMetaData appRole = entry.getValue(); 941 SecurityRoleMetaData srMetaData = securityRoles.get(roleName); 942 if (srMetaData != null) 943 { 944 Set principalNames = appRole.getPrincipals(); 945 srMetaData.addPrincipalNames(principalNames); 946 } 947 else 948 { 949 securityRoles.put(roleName, entry.getValue()); 950 } 951 } 952 } 953 954 957 public Iterator getVirtualHosts() 958 { 959 return virtualHosts.iterator(); 960 } 961 965 public void setVirtualHosts(Collection virtualHosts) 966 { 967 this.virtualHosts.clear(); 968 this.virtualHosts.addAll(virtualHosts); 969 } 970 971 975 public boolean getDistributable() 976 { 977 return distributable; 978 } 979 983 public void setDistributable(boolean distributable) 984 { 985 this.distributable = distributable; 986 } 987 988 991 public Collection getDepends() 992 { 993 return depends; 994 } 995 998 public void setDepends(Collection depends) 999 { 1000 this.depends.clear(); 1001 this.depends.addAll(depends); 1002 } 1003 1004 1008 public boolean getJava2ClassLoadingCompliance() 1009 { 1010 return java2ClassLoadingCompliance; 1011 } 1012 public void setJava2ClassLoadingCompliance(boolean flag) 1013 { 1014 java2ClassLoadingCompliance = flag; 1015 } 1016 1017 public LoaderRepositoryConfig getLoaderConfig() 1018 { 1019 return loaderConfig; 1020 } 1021 public void setLoaderConfig(LoaderRepositoryConfig loaderConfig) 1022 { 1023 this.loaderConfig = loaderConfig; 1024 } 1025 1026 public ClassLoader getENCLoader() 1027 { 1028 return encLoader; 1029 } 1030 public void setENCLoader(ClassLoader encLoader) 1031 { 1032 this.encLoader = encLoader; 1033 } 1034 1035 public ClassLoader getContextLoader() 1036 { 1037 return cxtLoader; 1038 } 1039 1040 1041 public void setContextLoader(ClassLoader cxtLoader) 1042 { 1043 this.cxtLoader = cxtLoader; 1044 } 1045 1046 public int getSessionCookies() 1047 { 1048 return this.sessionCookies; 1049 } 1050 public void setSessionCookies(int sessionCookies) 1051 { 1052 this.sessionCookies = sessionCookies; 1053 } 1054 1055 public int getInvalidateSessionPolicy() 1056 { 1057 return this.invalidateSessionPolicy; 1058 } 1059 public void setInvalidateSessionPolicy(int invalidateSessionPolicy) 1060 { 1061 this.invalidateSessionPolicy = invalidateSessionPolicy; 1062 } 1063 1064 public int getReplicationType() 1065 { 1066 return replicationType; 1067 } 1068 1069 public int getReplicationGranularity() 1070 { 1071 return replicationGranularity; 1072 } 1073 public void setReplicationGranularity(int replicationGranularity) 1074 { 1075 this.replicationGranularity = replicationGranularity; 1076 } 1077 1078 public boolean getReplicationFieldBatchMode() 1079 { 1080 return replicationFieldBatchMode; 1081 } 1082 1083 public boolean getSessionPassivationMode() 1084 { 1085 return sessionPassivationMode; 1086 } 1087 1088 public void setSessionPassivationMode(boolean mode) 1089 { 1090 this.sessionPassivationMode = mode; 1091 } 1092 1093 public int getSessionPassivationMinIdleTime() 1094 { 1095 return sessionPassivationMinIdleTime; 1096 } 1097 1098 public void setSessionPassivationMinIdleTime(int time) 1099 { 1100 this.sessionPassivationMinIdleTime = time; 1101 } 1102 1103 public int getSessionPassivationMaxIdleTime() 1104 { 1105 return sessionPassivationMaxIdleTime; 1106 } 1107 1108 public void setSessionPassivationMaxIdleTime(int time) 1109 { 1110 this.sessionPassivationMaxIdleTime = time; 1111 } 1112 1113 public int getMaxActiveSessionsAllowed() 1114 { 1115 return maxActiveSessions; 1116 } 1117 1118 public void setMaxActiveSessionsAllowed(int maxActive) 1119 { 1120 this.maxActiveSessions = maxActive; 1121 } 1122 1123 1125 protected void importJBossWebXml(Element jbossWeb) throws DeploymentException 1126 { 1127 Element contextRootElement = getOptionalChild(jbossWeb, "context-root"); 1129 if( contextRootElement != null ) 1130 contextRoot = getElementContent(contextRootElement); 1131 1132 Element securityDomainElement = getOptionalChild(jbossWeb, "security-domain"); 1134 if( securityDomainElement != null ) 1135 { 1136 securityDomain = getElementContent(securityDomainElement); 1137 Boolean flag = Boolean.valueOf(securityDomainElement.getAttribute("flushOnSessionInvalidation")); 1139 flushOnSessionInvalidation = flag.booleanValue(); 1140 } 1141 1142 for( Iterator virtualHostElements = getChildrenByTagName(jbossWeb, "virtual-host"); 1144 virtualHostElements.hasNext();) 1145 { 1146 Element virtualHostElement = (Element )virtualHostElements.next(); 1147 String virtualHostName = getElementContent(virtualHostElement); 1148 virtualHosts.add(virtualHostName); 1149 } 1151 Iterator iterator = getChildrenByTagName(jbossWeb, "resource-ref"); 1153 while( iterator.hasNext() ) 1154 { 1155 Element resourceRef = (Element ) iterator.next(); 1156 String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name")); 1157 ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences.get(resRefName); 1158 if( refMetaData == null ) 1159 { 1160 throw new DeploymentException("resource-ref " + resRefName 1161 + " found in jboss-web.xml but not in web.xml"); 1162 } 1163 refMetaData.importJbossXml(resourceRef); 1164 } 1165 1166 iterator = getChildrenByTagName(jbossWeb, "resource-env-ref"); 1168 while( iterator.hasNext() ) 1169 { 1170 Element resourceRef = (Element ) iterator.next(); 1171 String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name")); 1172 ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName); 1173 if( refMetaData == null ) 1174 { 1175 throw new DeploymentException("resource-env-ref " + resRefName 1176 + " found in jboss-web.xml but not in web.xml"); 1177 } 1178 refMetaData.importJbossXml(resourceRef); 1179 } 1180 1181 iterator = getChildrenByTagName(jbossWeb, "message-destination-ref"); 1183 while (iterator.hasNext()) 1184 { 1185 Element messageDestinationRef = (Element ) iterator.next(); 1186 String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name")); 1187 MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences.get(messageDestinationRefName); 1188 if (messageDestinationRefMetaData == null) 1189 throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss-web.xml but not in web.xml"); 1190 messageDestinationRefMetaData.importJbossXml(messageDestinationRef); 1191 } 1192 1193 iterator = getChildrenByTagName(jbossWeb, "message-destination"); 1195 while (iterator.hasNext()) 1196 { 1197 Element messageDestination = (Element ) iterator.next(); 1198 try 1199 { 1200 String messageDestinationName = getUniqueChildContent(messageDestination, "message-destination-name"); 1201 MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations.get(messageDestinationName); 1202 if (messageDestinationMetaData == null) 1203 throw new DeploymentException("message-destination " + messageDestinationName + " found in jboss-web.xml but not in web.xml"); 1204 messageDestinationMetaData.importJbossXml(messageDestination); 1205 } 1206 catch (Throwable t) 1207 { 1208 throw new DeploymentException("Error in web.xml " + 1209 "for message destination: " + t.getMessage()); 1210 } 1211 } 1212 1213 iterator = getChildrenByTagName(jbossWeb, "security-role"); 1215 while (iterator.hasNext()) 1216 { 1217 Element securityRole = (Element ) iterator.next(); 1218 String roleName = getElementContent(getUniqueChild(securityRole, "role-name")); 1219 SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData)securityRoles.get(roleName); 1220 if (securityRoleMetaData == null) 1221 throw new DeploymentException("Security role '" + roleName + "' defined in jboss-web.xml" + 1222 " is not defined in web.xml"); 1223 1224 Iterator itPrincipalNames = getChildrenByTagName(securityRole, "principal-name"); 1225 while (itPrincipalNames.hasNext()) 1226 { 1227 String principalName = getElementContent((Element ) itPrincipalNames.next()); 1228 securityRoleMetaData.addPrincipalName(principalName); 1229 } 1230 } 1231 1232 iterator = getChildrenByTagName(jbossWeb, "ejb-ref"); 1234 while( iterator.hasNext() ) 1235 { 1236 Element ejbRef = (Element ) iterator.next(); 1237 String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name")); 1238 EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName); 1239 if( ejbRefMetaData == null ) 1240 { 1241 throw new DeploymentException("ejb-ref " + ejbRefName 1242 + " found in jboss-web.xml but not in web.xml"); 1243 } 1244 ejbRefMetaData.importJbossXml(ejbRef); 1245 } 1246 1247 iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref"); 1249 while( iterator.hasNext() ) 1250 { 1251 Element ejbLocalRef = (Element ) iterator.next(); 1252 String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name")); 1253 EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences.get(ejbLocalRefName); 1254 if( ejbLocalRefMetaData == null ) 1255 { 1256 throw new DeploymentException("ejb-local-ref " + ejbLocalRefName 1257 + " found in jboss-web.xml but not in web.xml"); 1258 } 1259 ejbLocalRefMetaData.importJbossXml(ejbLocalRef); 1260 } 1261 1262 iterator = MetaData.getChildrenByTagName(jbossWeb, "service-ref"); 1264 while (iterator.hasNext()) 1265 { 1266 Element serviceRef = (Element ) iterator.next(); 1267 String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name"); 1268 ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName); 1269 if (refMetaData == null) 1270 { 1271 log.warn("service-ref " + serviceRefName + " found in jboss-web.xml but not in web.xml"); 1272 refMetaData = new ServiceRefMetaData(serviceRefName); 1273 serviceReferences.put(serviceRefName, refMetaData); 1274 } 1275 refMetaData.importJBossXml(serviceRef); 1276 } 1277 1278 iterator = getChildrenByTagName(jbossWeb, "webservice-description"); 1280 while (iterator.hasNext()) 1281 { 1282 Element wsd = (Element )iterator.next(); 1283 String wsdName = getElementContent(getUniqueChild(wsd, "webservice-description-name")); 1284 configName = MetaData.getOptionalChildContent(wsd, "config-name"); 1285 configFile = MetaData.getOptionalChildContent(wsd, "config-file"); 1286 String wsdlPublishLocation = getOptionalChildContent(wsd, "wsdl-publish-location"); 1287 wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation); 1288 } 1289 1290 for( Iterator dependsElements = getChildrenByTagName(jbossWeb, "depends"); 1292 dependsElements.hasNext();) 1293 { 1294 Element dependsElement = (Element )dependsElements.next(); 1295 String dependsName = getElementContent(dependsElement); 1296 depends.add(ObjectNameFactory.create(dependsName)); 1297 } 1299 iterator = getChildrenByTagName(jbossWeb, "use-session-cookies"); 1301 if ( iterator.hasNext() ) 1302 { 1303 Element useCookiesElement = (Element ) iterator.next(); 1304 String useCookiesElementContent = getElementContent(useCookiesElement); 1305 Boolean useCookies=Boolean.valueOf(useCookiesElementContent); 1306 1307 if (useCookies.booleanValue()) 1308 { 1309 sessionCookies=SESSION_COOKIES_ENABLED; 1310 } 1311 else 1312 { 1313 sessionCookies=SESSION_COOKIES_DISABLED; 1314 } 1315 } 1316 1317 Element maxActiveSessionsElement = getOptionalChild(jbossWeb, "max-active-sessions"); 1319 if(maxActiveSessionsElement != null) 1320 { 1321 maxActiveSessions = Integer.valueOf(getElementContent(maxActiveSessionsElement)).intValue(); 1322 } 1323 1324 log.info("WebMetaData:importJBossWebXml: maxActiveSessions = " + maxActiveSessions); 1325 Element sessionPassivationRootElement = getOptionalChild(jbossWeb, "passivation-config"); 1327 if( sessionPassivationRootElement != null) 1328 { 1329 Element usePassivationElement = MetaData.getOptionalChild(sessionPassivationRootElement, "use-session-passivation"); 1331 if (usePassivationElement != null && Boolean.valueOf(getElementContent(usePassivationElement)).booleanValue()) 1332 { 1333 sessionPassivationMode = true; 1334 } 1335 else 1336 { 1337 sessionPassivationMode = false; 1338 } 1339 log.info("WebMetaData:importJBossWebXml: sessionPassivationMode = " + sessionPassivationMode); 1340 if (getSessionPassivationMode()) 1342 { 1343 Element minIdleTimeElement = MetaData.getOptionalChild(sessionPassivationRootElement, "passivation-min-idle-time"); 1344 if (minIdleTimeElement != null) 1345 { 1346 Long minIdleTimeValue = Long.valueOf(getElementContent(minIdleTimeElement)); 1347 sessionPassivationMinIdleTime = minIdleTimeValue.intValue(); 1348 log.info("WebMetaData:importJBossWebXml: sessionPassivationMinIdleTime = " + sessionPassivationMinIdleTime); 1349 } 1350 1351 Element maxIdleTimeElement = MetaData.getOptionalChild(sessionPassivationRootElement, "passivation-max-idle-time"); 1352 if (maxIdleTimeElement != null) 1353 { 1354 Long maxIdleTimeValue = Long.valueOf(getElementContent(maxIdleTimeElement)); 1355 sessionPassivationMaxIdleTime = maxIdleTimeValue.intValue(); 1356 log.info("WebMetaData:importJBossWebXml: sessionPassivationMaxIdleTime = " + sessionPassivationMaxIdleTime); 1357 } 1358 } 1359 } 1360 1362 Element sessionReplicationRootElement = getOptionalChild(jbossWeb, "replication-config"); 1363 if( sessionReplicationRootElement != null ) 1364 { 1365 Element replicationTriggerElement = getOptionalChild(sessionReplicationRootElement, "replication-trigger"); 1368 if (replicationTriggerElement != null) 1369 { 1370 String repMethod = getElementContent(replicationTriggerElement); 1371 if ("SET_AND_GET".equalsIgnoreCase(repMethod)) 1372 this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET; 1373 else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(repMethod)) 1374 this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET; 1375 else if ("SET".equalsIgnoreCase(repMethod)) 1376 this.invalidateSessionPolicy = SESSION_INVALIDATE_SET; 1377 else 1378 throw new DeploymentException("replication-trigger value set to a non-valid value: '" + repMethod 1379 + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml"); 1380 } 1381 1382 Element replicationTypeElement = getOptionalChild(sessionReplicationRootElement, "replication-type"); 1385 if (replicationTypeElement != null) 1386 { 1387 String repType = getElementContent(replicationTypeElement); 1388 if ("SYNC".equalsIgnoreCase(repType)) 1389 this.replicationType = REPLICATION_TYPE_SYNC; 1390 else if ("ASYNC".equalsIgnoreCase(repType)) 1391 this.replicationType = REPLICATION_TYPE_ASYNC; 1392 else 1393 throw new DeploymentException("replication-type value set to a non-valid value: '" + repType 1394 + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml"); 1395 } 1396 1397 Element replicationGranularityElement = MetaData.getOptionalChild(sessionReplicationRootElement, "replication-granularity"); 1400 if (replicationGranularityElement != null) 1401 { 1402 String repType = MetaData.getElementContent(replicationGranularityElement); 1403 if ("SESSION".equalsIgnoreCase(repType)) 1404 this.replicationGranularity = REPLICATION_GRANULARITY_SESSION; 1405 else if ("ATTRIBUTE".equalsIgnoreCase(repType)) 1406 this.replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE; 1407 else if ("FIELD".equalsIgnoreCase(repType)) 1408 this.replicationGranularity = REPLICATION_GRANULARITY_FIELD; 1409 else 1410 throw new DeploymentException("replication-granularity value set to a non-valid value: '" + repType 1411 + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml"); 1412 } 1413 1414 Element batchModeElement = MetaData.getOptionalChild(sessionReplicationRootElement, "replication-field-batch-mode"); 1415 if (batchModeElement != null) 1416 { 1417 Boolean flag = Boolean.valueOf(MetaData.getElementContent(batchModeElement)); 1418 replicationFieldBatchMode = flag.booleanValue(); 1419 } 1420 } 1421 1422 Element classLoading = MetaData.getOptionalChild(jbossWeb, "class-loading"); 1424 if( classLoading != null ) 1425 { 1426 String flagString = classLoading.getAttribute("java2ClassLoadingCompliance"); 1427 if( flagString.length() == 0 ) 1428 flagString = "true"; 1429 boolean flag = Boolean.valueOf(flagString).booleanValue(); 1430 setJava2ClassLoadingCompliance(flag); 1431 Element loader = MetaData.getOptionalChild(classLoading, "loader-repository"); 1433 if( loader != null ) 1434 { 1435 try 1436 { 1437 loaderConfig = LoaderRepositoryFactory.parseRepositoryConfig(loader); 1438 } 1439 catch (MalformedObjectNameException e) 1440 { 1441 throw new DeploymentException(e); 1442 } 1443 } 1444 } 1445 1446 iterator = getChildrenByTagName(jbossWeb, "servlet"); 1448 while (iterator.hasNext()) 1449 { 1450 Element servlet = (Element )iterator.next(); 1451 String servletName = getElementContent(getUniqueChild(servlet, "servlet-name")); 1452 String principalName = getOptionalChildContent(servlet, "run-as-principal"); 1453 String webXmlRunAs = (String ) runAsNames.get(servletName); 1455 if( principalName != null ) 1456 { 1457 if( webXmlRunAs == null ) 1458 { 1459 throw new DeploymentException("run-as-principal: " + principalName 1460 + " found in jboss-web.xml but there was no run-as in web.xml"); 1461 } 1462 Set extraRoles = getSecurityRoleNamesByPrincipal(principalName); 1464 RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, principalName, extraRoles); 1465 runAsIdentity.put(servletName, runAs); 1466 } 1467 else if( webXmlRunAs != null ) 1468 { 1469 RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, null); 1470 runAsIdentity.put(servletName, runAs); 1471 } 1472 } 1473 } 1474 1475} 1476 | Popular Tags |