FileDocCategorySizeDatePackage
CredentialInterface.javaAPI DocGlassfish v2 API6068Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.connector

CredentialInterface

public class CredentialInterface extends ConnectorTest implements ConnectorCheck
All Credential interface declared in the DD should be one of the allowed interface
author
Jerome Dochez
version

Fields Summary
private static String[]
allowedInterfaces
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.ConnectorDescriptor descriptor)

All Credential interface declared in the DD should be one of the allowed interface

paramm
descriptor deployment descriptor for the rar file
return
result object containing the result of the individual test performed


                                             
        
        boolean oneFailed = false;
        Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        if(!descriptor.getOutBoundDefined())
        {
          result.addNaDetails(smh.getLocalString
              ("tests.componentNameConstructor",
               "For [ {0} ]",
               new Object[] {compName.toString()}));
          result.notApplicable(smh.getLocalString
              ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
               "Resource Adapter does not provide outbound communication"));
          return result;
        }
        Set mechanisms = 
        descriptor.getOutboundResourceAdapter().getAuthMechanisms();
        if (mechanisms.isEmpty()) {
            // passed
	    result.addGoodDetails(smh.getLocalString
				  ("tests.componentNameConstructor",
				   "For [ {0} ]",
				   new Object[] {compName.toString()}));	
	    result.passed(smh.getLocalString
    	        ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.nonexist",
                 "No authentication mechanism defined for this resource adapater"));
            return result;
        }
        Iterator mechIterator = mechanisms.iterator();
        while (mechIterator.hasNext()) {
            AuthMechanism am = (AuthMechanism) mechIterator.next();
            String credInterface = am.getCredentialInterface();
            boolean allowedInterface = false;            
            if (credInterface!=null) { 
                for (int i=0;i<allowedInterfaces.length;i++) {
                    if (credInterface.equals(allowedInterfaces[i])) {
                        allowedInterface = true;
                        break;
                    }
                }
            }
            if (!allowedInterface || credInterface == null) {
                // failed
                oneFailed = true;
        	result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		result.failed(smh.getLocalString
    	            ("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.failed",
                    "Authentication mechanism credential interface [ {0} ] defined in the credential-interface tag is not allowed",
                    new Object[] {credInterface}));
            }
        }
        if (!oneFailed) {
	    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));	
		result.passed(smh.getLocalString
    	        ("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.passed",
                 "All defined authorization mechanism credential interfaces are allowed"));
        }
        return result;