KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > FormLoginPage


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 package com.sun.enterprise.tools.verifier.tests.web;
24
25 import com.sun.enterprise.tools.verifier.tests.web.WebTest;
26 import java.io.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30 import com.sun.enterprise.deployment.deploy.shared.FileArchive;
31
32 /**
33  * The Web form-login-page value defines the location in the web application
34  * where the page can be used for login page can be found within web application
35  * test
36  */

37 public class FormLoginPage extends WebTest implements WebCheck {
38
39     
40     /**
41      * The Web form-login-page value defines the location in the web application
42      * where the page can be used for login page can be found within web application
43      * test
44      *
45      * @param descriptor the Web deployment descriptor
46      *
47      * @return <code>Result</code> the results for this assertion
48      */

49     public Result check(WebBundleDescriptor descriptor) {
50
51     Result result = getInitializedResult();
52     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53
54     if (descriptor.getLoginConfiguration() != null) {
55         boolean foundIt = false;
56 // ZipEntry ze = null;
57
// JarFile jar =null;
58
FileArchive arch=null;
59         
60             String JavaDoc formLoginPage = descriptor.getLoginConfiguration().getFormLoginPage();
61             if (formLoginPage.length() > 0) {
62            
63                 try{
64 // File f = Verifier.getArchiveFile(descriptor.getModuleDescriptor().getArchiveUri());
65
// if(f==null){
66
String JavaDoc uri=getAbstractArchiveUri(descriptor);
67                         try{
68                             arch = new FileArchive();
69                             arch.open(uri);
70                         }catch(IOException e){throw e;}
71 // }else{
72
// jar = new JarFile(f);
73
// }
74
if (formLoginPage.startsWith("/"))
75                         formLoginPage=formLoginPage.substring(1);
76 // if (f!=null){
77
// ze = jar.getEntry(formLoginPage);
78
// foundIt = (ze != null);
79
// }
80
// else{
81
File flp = new File(arch.getArchiveUri()+File.separator+formLoginPage);
82                         if(flp.exists())
83                             foundIt=true;
84                         flp = null;
85 // }
86
// if (jar!=null)
87
// jar.close();
88
}catch (Exception JavaDoc ex) {
89             //should be aldready set?
90
foundIt = false;
91             }
92                
93             if (foundIt) {
94             result.addGoodDetails(smh.getLocalString
95             ("tests.componentNameConstructor",
96             "For [ {0} ]",
97             new Object JavaDoc[] {compName.toString()}));
98             result.passed(smh.getLocalString
99                       (getClass().getName() + ".passed",
100                        "The form-login-page [ {0} ] value does define the location in the web application [ {1} ] where the page can be used for login page can be found.",
101                        new Object JavaDoc[] {formLoginPage, descriptor.getName()}));
102             } else {
103             result.addErrorDetails(smh.getLocalString
104             ("tests.componentNameConstructor",
105             "For [ {0} ]",
106             new Object JavaDoc[] {compName.toString()}));
107             result.failed(smh.getLocalString
108                       (getClass().getName() + ".failed",
109                        "Error: The form-login-page [ {0} ] value does not define the location in the web application [ {1} ] where the page to be used for the login page can be found.",
110                        new Object JavaDoc[] {formLoginPage, descriptor.getName()}));
111             }
112         } else {
113         result.addNaDetails(smh.getLocalString
114             ("tests.componentNameConstructor",
115             "For [ {0} ]",
116             new Object JavaDoc[] {compName.toString()}));
117             result.notApplicable(smh.getLocalString
118                      (getClass().getName() + ".notApplicable",
119                       "There are no form-login-page name elements within this web archive [ {0} ]",
120                       new Object JavaDoc[] {descriptor.getName()}));
121         }
122     } else {
123         result.addNaDetails(smh.getLocalString
124             ("tests.componentNameConstructor",
125             "For [ {0} ]",
126             new Object JavaDoc[] {compName.toString()}));
127         result.notApplicable(smh.getLocalString
128                  (getClass().getName() + ".notApplicable",
129                   "There are no form-login-page name elements within this web archive [ {0} ]",
130                   new Object JavaDoc[] {descriptor.getName()}));
131     }
132
133     return result;
134     }
135 }
136
Popular Tags