KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > web > AuthConstraintNode


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 /*
25  * AuthConstraintNode.java
26  *
27  * Created on March 1, 2002, 2:45 PM
28  */

29
30 package com.sun.enterprise.deployment.node.web;
31
32 import java.util.Map JavaDoc;
33 import java.util.Enumeration JavaDoc;
34 import org.w3c.dom.Node JavaDoc;
35
36 import com.sun.enterprise.deployment.AuthorizationConstraintImpl;
37 import com.sun.enterprise.deployment.SecurityRoleDescriptor;
38 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
39 import com.sun.enterprise.deployment.xml.WebTagNames;
40
41 /**
42  * This node contains the auth-constraint xml node
43  *
44  * @author Jerome ochez
45  * @version
46  */

47 public class AuthConstraintNode extends DeploymentDescriptorNode {
48
49     /**
50      * all sub-implementation of this class can use a dispatch table to map xml element to
51      * method name on the descriptor class for setting the element value.
52      *
53      * @return the map with the element name as a key, the setter method as a value
54      */

55     protected Map JavaDoc getDispatchTable() {
56         Map JavaDoc table = super.getDispatchTable();
57         table.put(WebTagNames.ROLE_NAME, "addSecurityRole");
58         return table;
59     }
60     
61     /**
62      * write the descriptor class to a DOM tree and return it
63      *
64      * @param parent node in the DOM tree
65      * @param node name for the root element of this xml fragment
66      * @param the descriptor to write
67      * @return the DOM tree top node
68      */

69     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, AuthorizationConstraintImpl descriptor) {
70         Node JavaDoc myNode = appendChild(parent, nodeName);
71         
72         writeLocalizedDescriptions(myNode, descriptor);
73         
74         // role-name*
75
for (Enumeration JavaDoc roles = descriptor.getSecurityRoles();roles.hasMoreElements();) {
76             SecurityRoleDescriptor role = (SecurityRoleDescriptor) roles.nextElement();
77             appendTextChild(myNode, WebTagNames.ROLE_NAME, role.getName());
78         }
79         return myNode;
80     }
81 }
82
Popular Tags