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

AuthMechType

public class AuthMechType extends ConnectorTest implements ConnectorCheck
All Authorization Mechanism type should be of an allowed type
author
Jerome Dochez
version

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

All Authorization Mechanism type should be of an allowed type

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 authMechType = am.getAuthMechType();
            boolean allowedMech = false;            
            if (authMechType!=null) { 
                for (int i=0;i<allowedMechs.length;i++) {
                    if (authMechType.equals(allowedMechs[i])) {
                        allowedMech = true;
                        break;
                    }
                }
            }
            if (!allowedMech || authMechType == 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.AuthMechType.failed",
                    "Authentication mechanism type [ {0} ] is not allowed"));
            }
        }
        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.AuthMechType.passed",
                 "All defined authentication mechanism types are allowed"));
        }
        return result;