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.util.logging.Level ; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 33 38 public class RoleLink extends WebTest implements WebCheck { 39 40 49 public Result check(WebBundleDescriptor descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 if (descriptor.getWebComponentDescriptors().hasMoreElements()) { 55 boolean oneFailed = false; 56 int na = 0; 57 int noWd = 0; 58 for (Enumeration e = descriptor.getWebComponentDescriptors(); e.hasMoreElements();) { 59 noWd++; 60 WebComponentDescriptor next = (WebComponentDescriptor) e.nextElement(); 61 boolean foundIt = false; 62 if (next.getSecurityRoleReferences().hasMoreElements()) { 64 for (Enumeration ee = next.getSecurityRoleReferences(); ee.hasMoreElements();) { 65 RoleReference rr = (RoleReference) ee.nextElement(); 66 foundIt = false; 67 String linkName = rr.getValue(); 68 logger.log(Level.FINE, "servlet linkName: " + linkName); 69 if (descriptor.getSecurityRoles().hasMoreElements()) { 71 for (Enumeration eee = descriptor.getSecurityRoles(); eee.hasMoreElements();) { 72 SecurityRoleDescriptor srdNext = (SecurityRoleDescriptor) eee.nextElement(); 73 74 if (linkName.equals(srdNext.getName())) { 75 foundIt = true; 76 break; 77 } else { 78 continue; 79 } 80 } 81 } else { 82 foundIt = false; 84 } 85 86 if (foundIt) { 87 result.addGoodDetails(smh.getLocalString 88 ("tests.componentNameConstructor", 89 "For [ {0} ]", 90 new Object [] {compName.toString()})); 91 result.addGoodDetails(smh.getLocalString 92 (getClass().getName() + ".passed", 93 "role-link [ {0} ] links security role reference to a defined security role within web application [ {1} ]", 94 new Object [] {linkName, descriptor.getName()})); 95 } else { 96 if (!oneFailed) { 97 oneFailed = true; 98 } 99 result.addErrorDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.addErrorDetails(smh.getLocalString 104 (getClass().getName() + ".failed", 105 "Error: role-link [ {0} ] does not link security role reference to a defined security role within web application [ {1} ]", 106 new Object [] {linkName, descriptor.getName()})); 107 } 108 } } else { 110 result.addNaDetails(smh.getLocalString 111 ("tests.componentNameConstructor", 112 "For [ {0} ]", 113 new Object [] {compName.toString()})); 114 result.addNaDetails(smh.getLocalString 115 (getClass().getName() + ".notApplicable1", 116 "[ {0} ] has no role-link element defined within the web archive [ {1} ]", 117 new Object [] {next.getName(),descriptor.getName()})); 118 na++; 119 } 120 } if (oneFailed) { 122 result.setStatus(Result.FAILED); 123 } else if (na == noWd) { 124 result.setStatus(Result.NOT_APPLICABLE); 125 } else { 126 result.setStatus(Result.PASSED); 127 } 128 } else { 129 result.addNaDetails(smh.getLocalString 130 ("tests.componentNameConstructor", 131 "For [ {0} ]", 132 new Object [] {compName.toString()})); 133 result.notApplicable(smh.getLocalString 134 (getClass().getName() + ".notApplicable", 135 "There are no location elements within the web archive [ {0} ]", 136 new Object [] {descriptor.getName()})); 137 } 138 139 return result; 140 } 141 } 142 | Popular Tags |