KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > common > MessageSecurityNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.node.runtime.common;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import org.w3c.dom.Node JavaDoc;
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 /**
39  * This node handles message-security element
40  *
41  */

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     /**
59     * @return the descriptor instance to associate with this XMLNode
60     */

61     public Object JavaDoc getDescriptor() {
62        if (descriptor == null) {
63             descriptor = new MessageSecurityDescriptor();
64         }
65         return descriptor;
66     }
67
68     /**
69      * write the descriptor class to a DOM tree and return it
70      *
71      * @param parent node for the DOM tree
72      * @param node name for
73      * @param the descriptor to write
74      * @return the DOM tree top node
75      */

76     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
77         MessageSecurityDescriptor messageSecurityDesc) {
78         Node JavaDoc messageSecurityNode = super.writeDescriptor(parent, nodeName,
79            messageSecurityDesc);
80
81         ArrayList JavaDoc messageDescs =
82             messageSecurityDesc.getMessageDescriptors();
83         if (!messageDescs.isEmpty()) {
84             MessageNode messageNode = new MessageNode();
85             for (Iterator JavaDoc 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         // request-protection
95
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         // response-protection
104
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