KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > verifier > tests > AclTest


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  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31
32 package com.sun.enterprise.admin.verifier.tests;
33
34 /* Test case to check the validity of Acl fields
35  * Author : srini@sun.com
36  */

37
38
39 import java.io.File JavaDoc;
40 // 8.0 XML Verifier
41
//import com.sun.enterprise.tools.verifier.Result;
42
import com.sun.enterprise.config.serverbeans.Server;
43 import com.sun.enterprise.config.serverbeans.*;
44 import com.sun.enterprise.config.serverbeans.Resources;
45 import com.sun.enterprise.config.serverbeans.Applications;
46 import com.sun.enterprise.config.ConfigContext;
47 import com.sun.enterprise.config.ConfigException;
48 import com.sun.enterprise.config.serverbeans.*;
49 import com.sun.enterprise.config.ConfigContextEvent;
50
51 import com.sun.enterprise.admin.verifier.*;
52
53 // Logging
54
import java.util.logging.Logger JavaDoc;
55 import java.util.logging.Level JavaDoc;
56 import com.sun.logging.LogDomains;
57
58 public class AclTest extends ServerXmlTest implements ServerCheck {
59     
60     // Logging
61
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
62     
63     public AclTest() {
64     }
65  
66     // check method invoked by the command line verifier
67
public Result check(ConfigContext context) {
68             Result result;
69             result = super.getInitializedResult();
70             // 8.0 XML Verifier
71
/*try {
72                 Server server = (Server)context.getRootConfigBean();
73                 Acl[] acl = server.getHttpService().getAcl();
74                 for(int i=0;i<acl.length;i++){
75                     String file = acl[i].getFile();
76                     File f = new File(file);
77                     if(!f.exists())
78                         result.failed("Acl File " + file + " is not Valid");
79                 }
80             }
81             catch(Exception ex) {
82                 // Logging
83                 _logger.log(Level.FINE, "serverxmlverifier.exception", ex);
84                 result.failed("Exception : " + ex.getMessage());
85             } */

86             return result;
87     }
88     
89     // check method called from the admin GUI and iasadmin
90
public Result check(ConfigContextEvent ccce) {
91                 Object JavaDoc value = ccce.getObject();
92                 ConfigContext context = ccce.getConfigContext();
93                 Result result = new Result();
94                 result.passed("Passed ** ");
95                 String JavaDoc beanName = ccce.getBeanName();
96                 if(beanName!=null) {
97                     String JavaDoc name = ccce.getName();
98                     result = testSave(name, (String JavaDoc)value);
99                     return result;
100                 }
101 /*
102                 Acl acl = (Acl)value;
103                 
104                 // check if Acl ID is valid object name Bug : 4698687 : start
105                 String id = acl.getId();
106                 if(StaticTest.checkObjectName(id, result))
107                     result.passed("Valid Object Name");
108                 else {
109                     result.failed("Acl ID Invalid ");
110                     return result;
111                 }
112                 // End Bug : 4698687
113         
114                 if(acl != null) {
115                     File f = new File(acl.getFile());
116                     if(!f.exists())
117                         result.failed("Acl File Not Exists");
118                 }
119 */

120                 return result;
121     }
122     
123     public Result testSave(String JavaDoc name, String JavaDoc value) {
124             Result result = new Result();
125             result.passed("Passed **");
126             if(name.equals(ServerTags.FILE)) {
127                 if(value != null) {
128                     File JavaDoc f = new File JavaDoc(value);
129                     if (!f.exists())
130                         result.failed("Invalid ACL File");
131                 }
132             }
133             return result;
134     }
135     
136 }
137
Popular Tags