1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import java.util.*; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 32 33 37 public class ResourceAuth extends WebTest implements WebCheck{ 38 39 40 47 public Result check(WebBundleDescriptor descriptor) { 48 49 Set resourceRefs; 50 ResourceReferenceDescriptor resrefDes; 51 Iterator itr; 52 String resAuth; 53 Result result = getInitializedResult(); 54 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 55 boolean oneFailed = false; 56 57 if (!descriptor.getResourceReferenceDescriptors().isEmpty()) { 58 59 resourceRefs = descriptor.getResourceReferenceDescriptors(); 61 itr = resourceRefs.iterator(); 62 while (itr.hasNext()) { 64 resrefDes = (ResourceReferenceDescriptor)itr.next(); 65 resAuth = resrefDes.getAuthorization(); 66 if (resAuth.equals("Application") || resAuth.equals("Container")) { 67 result.addGoodDetails(smh.getLocalString 68 ("tests.componentNameConstructor", 69 "For [ {0} ]", 70 new Object [] {compName.toString()})); 71 result.addGoodDetails(smh.getLocalString 72 (getClass().getName() + ".passed", 73 "Resource reference has valid authorization.")); 74 } 75 76 else { 77 oneFailed = true; 78 result.addErrorDetails(smh.getLocalString 79 ("tests.componentNameConstructor", 80 "For [ {0} ]", 81 new Object [] {compName.toString()})); 82 result.addErrorDetails(smh.getLocalString 83 (getClass().getName() + ".failed", 84 "Error: Resource reference auth has to be either Container or Application.")); 85 86 } 87 } 88 89 } else { 90 result.addNaDetails(smh.getLocalString 91 ("tests.componentNameConstructor", 92 "For [ {0} ]", 93 new Object [] {compName.toString()})); 94 result.notApplicable(smh.getLocalString 95 (getClass().getName() + ".notApplicable", 96 "There are no resource references defined within the web archive [ {0} ]", 97 new Object [] {descriptor.getName()})); 98 } 99 if (oneFailed) { 100 result.setStatus(Result.FAILED); 101 } else { 102 result.setStatus(Result.PASSED); 103 } 104 return result; 105 } 106 } 107 | Popular Tags |