1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.util.*; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 31 36 public class SecurityRolesBind extends EjbTest implements EjbCheck { 37 38 39 40 49 public Result check(EjbDescriptor descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 EjbBundleDescriptor bundleDescriptor = descriptor.getEjbBundleDescriptor(); 55 Set ejbs = bundleDescriptor.getEjbs(); 56 Iterator ejbIterator = ejbs.iterator(); 57 EjbDescriptor ejb = null; 58 Set roleReferences = null; 59 Iterator roleRefsIterator = null; 60 Set roles = bundleDescriptor.getRoles(); 61 Iterator rolesIterator = roles.iterator(); 62 RoleReference roleReference = null; 63 Role role = null; 64 boolean oneFailed = false; 65 66 while (ejbIterator.hasNext()) { 68 ejb = (EjbDescriptor)ejbIterator.next(); 69 roleReferences = ejb.getRoleReferences(); 70 roleRefsIterator = roleReferences.iterator(); 71 if (roleRefsIterator.hasNext()) { 72 while (roleRefsIterator.hasNext()) { 73 roleReference = (RoleReference)roleRefsIterator.next(); 74 role = roleReference.getRole(); 75 if (!role.getName().equals("") 76 && !bundleDescriptor.getRoles().contains(role) ) { 77 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: The role [ {0} ] for bean [ {1} ] is undefined.", 85 new Object [] {role.getName(),ejb.getName()})); 86 if (!oneFailed) { 87 oneFailed = true; 88 } 89 } else { 90 result.addGoodDetails(smh.getLocalString 91 ("tests.componentNameConstructor", 92 "For [ {0} ]", 93 new Object [] {compName.toString()})); 94 result.passed(smh.getLocalString 95 (getClass().getName() + ".passed", 96 "The role [ {0} ] for bean [ {1} ] is defined.", 97 new Object [] {role.getName(),ejb.getName()})); 98 } 99 } 100 } else { 101 result.addNaDetails(smh.getLocalString 102 ("tests.componentNameConstructor", 103 "For [ {0} ]", 104 new Object [] {compName.toString()})); 105 result.notApplicable(smh.getLocalString 106 (getClass().getName() + ".notApplicable", 107 "There are no role references which need to be bound to other security roles within this bean [ {0} ]", 108 new Object [] {ejb.getName()})); 109 } 110 } 111 112 if (oneFailed) { 113 result.setStatus(Result.FAILED); 114 } 115 116 return result; 117 } 118 } 119 | Popular Tags |