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

TransportGuarantee

public class TransportGuarantee extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements WebCheck
The transport-guarantee element specifies that the communication between client and server should be "SECURE", "NONE", or "CONFIDENTIAL".

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
The transport-guarantee element specifies that the communication between client and server should be "SECURE", "NONE", or "CONFIDENTIAL".

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


	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

	if (descriptor.getSecurityConstraints().hasMoreElements()) {
	    boolean oneFailed = false;
	    boolean foundIt = false;
	    int na = 0;
	    int noSc = 0;
	    // get the errorpage's in this .war
	    for (Enumeration e = descriptor.getSecurityConstraints() ; e.hasMoreElements() ;) {
		foundIt = false;
                noSc++;
		SecurityConstraintImpl securityConstraintImpl = (SecurityConstraintImpl) e.nextElement();
		UserDataConstraintImpl userDataConstraint = (UserDataConstraintImpl) securityConstraintImpl.getUserDataConstraint();
		if (userDataConstraint != null) {
                    String transportGuarantee = userDataConstraint.getTransportGuarantee(); 
		    if (transportGuarantee.length() > 0) {
		        if ((transportGuarantee.equals("NONE")) ||
			    (transportGuarantee.equals("INTEGRAL")) ||
			    (transportGuarantee.equals("CONFIDENTIAL"))) {
			    foundIt = true;
		        } else {
			    foundIt = false;
		        }
		    } else {
		        foundIt = false;
		    }
         
		    if (foundIt) {
			result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		        result.addGoodDetails(smh.getLocalString
					      (getClass().getName() + ".passed",
					       "transport-guarantee [ {0} ] specifies that the communication between client and server should be one of \"SECURE\", \"NONE\", or \"CONFIDENTIAL\" within web application [ {1} ]",
					       new Object[] {transportGuarantee, descriptor.getName()}));
		    } else {
		        if (!oneFailed) {
			    oneFailed = true;
		        }
			result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		        result.addErrorDetails(smh.getLocalString
					       (getClass().getName() + ".failed",
					        "Error: transport-guarantee [ {0} ] does not specify that the communication between client and server is one of \"SECURE\", \"NONE\", or \"CONFIDENTIAL\" within web application [ {1} ]",
					        new Object[] {transportGuarantee, descriptor.getName()}));
		    }
	        } else {
		    result.addNaDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	            result.addNaDetails(smh.getLocalString
			 (getClass().getName() + ".notApplicable1",
			  "There are no transport-guarantee elements within the web application [ {0} ]",
			  new Object[] {descriptor.getName()}));
                    na++;
	        }
	    }
	    if (oneFailed) {
		result.setStatus(Result.FAILED);
	    } else if (na == noSc) {
		result.setStatus(Result.NOT_APPLICABLE);
	    } else {
		result.setStatus(Result.PASSED);
	    }
	} else {result.addNaDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
				 (getClass().getName() + ".notApplicable",
				  "There are no transport-guarantee elements within the web archive [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}

	return result;