FileDocCategorySizeDatePackage
SecurityIdentityRefs.javaAPI DocGlassfish v2 API5475Fri May 04 22:33:32 BST 2007com.sun.enterprise.tools.verifier.tests.ejb

SecurityIdentityRefs

public class SecurityIdentityRefs extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest
Security role references test. The Bean provider must declare all of the enterprise's bean references to security roles as specified in section 15.2.1.3 of the Moscone spec. Role names must be mapped to names within the jar.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(EjbDescriptor descriptor)
Security role references test. The Bean provider must declare all of the enterprise's bean references to security roles as specified in section 15.2.1.3 of the Moscone spec. Role names must be mapped to names within the jar.

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion


    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor.getUsesCallerIdentity()){
        result.addNaDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.notApplicable(smh.getLocalString(
              "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.notApplicable3",
              "Bean [ {0} ] does not specify a run-as identity",
              new Object[] {descriptor.getName()}));
        return result;
    }
    RunAsIdentityDescriptor identity = descriptor.getRunAsIdentity();
    if (identity == null) {
      result.addNaDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.notApplicable(smh.getLocalString(
            "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.notApplicable2",
            "Bean [ {0} ] does not specify a security identity",
            new Object[] {descriptor.getName()}));                    
      return result;
    }

    EjbBundleDescriptor bundleDescriptor = descriptor.getEjbBundleDescriptor();
    Set roles = bundleDescriptor.getRoles();
    Iterator roleIterator = roles.iterator();
    while (roleIterator.hasNext()) {
      Role role = (Role) roleIterator.next();
      if (role.getName().equals(identity.getRoleName())) {
        result.addGoodDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.passed(smh.getLocalString(
              "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.passed",
              "Security identity run-as specified identity [ {0} ] role is found in the list of roles",
              new Object[] {role.getName()}));        
        return result;                
      }
    }
    result.addErrorDetails(smh.getLocalString
        ("tests.componentNameConstructor",
         "For [ {0} ]",
         new Object[] {compName.toString()}));
    result.failed(smh.getLocalString(
          "com.sun.enterprise.tools.verifier.tests.ejb.SecurityIdentityRefs.failed",
          "Security identity run-as specified identity [ {0} ] role is not valid",
          new Object[] {identity.getRoleName()}));        
    return result;