KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.w3c.dom.Element JavaDoc;
31
32 import com.sun.enterprise.deployment.node.XMLElement;
33 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
34 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
35 import com.sun.enterprise.deployment.runtime.common.MessageSecurityDescriptor;
36 import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor;
37
38 /**
39  * This node handles message-security-binding element
40  *
41  */

42 public class MessageSecurityBindingNode extends DeploymentDescriptorNode {
43
44     MessageSecurityBindingDescriptor descriptor = null;
45
46     public MessageSecurityBindingNode() {
47         registerElementHandler(new XMLElement(
48             WebServicesTagNames.MESSAGE_SECURITY), MessageSecurityNode.class,
49             "addMessageSecurityDescriptor");
50     }
51     
52     /**
53     * @return the descriptor instance to associate with this XMLNode
54     */

55     public Object JavaDoc getDescriptor() {
56        if (descriptor == null) {
57             descriptor = new MessageSecurityBindingDescriptor();
58         }
59         return descriptor;
60     }
61
62     /**
63      * parsed an attribute of an element
64      *
65      * @param the element name
66      * @param the attribute name
67      * @param the attribute value
68      * @return true if the attribute was processed
69      */

70     protected boolean setAttributeValue(XMLElement elementName,
71         XMLElement attributeName, String JavaDoc value) {
72         if (attributeName.getQName().equals(WebServicesTagNames.AUTH_LAYER)) {
73             descriptor.setAttributeValue(descriptor.AUTH_LAYER, value);
74             return true;
75         } else if (attributeName.getQName().equals(
76             WebServicesTagNames.PROVIDER_ID)) {
77             descriptor.setAttributeValue(descriptor.PROVIDER_ID, value);
78             return true;
79         }
80         return false;
81     }
82
83     /**
84      * write the descriptor class to a DOM tree and return it
85      *
86      * @param parent node for the DOM tree
87      * @param node name for
88      * @param the descriptor to write
89      * @return the DOM tree top node
90      */

91     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
92         MessageSecurityBindingDescriptor messageSecurityBindingDesc) {
93         Element JavaDoc messageSecurityBindingNode = (Element JavaDoc)super.writeDescriptor(parent, nodeName, messageSecurityBindingDesc);
94
95         // message-security
96
ArrayList JavaDoc messageSecDescs =
97             messageSecurityBindingDesc.getMessageSecurityDescriptors();
98         if (!messageSecDescs.isEmpty()) {
99             MessageSecurityNode messageSecurityNode =
100                 new MessageSecurityNode();
101             for (Iterator JavaDoc messageSecIterator = messageSecDescs.iterator();
102                 messageSecIterator.hasNext();) {
103                 MessageSecurityDescriptor messageSecDesc =
104                     (MessageSecurityDescriptor) messageSecIterator.next();
105                 messageSecurityNode.writeDescriptor(messageSecurityBindingNode, WebServicesTagNames.MESSAGE_SECURITY, messageSecDesc);
106             }
107         }
108
109         // auth-layer
110
if (messageSecurityBindingDesc.getAttributeValue(
111             messageSecurityBindingDesc.AUTH_LAYER) != null) {
112             setAttribute(messageSecurityBindingNode, WebServicesTagNames.AUTH_LAYER, messageSecurityBindingDesc.getAttributeValue(messageSecurityBindingDesc.AUTH_LAYER));
113         }
114     
115         // provider-id
116
if (messageSecurityBindingDesc.getAttributeValue(
117             messageSecurityBindingDesc.PROVIDER_ID) != null) {
118             setAttribute(messageSecurityBindingNode, WebServicesTagNames.PROVIDER_ID, messageSecurityBindingDesc.getAttributeValue(messageSecurityBindingDesc.PROVIDER_ID));
119         }
120             
121         return messageSecurityBindingNode;
122     }
123 }
124
Popular Tags