FileDocCategorySizeDatePackage
ResourceAuth.javaAPI DocGlassfish v2 API5013Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

ResourceAuth

public class ResourceAuth extends WebTest implements WebCheck
Must check for the correct authorization.
author
Arun Jain

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
Resource authority exists test. Must be Container or Servlet.

param
descriptor the Web deployment descriptor
return
Result the results for this assertion


        Set resourceRefs;
        ResourceReferenceDescriptor resrefDes;
        Iterator itr;
        String resAuth;
	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        boolean oneFailed = false;
        
	if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
            
	    // get the Resource Reference Descriptors set
	    resourceRefs = descriptor.getResourceReferenceDescriptors();
	    itr = resourceRefs.iterator();
	    // test the Resource Reference Descriptor
	    while (itr.hasNext()) {
		resrefDes = (ResourceReferenceDescriptor)itr.next();
		resAuth = resrefDes.getAuthorization();
                if (resAuth.equals("Application") || resAuth.equals("Container")) {
		    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		result.addGoodDetails(smh.getLocalString
                                       (getClass().getName() + ".passed",
                                    "Resource reference has valid authorization."));
                }

                else {
                    oneFailed = true;
		    result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		    result.addErrorDetails(smh.getLocalString
                                       (getClass().getName() + ".failed",
                                    "Error: Resource reference auth has to be either Container or Application."));

                }
            }
            
        } else {
	    result.addNaDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
                                 (getClass().getName() + ".notApplicable",
                                  "There are no resource references defined within the web archive [ {0} ]",
                                  new Object[] {descriptor.getName()}));
        }
        if (oneFailed) {
            result.setStatus(Result.FAILED);
        } else {
            result.setStatus(Result.PASSED);
        }
	return result;