1 package com.sun.enterprise.tools.verifier.tests.ejb.ias.resource; 2 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.util.*; 27 import com.sun.enterprise.deployment.EjbDescriptor; 28 import com.sun.enterprise.deployment.EjbSessionDescriptor; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 34 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar; 35 import com.sun.enterprise.tools.common.dd.ejb.Ejb; 36 import com.sun.enterprise.tools.common.dd.ResourceRef; 37 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal; 38 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 39 40 55 public class ASEjbRRefDefResPrincipal extends ASEjbResRef { 56 57 public Result check(EjbDescriptor descriptor) 58 { 59 Result result = getInitializedResult(); 60 ComponentNameConstructor compName = new ComponentNameConstructor(descriptor); 61 62 SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject(); 63 boolean oneFailed = false; 64 65 if(ejbJar!=null) 66 { 67 Ejb ejbs[] = ejbJar.getEnterpriseBeans().getEjb(); 68 Ejb testCase = null; 69 for(int i=0;i<ejbs.length;i++) 70 { 71 if(ejbs[i].getEjbName().equals(descriptor.getName())) 72 { 73 testCase = ejbs[i]; 74 break; 75 } 76 } 77 78 ResourceRef resRefs[] = testCase.getResourceRef(); 79 ResourceReferenceDescriptor resDesc; 80 if(resRefs.length > 0) 81 { 82 for(int i=0;i<resRefs.length;i++) 83 { 84 String refName = resRefs[i].getResRefName(); 85 String refJndiName = resRefs[i].getJndiName(); 86 DefaultResourcePrincipal defPrinci = resRefs[i].getDefaultResourcePrincipal(); 87 if(defPrinci == null) 88 { 89 try 90 { 91 resDesc = descriptor.getResourceReferenceByName(refName); 92 String resAuth = resDesc.getAuthorization(); 93 if(resAuth.equals(ResourceReferenceDescriptor.APPLICATION_AUTHORIZATION)) 94 { 95 result.failed(smh.getLocalString(getClass().getName()+".failed", 96 "FAILED [AS-EJB resource-ref] : res-auth for res-ref-name {0} is defined as Application." + 97 "Therefore the default-resource-principal should be supplied with valid properties", 98 new Object [] {refName})); 99 } 100 else 101 { 102 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 103 "NOT APPLICABLE [AS-EJB resource-ref] : default-resource-principal Element not defined")); 104 } 105 } 106 catch(IllegalArgumentException iaex) 107 { 108 result.failed(smh.getLocalString(getClass().getName()+".failed2", 109 "FAILED [AS-EJB resource-ref] : res-ref-name {0} is not defined in the ejb-jar.xml", 110 new Object []{refName})); 111 } 112 } 113 else 114 { 115 String name = defPrinci.getName(); 116 if(name.length()==0) 117 { 118 oneFailed = true; 119 result.failed(smh.getLocalString(getClass().getName()+".failed3", 120 "FAILED [AS-EJB default-resource-principal] : name cannot be an empty string")); 121 } 122 else 123 { 124 result.passed(smh.getLocalString(getClass().getName()+".passed", 125 "PASSED [AS-EJB default-resource-principal] : name is {0}",new Object []{name})); 126 } 127 128 String password = defPrinci.getPassword(); 129 if(password.length()==0) 130 { 131 result.warning(smh.getLocalString(getClass().getName()+".warning1", 136 "WARNING [AS-EJB default-resource-principal] : password is an empty string")); 137 } 139 else 140 { 141 result.passed(smh.getLocalString(getClass().getName()+".passed", 142 "PASSED [AS-EJB default-resource-principal] : password is {0}",new Object []{password})); 143 } 144 145 if(oneFailed) 146 result.setStatus(Result.FAILED); 147 } 148 } } 150 else 151 { 152 result.notApplicable(smh.getLocalString 153 (getClass().getName() + ".notApplicable", 154 "{0} Does not define any resource-ref Elements", 155 new Object [] {descriptor.getName()})); 156 } 157 } 158 else 159 { 160 result.addErrorDetails(smh.getLocalString 161 (getClass().getName() + ".notRun", 162 "NOT RUN [AS-EJB] : Could not create an SunEjbJar object")); 163 } 164 return result; 165 } 166 } 167 168 | Popular Tags |