1 23 24 package com.sun.enterprise.deployment.node.runtime.common; 25 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 29 import org.w3c.dom.Node ; 30 31 import com.sun.enterprise.deployment.node.XMLElement; 32 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 33 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 34 import com.sun.enterprise.deployment.runtime.common.ProtectionDescriptor; 35 import com.sun.enterprise.deployment.runtime.common.MessageDescriptor; 36 import com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor; 37 38 42 public class MessageSecurityNode extends DeploymentDescriptorNode { 43 44 MessageSecurityDescriptor descriptor = null; 45 46 public MessageSecurityNode() { 47 registerElementHandler(new XMLElement( 48 WebServicesTagNames.MESSAGE), MessageNode.class, 49 "addMessageDescriptor"); 50 registerElementHandler(new XMLElement( 51 WebServicesTagNames.REQUEST_PROTECTION), ProtectionNode.class, 52 "setRequestProtectionDescriptor"); 53 registerElementHandler(new XMLElement( 54 WebServicesTagNames.RESPONSE_PROTECTION), ProtectionNode.class, 55 "setResponseProtectionDescriptor"); 56 } 57 58 61 public Object getDescriptor() { 62 if (descriptor == null) { 63 descriptor = new MessageSecurityDescriptor(); 64 } 65 return descriptor; 66 } 67 68 76 public Node writeDescriptor(Node parent, String nodeName, 77 MessageSecurityDescriptor messageSecurityDesc) { 78 Node messageSecurityNode = super.writeDescriptor(parent, nodeName, 79 messageSecurityDesc); 80 81 ArrayList messageDescs = 82 messageSecurityDesc.getMessageDescriptors(); 83 if (!messageDescs.isEmpty()) { 84 MessageNode messageNode = new MessageNode(); 85 for (Iterator messageIterator = messageDescs.iterator(); 86 messageIterator.hasNext();) { 87 MessageDescriptor messageDesc = 88 (MessageDescriptor) messageIterator.next(); 89 messageNode.writeDescriptor(messageSecurityNode, 90 WebServicesTagNames.MESSAGE, messageDesc); 91 } 92 } 93 94 ProtectionDescriptor requestProtectionDesc = 96 messageSecurityDesc.getRequestProtectionDescriptor(); 97 if (requestProtectionDesc != null) { 98 ProtectionNode requestProtectionNode = new ProtectionNode(); 99 requestProtectionNode.writeDescriptor(messageSecurityNode, 100 WebServicesTagNames.REQUEST_PROTECTION, requestProtectionDesc); 101 } 102 103 ProtectionDescriptor responseProtectionDesc = 105 messageSecurityDesc.getResponseProtectionDescriptor(); 106 if (responseProtectionDesc != null) { 107 ProtectionNode responseProtectionNode = new ProtectionNode(); 108 responseProtectionNode.writeDescriptor(messageSecurityNode, 109 WebServicesTagNames.RESPONSE_PROTECTION, 110 responseProtectionDesc); 111 } 112 113 return messageSecurityNode; 114 } 115 } 116 | Popular Tags |