1 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 37 public class FormLoginPage extends WebTest implements WebCheck { 38 39 40 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 FileArchive arch=null; 59 60 String formLoginPage = descriptor.getLoginConfiguration().getFormLoginPage(); 61 if (formLoginPage.length() > 0) { 62 63 try{ 64 String uri=getAbstractArchiveUri(descriptor); 67 try{ 68 arch = new FileArchive(); 69 arch.open(uri); 70 }catch(IOException e){throw e;} 71 if (formLoginPage.startsWith("/")) 75 formLoginPage=formLoginPage.substring(1); 76 File flp = new File(arch.getArchiveUri()+File.separator+formLoginPage); 82 if(flp.exists()) 83 foundIt=true; 84 flp = null; 85 }catch (Exception ex) { 89 foundIt = false; 91 } 92 93 if (foundIt) { 94 result.addGoodDetails(smh.getLocalString 95 ("tests.componentNameConstructor", 96 "For [ {0} ]", 97 new Object [] {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 [] {formLoginPage, descriptor.getName()})); 102 } else { 103 result.addErrorDetails(smh.getLocalString 104 ("tests.componentNameConstructor", 105 "For [ {0} ]", 106 new Object [] {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 [] {formLoginPage, descriptor.getName()})); 111 } 112 } else { 113 result.addNaDetails(smh.getLocalString 114 ("tests.componentNameConstructor", 115 "For [ {0} ]", 116 new Object [] {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 [] {descriptor.getName()})); 121 } 122 } else { 123 result.addNaDetails(smh.getLocalString 124 ("tests.componentNameConstructor", 125 "For [ {0} ]", 126 new Object [] {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 [] {descriptor.getName()})); 131 } 132 133 return result; 134 } 135 } 136 | Popular Tags |