1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 26 import java.util.*; 27 import java.io.*; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 import com.sun.enterprise.util.FileClassLoader; 32 33 34 38 public class WebResourceName extends WebTest implements WebCheck { 39 40 41 49 public Result check(WebBundleDescriptor descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 if (descriptor.getSecurityConstraints().hasMoreElements()) { 55 boolean oneFailed = false; 56 int na = 0; 57 int noSc = 0; 58 boolean foundIt = false; 59 for (Enumeration e = descriptor.getSecurityConstraints() ; e.hasMoreElements() ;) { 61 foundIt = false; 62 noSc++; 63 SecurityConstraintImpl securityConstraintImpl = (SecurityConstraintImpl) e.nextElement(); 64 if (securityConstraintImpl.getWebResourceCollections().hasMoreElements()) { 65 for (Enumeration ee = securityConstraintImpl.getWebResourceCollections(); ee.hasMoreElements();) { 66 WebResourceCollectionImpl webResCollection = (WebResourceCollectionImpl) ee.nextElement(); 67 String webRCName = webResCollection.getName(); 68 if (webRCName.length() > 0) { 70 foundIt = true; 71 } else { 72 foundIt = false; 73 } 74 75 if (foundIt) { 76 result.addGoodDetails(smh.getLocalString 77 ("tests.componentNameConstructor", 78 "For [ {0} ]", 79 new Object [] {compName.toString()})); 80 result.addGoodDetails(smh.getLocalString 81 (getClass().getName() + ".passed", 82 "web-resource-name [ {0} ] contains the name of this web resource collection within web application [ {1} ]", 83 new Object [] {webRCName, descriptor.getName()})); 84 } else { 85 if (!oneFailed) { 86 oneFailed = true; 87 } 88 result.addErrorDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.addErrorDetails(smh.getLocalString 93 (getClass().getName() + ".failed", 94 "Error: web-resource-name [ {0} ] does not contain the name of this web resource collection within web application [ {1} ]", 95 new Object [] {webRCName, descriptor.getName()})); 96 } 97 } 98 } else { 99 result.addNaDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.notApplicable(smh.getLocalString 104 (getClass().getName() + ".notApplicable2", 105 "There are no web web resource collections in the web security constraint within [ {0} ]", 106 new Object [] {descriptor.getName()})); 107 na++; 108 } 109 } 110 if (oneFailed) { 111 result.setStatus(Result.FAILED); 112 } else if (na == noSc) { 113 result.setStatus(Result.NOT_APPLICABLE); 114 } else { 115 result.setStatus(Result.PASSED); 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 web-resource-name elements within the web archive [ {0} ]", 125 new Object [] {descriptor.getName()})); 126 } 127 128 return result; 129 } 130 } 131 | Popular Tags |