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 TransportGuarantee 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 boolean foundIt = false; 57 int na = 0; 58 int noSc = 0; 59 for (Enumeration e = descriptor.getSecurityConstraints() ; e.hasMoreElements() ;) { 61 foundIt = false; 62 noSc++; 63 SecurityConstraintImpl securityConstraintImpl = (SecurityConstraintImpl) e.nextElement(); 64 UserDataConstraintImpl userDataConstraint = (UserDataConstraintImpl) securityConstraintImpl.getUserDataConstraint(); 65 if (userDataConstraint != null) { 66 String transportGuarantee = userDataConstraint.getTransportGuarantee(); 67 if (transportGuarantee.length() > 0) { 68 if ((transportGuarantee.equals("NONE")) || 69 (transportGuarantee.equals("INTEGRAL")) || 70 (transportGuarantee.equals("CONFIDENTIAL"))) { 71 foundIt = true; 72 } else { 73 foundIt = false; 74 } 75 } else { 76 foundIt = false; 77 } 78 79 if (foundIt) { 80 result.addGoodDetails(smh.getLocalString 81 ("tests.componentNameConstructor", 82 "For [ {0} ]", 83 new Object [] {compName.toString()})); 84 result.addGoodDetails(smh.getLocalString 85 (getClass().getName() + ".passed", 86 "transport-guarantee [ {0} ] specifies that the communication between client and server should be one of \"SECURE\", \"NONE\", or \"CONFIDENTIAL\" within web application [ {1} ]", 87 new Object [] {transportGuarantee, descriptor.getName()})); 88 } else { 89 if (!oneFailed) { 90 oneFailed = true; 91 } 92 result.addErrorDetails(smh.getLocalString 93 ("tests.componentNameConstructor", 94 "For [ {0} ]", 95 new Object [] {compName.toString()})); 96 result.addErrorDetails(smh.getLocalString 97 (getClass().getName() + ".failed", 98 "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} ]", 99 new Object [] {transportGuarantee, descriptor.getName()})); 100 } 101 } else { 102 result.addNaDetails(smh.getLocalString 103 ("tests.componentNameConstructor", 104 "For [ {0} ]", 105 new Object [] {compName.toString()})); 106 result.addNaDetails(smh.getLocalString 107 (getClass().getName() + ".notApplicable1", 108 "There are no transport-guarantee elements within the web application [ {0} ]", 109 new Object [] {descriptor.getName()})); 110 na++; 111 } 112 } 113 if (oneFailed) { 114 result.setStatus(Result.FAILED); 115 } else if (na == noSc) { 116 result.setStatus(Result.NOT_APPLICABLE); 117 } else { 118 result.setStatus(Result.PASSED); 119 } 120 } else {result.addNaDetails(smh.getLocalString 121 ("tests.componentNameConstructor", 122 "For [ {0} ]", 123 new Object [] {compName.toString()})); 124 result.notApplicable(smh.getLocalString 125 (getClass().getName() + ".notApplicable", 126 "There are no transport-guarantee elements within the web archive [ {0} ]", 127 new Object [] {descriptor.getName()})); 128 } 129 130 return result; 131 } 132 } 133 | Popular Tags |