1 23 24 29 30 package com.sun.enterprise.deployment.node.web; 31 32 import java.util.Enumeration ; 33 import java.util.Map ; 34 import org.w3c.dom.Node ; 35 36 import com.sun.enterprise.deployment.SecurityConstraintImpl; 37 import com.sun.enterprise.deployment.WebResourceCollectionImpl; 38 import com.sun.enterprise.deployment.AuthorizationConstraintImpl; 39 import com.sun.enterprise.deployment.UserDataConstraintImpl; 40 import com.sun.enterprise.deployment.xml.WebTagNames; 41 import com.sun.enterprise.deployment.node.XMLElement; 42 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 43 44 50 public class SecurityConstraintNode extends DeploymentDescriptorNode { 51 52 public SecurityConstraintNode() { 53 super(); 54 registerElementHandler(new XMLElement(WebTagNames.USERDATA_CONSTRAINT), 55 UserDataConstraintNode.class, "setUserDataConstraint"); 56 registerElementHandler(new XMLElement(WebTagNames.AUTH_CONSTRAINT), 57 AuthConstraintNode.class, "setAuthorizationConstraint"); 58 registerElementHandler(new XMLElement(WebTagNames.WEB_RESOURCE_COLLECTION), 59 WebResourceCollectionNode.class, "addWebResourceCollection"); 60 } 61 62 70 protected Map getDispatchTable() { 71 Map table = super.getDispatchTable(); 72 table.put(WebTagNames.NAME, "setName"); 73 return table; 74 } 75 76 84 public Node writeDescriptor(Node parent, String nodeName, SecurityConstraintImpl descriptor) { 85 Node myNode = appendChild(parent, nodeName); 86 appendTextChild(myNode, WebTagNames.NAME, descriptor.getName()); 87 88 WebResourceCollectionNode wrcNode = new WebResourceCollectionNode(); 90 for (Enumeration webResources = descriptor.getWebResourceCollections(); 91 webResources.hasMoreElements();) { 92 wrcNode.writeDescriptor(myNode, WebTagNames.WEB_RESOURCE_COLLECTION, 93 (WebResourceCollectionImpl) webResources.nextElement()); 94 } 95 96 AuthorizationConstraintImpl aci = (AuthorizationConstraintImpl) descriptor.getAuthorizationConstraint(); 98 if (aci!=null) { 99 AuthConstraintNode acNode = new AuthConstraintNode(); 100 acNode.writeDescriptor(myNode, WebTagNames.AUTH_CONSTRAINT, aci); 101 } 102 103 UserDataConstraintImpl udci = (UserDataConstraintImpl) descriptor.getUserDataConstraint(); 105 if (udci!=null) { 106 UserDataConstraintNode udcn = new UserDataConstraintNode(); 107 udcn.writeDescriptor(myNode, WebTagNames.USERDATA_CONSTRAINT, udci); 108 } 109 return myNode; 110 } 111 112 } | Popular Tags |