FileDocCategorySizeDatePackage
AppSecurityRole.javaAPI DocGlassfish v2 API4130Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.app

AppSecurityRole

public class AppSecurityRole extends com.sun.enterprise.tools.verifier.tests.app.ApplicationTest implements AppCheck
The Application role-name element contains the name of a security role.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(Application descriptor)
The Application role-name element contains the name of a security role.

param
descriptor the Application deployment descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();


	if (!descriptor.getRoles().isEmpty()) {
	    boolean oneFailed = false;
	    boolean foundIt = false;
	    // get the security role name's in this app
	    Set sc = descriptor.getRoles();
	    Iterator itr = sc.iterator();
	    while (itr.hasNext()) {
		foundIt = false;
		Role role = (Role) itr.next();
		String roleName = role.getName(); 
		if (roleName.length() > 0) {
		    foundIt = true;
		} else {
		    foundIt = false;
		}

      
		if (foundIt) {
		    result.addGoodDetails(smh.getLocalString
					  (getClass().getName() + ".passed",
					   "The security role name [ {0} ] found within application [ {1} ]",
					   new Object[] {roleName, descriptor.getName()}));
		} else {
		    if (!oneFailed) {
			oneFailed = true;
		    }
		    result.addErrorDetails(smh.getLocalString
					   (getClass().getName() + ".failed",
					    "Error: The security role name [ {0} ] not found within application [ {1} ]",
					    new Object[] {roleName, descriptor.getName()}));
		}
	    }
	    if (oneFailed) {
		result.setStatus(Result.FAILED);
	    } else {
		result.setStatus(Result.PASSED);
	    }
	} else {
	    result.notApplicable(smh.getLocalString
				 (getClass().getName() + ".notApplicable",
				  "There are no role-name elements within the application [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}

	return result;