1 23 28 29 package com.sun.enterprise.tools.verifier.tests.connector; 30 31 import java.util.*; 32 import com.sun.enterprise.tools.verifier.Result; 33 import com.sun.enterprise.deployment.ConnectorDescriptor; 34 import com.sun.enterprise.tools.verifier.tests.*; 35 import com.sun.enterprise.deployment.AuthMechanism; 36 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 37 38 43 public class AuthMechType extends ConnectorTest implements ConnectorCheck { 44 45 46 private static String [] allowedMechs = { 47 ConnectorTagNames.DD_BASIC_PASSWORD, 48 ConnectorTagNames.DD_KERBEROS }; 49 50 58 public Result check(ConnectorDescriptor descriptor) { 59 boolean oneFailed = false; 60 Result result = getInitializedResult(); 61 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 62 if(!descriptor.getOutBoundDefined()) 63 { 64 result.addNaDetails(smh.getLocalString 65 ("tests.componentNameConstructor", 66 "For [ {0} ]", 67 new Object [] {compName.toString()})); 68 result.notApplicable(smh.getLocalString 69 ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA", 70 "Resource Adapter does not provide outbound communication")); 71 return result; 72 } 73 Set mechanisms = 74 descriptor.getOutboundResourceAdapter().getAuthMechanisms(); 75 if (mechanisms.isEmpty()) { 76 result.addGoodDetails(smh.getLocalString 78 ("tests.componentNameConstructor", 79 "For [ {0} ]", 80 new Object [] {compName.toString()})); 81 result.passed(smh.getLocalString 82 ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.nonexist", 83 "No authentication mechanism defined for this resource adapater")); 84 return result; 85 } 86 Iterator mechIterator = mechanisms.iterator(); 87 while (mechIterator.hasNext()) { 88 AuthMechanism am = (AuthMechanism) mechIterator.next(); 89 String authMechType = am.getAuthMechType(); 90 boolean allowedMech = false; 91 if (authMechType!=null) { 92 for (int i=0;i<allowedMechs.length;i++) { 93 if (authMechType.equals(allowedMechs[i])) { 94 allowedMech = true; 95 break; 96 } 97 } 98 } 99 if (!allowedMech || authMechType == null) { 100 oneFailed = true; 102 result.addErrorDetails(smh.getLocalString 103 ("tests.componentNameConstructor", 104 "For [ {0} ]", 105 new Object [] {compName.toString()})); 106 result.failed(smh.getLocalString 107 ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.failed", 108 "Authentication mechanism type [ {0} ] is not allowed")); 109 } 110 } 111 if (!oneFailed) { 112 result.addGoodDetails(smh.getLocalString 113 ("tests.componentNameConstructor", 114 "For [ {0} ]", 115 new Object [] {compName.toString()})); 116 result.passed(smh.getLocalString 117 ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.passed", 118 "All defined authentication mechanism types are allowed")); 119 } 120 return result; 121 } 122 } 123 | Popular Tags |