1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 30 import java.io.*; 31 32 33 38 public class FormErrorPage extends WebTest implements WebCheck { 39 40 41 50 public Result check(WebBundleDescriptor descriptor) { 51 52 Result result = getInitializedResult(); 53 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 54 55 if (descriptor.getLoginConfiguration() != null) { 56 boolean foundIt = false; 57 FileArchive arch=null; 60 61 String formErrorPage = descriptor.getLoginConfiguration().getFormErrorPage(); 62 if (formErrorPage.length() > 0) { 63 64 try{ 65 66 69 String uri=getAbstractArchiveUri(descriptor); 70 71 try{ 72 arch = new FileArchive(); 73 arch.open(uri); 74 }catch(IOException e){ 75 throw e; 76 } 77 if (formErrorPage.startsWith("/")) 81 formErrorPage=formErrorPage.substring(1); 82 File fep = new File(arch.getArchiveUri() + File.separator + formErrorPage); 88 if(fep.exists()) 89 foundIt=true; 90 fep = null; 91 }catch (Exception ex) { 95 foundIt = false; 97 } 98 if (foundIt) { 99 result.addGoodDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.passed(smh.getLocalString 104 (getClass().getName() + ".passed", 105 "The form-error-page [ {0} ] value defines the location in the web application where the error page that is displayed when login is not successful can be found within web application [ {1} ]", 106 new Object [] {formErrorPage, descriptor.getName()})); 107 } else { 108 result.addErrorDetails(smh.getLocalString 109 ("tests.componentNameConstructor", 110 "For [ {0} ]", 111 new Object [] {compName.toString()})); 112 result.failed(smh.getLocalString 113 (getClass().getName() + ".failed", 114 "Error: The form-error-page [ {0} ] value does not define the location in the web application where the error page that is displayed when login is not successful can be found within web application [ {1} ]", 115 new Object [] {formErrorPage, descriptor.getName()})); 116 } 117 } else { 118 result.addNaDetails(smh.getLocalString 119 ("tests.componentNameConstructor", 120 "For [ {0} ]", 121 new Object [] {compName.toString()})); 122 result.notApplicable(smh.getLocalString 123 (getClass().getName() + ".notApplicable", 124 "There are no form-error-page elements within this web archive [ {0} ]", 125 new Object [] {descriptor.getName()})); 126 } 127 } else { 128 result.addNaDetails(smh.getLocalString 129 ("tests.componentNameConstructor", 130 "For [ {0} ]", 131 new Object [] {compName.toString()})); 132 result.notApplicable(smh.getLocalString 133 (getClass().getName() + ".notApplicable", 134 "There are no form-error-page elements within this web archive [ {0} ]", 135 new Object [] {descriptor.getName()})); 136 } 137 138 return result; 139 } 140 } 141 | Popular Tags |