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 36 public class SecurityRolesRefs extends EjbTest implements EjbCheck { 37 38 39 49 public Result check(EjbDescriptor descriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 if ((descriptor instanceof EjbEntityDescriptor) || 54 (descriptor instanceof EjbSessionDescriptor)) { 55 56 Set roleReferences = descriptor.getRoleReferences(); 58 Iterator roleRefsIterator = roleReferences.iterator(); 59 EjbBundleDescriptor bundleDescriptor = descriptor.getEjbBundleDescriptor(); 60 Set roles = bundleDescriptor.getRoles(); 61 Iterator roleIterator = roles.iterator(); 62 Role role = null; 63 RoleReference roleReference = null; 64 boolean found = false; 65 boolean oneFailed = false; 66 67 if (roleRefsIterator.hasNext()) { 68 while (roleRefsIterator.hasNext()) { 69 found = false; 70 roleReference = (RoleReference)roleRefsIterator.next(); 71 72 while (roleIterator.hasNext()) { 73 role = (Role)roleIterator.next(); 74 if (role.getName().equals(roleReference.getValue())) { 75 found = true; 76 roleIterator = roles.iterator(); 78 break; 79 } 80 } 81 82 if (!found) { 83 result.addErrorDetails(smh.getLocalString 85 ("tests.componentNameConstructor", 86 "For [ {0} ]", 87 new Object [] {compName.toString()})); 88 result.addErrorDetails(smh.getLocalString 89 (getClass().getName() + ".failed", 90 "Erro: The security role reference [ {0} ] has no corresponding linked security role name [ {1} ]", 91 new Object [] {roleReference.getName(),roleReference.getValue()})); 92 if (!oneFailed) { 93 oneFailed = true; 94 } 95 } else { 96 result.addGoodDetails(smh.getLocalString 97 ("tests.componentNameConstructor", 98 "For [ {0} ]", 99 new Object [] {compName.toString()})); 100 result.addGoodDetails(smh.getLocalString 101 (getClass().getName() + ".passed", 102 "The security role reference [ {0} ] has corresponding linked security role name [ {1} ]", 103 new Object [] {roleReference.getName(),roleReference.getValue()})); 104 } 105 } 106 } else { 107 result.addNaDetails(smh.getLocalString 108 ("tests.componentNameConstructor", 109 "For [ {0} ]", 110 new Object [] {compName.toString()})); 111 result.notApplicable(smh.getLocalString 112 (getClass().getName() + ".notApplicable1", 113 "There are no role references within this bean [ {0} ]", 114 new Object [] {descriptor.getName()})); 115 return result; 116 } 117 118 if (oneFailed) { 121 result.setStatus(Result.FAILED); 122 } else { 123 result.setStatus(Result.PASSED); 124 } 125 126 return result; 127 } else { 128 result.addNaDetails(smh.getLocalString 129 ("tests.componentNameConstructor", 130 "For [ {0} ]", 131 new Object [] {compName.toString()})); 132 result.notApplicable(smh.getLocalString 133 (getClass().getName() + ".notApplicable", 134 "[ {0} ] not called \n with a Session or Entity bean.", 135 new Object [] {getClass()})); 136 return result; 137 } 138 } 139 } 140 | Popular Tags |