FileDocCategorySizeDatePackage
ASEjbIORSecurityConfig.javaAPI DocGlassfish v2 API15637Fri May 04 22:34:04 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.runtime

ASEjbIORSecurityConfig

public class ASEjbIORSecurityConfig extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
ejb [0,n] ior-security-config ? transport-config? integrity [String] confidentiality [String] establish-trust-in-client [String] establish-trust-in-target [String] as-context? auth-method [String] realm [String] required [String] sas-context? caller-propagation [String] The tag describes the security configuration for the IOR
author
Irfan Ahmed

Fields Summary
boolean
oneFailed
Constructors Summary
Methods Summary
public Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)
The function that performs the test.

param
descriptor EjbDescriptor object representing the bean.


                          
        
    
        Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        int count = 0;
        try{
//            Set ejbIORConfDescSet = descriptor.getIORConfigurationDescriptors();
            count = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config");
            if (count>0){
                for(int i=0;i<count;i++){
                    testTranConfig(i, descriptor, compName, result);
                    testAsContext(i, descriptor, compName, result);
                    testSasContext(i, descriptor, compName, result);
                }
            }else{
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                    "NOT APPLICABLE [AS-EJB ior-security-config] : ior-security-config Element not defined"));
            }

            if(oneFailed)
                result.setStatus(Result.FAILED);
        }catch(Exception ex){
            addErrorDetails(result, compName);
            result.addErrorDetails(smh.getLocalString
                (getClass().getName() + ".notRun",
                "NOT RUN [AS-EJB] : Could not create a descriptor object"));
        }
        return result;

    
protected voidtestAsContext(int i, com.sun.enterprise.deployment.EjbDescriptor descriptor, ComponentNameConstructor compName, Result result)
The function tests the tag for valid values

param
param
result Result object

        try{
            int counter = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config/as-context");
            if (counter>0){
                //auth-method
                String value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/as-context/auth-method");
                if(value==null || value.length()==0){
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName()+".failedAsContextAuthMethod",
                        "FAILED [AS-EJB as-context] : auth-method cannot be an empty string"));
                }else{
                    if(value.equals("USERNAME_PASSWORD")){
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName()+".passedAsContextAuthMethod",
                            "PASSED [AS-EJB as-context] : auth-method is {0}", new Object[] {value}));
                    }else{
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName()+".failedAsContextAuthMethod1",
                            "FAILED [AS-EJB as-context] : auth-method cannot be {0}. It can only be USERNAME_PASSWORD"
                            ,new Object[]{value}));
                    }
                }
                //realm
                value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/as-context/realm");
                if (value != null){
                    if(value.length()==0){
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRealm",
                            "FAILED [AS-EJB as-context] : realm cannot be an empty string"));

                    }else{
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName()+".passedAsContextRealm",
                            "PASSED [AS-EJB as-context] : realm is {0}", new Object[] {value}));
                    }
                } else {
                    oneFailed = true;
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRealm1",
                            "FAILED [AS-EJB as-context] : realm cannot be null"));
                }
                //required
                value = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/as-context/required");
                if(value==null || value.length()==0){
                    oneFailed = true;
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRequired1",
                        "FAILED [AS-EJB as-context] : required cannot be an empty string"));
                }else{
                    if(value.equals("true") || value.equals("false")){
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName()+".passedAsContextRequired",
                            "PASSED [AS-EJB as-context] : required is {0}", new Object[]{new Boolean(value)}));
                    }else{
                        oneFailed = true;
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRequired2",
                            "FAILED [AS-EJB as-context] : required cannot be {0}. It can only be USERNAME_PASSWORD"
                            ,new Object[]{value}));
                    }
                }
            }else{
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2",
                    "NOT APPLICABLE [AS-EJB ior-security-config] :  Element not defined"));
            }

        }catch(Exception ex){
            oneFailed = true;
            addErrorDetails(result, compName);
            result.addErrorDetails(smh.getLocalString
                (getClass().getName() + ".notRun",
                "NOT RUN [AS-EJB] : Could not create a descriptor object"));
        }
        
    
