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 37 public class SecurityIdentityRefs extends EjbTest { 38 39 40 50 public Result check(EjbDescriptor descriptor) { 51 52 Result result = getInitializedResult(); 53 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 54 if (descriptor.getUsesCallerIdentity()){ 55 result.addNaDetails(smh.getLocalString 56 ("tests.componentNameConstructor", 57 "For [ {0} ]", 58 new Object [] {compName.toString()})); 59 result.notApplicable(smh.getLocalString( 60 "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.notApplicable3", 61 "Bean [ {0} ] does not specify a run-as identity", 62 new Object [] {descriptor.getName()})); 63 return result; 64 } 65 RunAsIdentityDescriptor identity = descriptor.getRunAsIdentity(); 66 if (identity == null) { 67 result.addNaDetails(smh.getLocalString 68 ("tests.componentNameConstructor", 69 "For [ {0} ]", 70 new Object [] {compName.toString()})); 71 result.notApplicable(smh.getLocalString( 72 "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.notApplicable2", 73 "Bean [ {0} ] does not specify a security identity", 74 new Object [] {descriptor.getName()})); 75 return result; 76 } 77 78 EjbBundleDescriptor bundleDescriptor = descriptor.getEjbBundleDescriptor(); 79 Set roles = bundleDescriptor.getRoles(); 80 Iterator roleIterator = roles.iterator(); 81 while (roleIterator.hasNext()) { 82 Role role = (Role) roleIterator.next(); 83 if (role.getName().equals(identity.getRoleName())) { 84 result.addGoodDetails(smh.getLocalString 85 ("tests.componentNameConstructor", 86 "For [ {0} ]", 87 new Object [] {compName.toString()})); 88 result.passed(smh.getLocalString( 89 "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.passed", 90 "Security identity run-as specified identity [ {0} ] role is found in the list of roles", 91 new Object [] {role.getName()})); 92 return result; 93 } 94 } 95 result.addErrorDetails(smh.getLocalString 96 ("tests.componentNameConstructor", 97 "For [ {0} ]", 98 new Object [] {compName.toString()})); 99 result.failed(smh.getLocalString( 100 "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.failed", 101 "Security identity run-as specified identity [ {0} ] role is not valid", 102 new Object [] {identity.getRoleName()})); 103 return result; 104 } 105 106 } 107 | Popular Tags |