FileDocCategorySizeDatePackage
ASEjbIORSecurityConfig.javaAPI DocGlassfish v2 API11288Fri May 04 22:35:12 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.ias

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 = new ComponentNameConstructor(descriptor);

        SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
        
        if(ejbJar!=null)
        {
            Ejb ejbs[] = ejbJar.getEnterpriseBeans().getEjb();
            Ejb testCase = null;
            for(int i=0;i<ejbs.length;i++)
            {
                if(ejbs[i].getEjbName().equals(descriptor.getName()))
                {
                    testCase = ejbs[i];
                    break;
                }
            }
            
            IorSecurityConfig iorSec = testCase.getIorSecurityConfig();
            if(iorSec == null)
            {
                result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                    "NOT APPLICABLE [AS-EJB ior-security-config] : ior-security-config Element not defined"));
            }
            else
            {
                TransportConfig tranConfig = iorSec.getTransportConfig();
                if(tranConfig != null)
                    testTranConfig(tranConfig,result);
                else
                {
                    result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                        "NOT APPLICABLE [AS-EJB ior-security-config] : transport-config Element not defined"));
                }
                
                AsContext asContext = iorSec.getAsContext();
                if(asContext != null)
                    testAsContext(asContext,result);
                else
                {
                    result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                        "NOT APPLICABLE [AS-EJB ior-security-config] : as-context Element not defined"));
                }
                
                SasContext sasContext = iorSec.getSasContext();
                if(sasContext != null)
                    testSasContext(sasContext,result);
                else
                {
                    result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                        "NOT APPLICABLE [AS-EJB ior-security-config] : sas-context Element not defined"));
                }
                
            }
            if(oneFailed)
                result.setStatus(Result.FAILED);
        }
        else
        {
            result.addErrorDetails(smh.getLocalString
                 (getClass().getName() + ".notRun",
                  "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
        }
        return result;
    
protected voidtestAsContext(com.sun.enterprise.tools.common.dd.ejb.AsContext aContext, Result result)
The function tests the tag in for valid values

param
aContext AsContext object representing the tag
param
result Result object

        //auth-method
        String value = aContext.getAuthMethod();
        if(value.length()==0)
        {
            oneFailed = true;
            result.failed(smh.getLocalString(getClass().getName()+".failedAsContextAuthMethod",
                "FAILED [AS-EJB as-context] : auth-method cannotb be an empty string"));
        }
        else
        {
            if(value.equals("USERNAME_PASSWORD"))
            {
                result.passed(smh.getLocalString(getClass().getName()+".passedAsContextAuthMethod",
                    "PASSED [AS-EJB as-context] : auth-method is {0}", new Object[] {value}));
            }
            else
            {
                oneFailed = true;
                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 = aContext.getRealm();
        if(value.length()==0)
        {
            oneFailed = true;
            result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRealm",
                "FAILED [AS-EJB as-context] : realm cannot be an empty string"));
        }
        else
        {
            result.passed(smh.getLocalString(getClass().getName()+".passedAsContextRealm",
                "PASSED [AS-EJB as-context] : realm is {0}", new Object[] {value}));
        }
        
        //required
        value = aContext.getRequired();
        if(value.length()==0)
        {
            oneFailed = true;
            result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRequired",
                "FAILED [AS-EJB as-context] : required cannot be an empty string"));
        }
        else
        {
            if(value.equals("true") || value.equals("false"))
            {
                result.passed(smh.getLocalString(getClass().getName()+".passedAsContextRequired",
                    "PASSED [AS-EJB as-context] : required is {0}", new Object[] {value}));
            }
            else
            {
                oneFailed = true;
                result.failed(smh.getLocalString(getClass().getName()+".failedAsContextRequired1",
                    "FAILED [AS-EJB as-context] : required cannot be {0}. It can only be true or false"
                    ,new Object[]{value}));
            }
        }
        
    
private voidtestMsgs(java.lang.String tCase, Result result, java.lang.String parentElement, java.lang.String testElement)

        if(tCase.length()==0)
        {
            oneFailed = true;
            result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg",
                "FAILED [AS-EJB " + parentElement + "] : " + testElement + " cannot be an empty String"));
        }
        else
        {
            if(!tCase.equals("NONE") && !tCase.equals("SUPPORTED") 
                && !tCase.equals("REQUIRED"))
            {
                oneFailed = true;
                result.failed(smh.getLocalString(getClass().getName()+".failedTestMsg",
                    "FAILED [AS-EJB " + parentElement+"] : "+testElement+" cannot be {0}. It can be either NONE, SUPPORTED or REQUIRED",
                    new Object[]{tCase}));
            }
            else
                result.passed(smh.getLocalString(getClass().getName()+".passedTestMsg",
                    "PASSED [AS-EJB "+ parentElement+"] : " + testElement +" is {0}", new Object[]{tCase}));
        }
    
protected voidtestSasContext(com.sun.enterprise.tools.common.dd.ejb.SasContext sContext, Result result)

param
sContext
param
result

        String caller = sContext.getCallerPropagation();
        testMsgs(caller,result,"sas-context","caller-propagation");
    
protected voidtestTranConfig(com.sun.enterprise.tools.common.dd.ejb.TransportConfig tConfig, Result result)
This function tests the tag for valid values

param
tConfig TransportConfig - The object representing the tag
param
result Result - The Result object

        //integrity
        String integrity = tConfig.getIntegrity();
        testMsgs(integrity,result,"transport-config","integrity");
        
        //confidentiality
        String confdn = tConfig.getConfidentiality();
        testMsgs(confdn,result,"transport-config","confidentiality");
        
        //establish-trust-in-target
        String trustTarget = tConfig.getEstablishTrustInTarget();
        testMsgs(trustTarget,result,"transport-config","extablish-trust-in-target");
        
        //establish-trust-in-client
        String trustClient = tConfig.getEstablishTrustInClient();
        testMsgs(trustClient,result,"transport-config","establish-trust-in-client");