1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.resource; 2 24 25 import java.util.*; 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 30 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 31 import com.sun.enterprise.deployment.ResourcePrincipal; 32 33 48 49 public class ASEjbRRefDefResPrincipal extends ASEjbResRef { 50 51 public Result check(EjbDescriptor descriptor) 52 { 53 Result result = getInitializedResult(); 54 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 55 boolean oneFailed = false; 56 try{ 57 Set resRef = descriptor.getResourceReferenceDescriptors(); 58 if(!(resRef.isEmpty())){ 59 Iterator it = resRef.iterator(); 60 while (it.hasNext()){ 61 ResourceReferenceDescriptor resDesc = ((ResourceReferenceDescriptor)it.next()); 62 String refName = resDesc.getName(); 63 String refJndiName = resDesc.getJndiName(); 64 ResourcePrincipal resPrinci = resDesc.getResourcePrincipal(); 65 if(resPrinci == null) 66 { 67 try 68 { 69 resDesc = descriptor.getResourceReferenceByName(refName); 70 String resAuth = resDesc.getAuthorization(); 71 if(resAuth.equals(ResourceReferenceDescriptor.APPLICATION_AUTHORIZATION)) 72 { 73 addErrorDetails(result, compName); 74 result.failed(smh.getLocalString(getClass().getName()+".failed", 75 "FAILED [AS-EJB resource-ref] : res-auth for res-ref-name {0} is defined as Application." + 76 "Therefore the default-resource-principal should be supplied with valid properties", 77 new Object [] {refName})); 78 } 79 else 80 { 81 addNaDetails(result, compName); 82 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 83 "NOT APPLICABLE [AS-EJB resource-ref] : default-resource-principal Element not defined")); 84 } 85 } 86 catch(IllegalArgumentException iaex) 87 { 88 addErrorDetails(result, compName); 89 result.failed(smh.getLocalString(getClass().getName()+".failed2", 90 "FAILED [AS-EJB resource-ref] : res-ref-name {0} is not defined in the ejb-jar.xml", 91 new Object []{refName})); 92 } 93 }else 94 { 95 String name = resPrinci.getName(); 96 if(name == null || name.length()==0) 97 { 98 oneFailed = true; 99 addErrorDetails(result, compName); 100 result.failed(smh.getLocalString(getClass().getName()+".failed3", 101 "FAILED [AS-EJB default-resource-principal] : name cannot be an empty string")); 102 } 103 else 104 { 105 addGoodDetails(result, compName); 106 result.passed(smh.getLocalString(getClass().getName()+".passed", 107 "PASSED [AS-EJB default-resource-principal] : name is {0}",new Object []{name})); 108 } 109 110 String password = resPrinci.getPassword(); 111 if(password == null || password.length()==0) 112 { 113 addWarningDetails(result, compName); 114 result.warning(smh.getLocalString(getClass().getName()+".warning1", 115 "WARNING [AS-EJB default-resource-principal] : password is an empty string")); 116 } 117 else 118 { 119 addGoodDetails(result, compName); 120 result.passed(smh.getLocalString(getClass().getName()+".passed1", 121 "PASSED [AS-EJB default-resource-principal] : password is {0}",new Object []{password})); 122 } 123 124 if(oneFailed) 125 result.setStatus(Result.FAILED); 126 } 127 128 } 129 } 130 else 131 { 132 addNaDetails(result, compName); 133 result.notApplicable(smh.getLocalString 134 (getClass().getName() + ".notApplicable", 135 "{0} Does not define any resource-ref Elements")); 136 } 137 }catch(Exception ex) 138 { 139 addErrorDetails(result, compName); 140 result.addErrorDetails(smh.getLocalString 141 (getClass().getName() + ".notRun", 142 "NOT RUN [AS-EJB] : Could not create the descriptor object")); 143 } 144 return result; 145 } 146 } 147 | Popular Tags |