private voidtestMsgs(java.lang.String tCase, Result result, java.lang.String parentElement, java.lang.String testElement, ComponentNameConstructor compName)

        if(tCase.length()==0)
        {
            oneFailed = true;
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg",
                "FAILED [AS-EJB {1}] : {2} cannot be an empty String",
                new Object[]{tCase, parentElement, testElement}));
        }
        else
        {
            if(!tCase.equals("NONE") && !tCase.equals("SUPPORTED") 
                && !tCase.equals("REQUIRED"))
            {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg1",
                    "FAILED [AS-EJB {1}] : {2} cannot be {0}. It can be either NONE, SUPPORTED or REQUIRED",
                    new Object[]{tCase, parentElement, testElement}));
            }
            else {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName()+".passedTestMsg",
                    "PASSED [AS-EJB "+ parentElement+"] : " + testElement +" is {0}", new Object[]{tCase}));
            }
        }
    
private voidtestMsgs1(java.lang.String tCase, Result result, java.lang.String parentElement, java.lang.String testElement, ComponentNameConstructor compName)
This method will check for values that should be either NONE or SUPPORTED

        if(tCase.length()==0)
        {
            oneFailed = true;
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg",
                "FAILED [AS-EJB {1}] : {2} cannot be an empty String",
                new Object[]{tCase, parentElement, testElement}));
        }
        else
        {
            if(!tCase.equals("NONE") && !tCase.equals("SUPPORTED"))
            {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg2",
                    "FAILED [AS-EJB {1}] : {2} cannot be {0}. It can be either NONE or SUPPORTED.",
                    new Object[]{tCase, parentElement, testElement}));
            }
            else {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName()+".passedTestMsg",
                    "PASSED [AS-EJB "+ parentElement+"] : " + testElement +" is {0}", new Object[]{tCase}));
            }
        }
    
protected voidtestSasContext(int i, com.sun.enterprise.deployment.EjbDescriptor descriptor, ComponentNameConstructor compName, Result result)

param
param
result

        try{
            int counter = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config/sas-context");
            if (counter>0){
                String caller = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/sas-context/caller-propagation");
                if (caller!=null){
                    testMsgs1(caller,result,"sas-context","caller-propagation", compName);
                }
            }
        }catch(Exception ex){
            oneFailed = true;
            addErrorDetails(result, compName);
            result.addErrorDetails(smh.getLocalString
                (getClass().getName() + ".notRun",
                "NOT RUN [AS-EJB] : Could not create a descriptor object"));
        }
    
protected voidtestTranConfig(int i, com.sun.enterprise.deployment.EjbDescriptor descriptor, ComponentNameConstructor compName, Result result)
This function tests the tag for valid values

param
param
result Result - The Result object

        try{
            int counter = getCountNodeSet("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config/transport-config");
            if (counter>0){
                //integrity
                String integrity = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/transport-config/integrity");
                if (integrity!=null){
                    testMsgs(integrity,result,"transport-config","integrity", compName);
                }

                //confidentiality
                String confdn = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/transport-config/confidentiality");
                if (confdn!=null){
                    testMsgs(confdn,result,"transport-config","confidentiality", compName);
                }

                //establish-trust-in-target
                String trustTarget = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/transport-config/establish-trust-in-target");
                if (trustTarget!=null){
                    testMsgs1(trustTarget,result,"transport-config","extablish-trust-in-target", compName);
                }

                //establish-trust-in-client
                String trustClient = getXPathValue("sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/ior-security-config[\""+i+"\"]/transport-config/establish-trust-in-client");
                if (trustClient!=null){
                    testMsgs(trustClient,result,"transport-config","establish-trust-in-client", compName);
                }
            }else{
                addNaDetails(result, compName);
                result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
                    "NOT APPLICABLE [AS-EJB ior-security-config] : transport-config Element not defined"));
            }
        }catch(Exception ex){
            oneFailed = true;
            addErrorDetails(result, compName);
            result.addErrorDetails(smh.getLocalString
                (getClass().getName() + ".notRun",
                "NOT RUN [AS-EJB] : Could not create a descriptor object"));
        }