KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > transform > elements > AuthRealm


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  * AuthRealm.java
26  *
27  * Created on August 4, 2003, 2:04 PM
28  */

29
30 package com.sun.enterprise.tools.upgrade.transform.elements;
31
32 /**
33  *
34  * @author prakash
35  */

36 import org.w3c.dom.Document JavaDoc;
37 import org.w3c.dom.Element JavaDoc;
38 import org.w3c.dom.NodeList JavaDoc;
39 import org.w3c.dom.Node JavaDoc;
40 import com.sun.enterprise.tools.upgrade.transform.ElementToObjectMapper;
41
42 public class AuthRealm extends BaseElement {
43     
44     /** Creates a new instance of Element */
45     public AuthRealm() {
46     }
47     /**
48      * element - auth-realm
49      * parentSource - parent http-service of element
50      * parentResult - parent http-service of result
51      */

52     public void transform(Element JavaDoc element, Element JavaDoc parentSource, Element JavaDoc parentResult){
53         if(!this.canTransform(element.getAttribute("name"), element.getAttribute("classname")))
54             return;
55         NodeList JavaDoc resultAuths = parentResult.getElementsByTagName("auth-realm");
56         Element JavaDoc resultAuth = null;
57         for(int lh =0; lh < resultAuths.getLength(); lh++){
58             // Compare id attribute of auth-realm elements.
59
if((element.getAttribute("name")).equals(((Element JavaDoc)resultAuths.item(lh)).getAttribute("name"))){
60                 resultAuth = (Element JavaDoc)resultAuths.item(lh);
61                 this.transferAttributes(element, resultAuth, null);
62                 break;
63              }
64         }
65         if(resultAuth == null){
66             // Add element - auth-realm to result security-service.
67
resultAuth = parentResult.getOwnerDocument().createElement("auth-realm");
68             this.transferAttributes(element, resultAuth, null);
69             this.appendElementToParent(parentResult,resultAuth);
70         }
71         super.transform(element, parentSource, resultAuth);
72     }
73     private boolean canTransform(String JavaDoc name, String JavaDoc className){
74         // FIX... name of solarisRealm is "solaris" not known. Need to finout
75
//start CR 6399167 - security's keyfile location should be transformed.
76
//if((name.equals("file") || className.equals("com.iplanet.ias.security.auth.realm.file.FileRealm")) ||
77
//end CR 6399167
78
if((name.equals("ldap") || className.equals("com.iplanet.ias.security.auth.realm.ldap.LDAPRealm")) ||
79             (name.equals("solaris") || className.equals("com.iplanet.ias.security.auth.realm.solaris.SolarisRealm")) ||
80             (name.equals("certificate") || className.equals("com.iplanet.ias.security.auth.realm.certificate.CertificateRealm"))){
81             return false;
82         }
83         return true;
84     }
85     protected java.util.List JavaDoc getInsertElementStructure(Element JavaDoc element, Element JavaDoc parentEle){
86         java.util.List JavaDoc list = new java.util.ArrayList JavaDoc();
87         if(parentEle.getTagName().equals("node-agent")){
88             list.add("log-service");
89         }
90         return list;
91     }
92     
93 }
94
Popular Tags