FileDocCategorySizeDatePackage
ASConnectorPrincipal.javaAPI DocGlassfish v2 API4486Fri May 04 22:35:12 BST 2007com.sun.enterprise.tools.verifier.tests.connector.ias

ASConnectorPrincipal

public class ASConnectorPrincipal extends ConnectorTest implements ConnectorCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(com.sun.enterprise.deployment.ConnectorDescriptor descriptor)

     Result result = getInitializedResult();
     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);   
	 boolean oneFailed = false;
	 boolean oneWarning = false;
     SunConnector sc = descriptor.getSunDescriptor();
     if(sc == null)
     {
	      result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
		    "NOTAPPLICABLE [AS­CONNECTOR]: sun-ra.xml descriptor object could not be obtained"));
     }
     else{
     RoleMap rm = sc.getRoleMap();
	 if(rm == null){
	     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2","NOTAPPLICABLE [AS-CONNECTOR]: rolemap element not defined"));
		 return result;
	 }
     MapElement[] marr = rm.getMapElement();
	 int size = marr.length;
	 if(size == 0)
	 {
	     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable3","NOTAPPLICABLE [AS-CONNECTOR rolemap]: map-elements not defined"));
		 return result;
	 }
	 Hashtable ht = new Hashtable();
	 for(int i=0; i < size ;i++)
	 {
	     String username = marr[i].getAttributeValue("backend-principal","user-name");
         Principal[] p = marr[i].getPrincipal();
		 for(int j=0; j< p.length ; j++)
		 {
		    String puser = p[j].getAttributeValue("user-name");
			String mappeduser = (String)ht.get(puser);
		    if(mappeduser == null)
		        ht.put(puser,username); 
			else
			{
			    if(!(mappeduser.equals(username)))
				{
				    oneWarning = true;
				    result.warning(smh.getLocalString(getClass().getName()+".warning","WARNING [AS-CONNECTOR rolemap map-element]: principal with username {0} is mapped to multiple backend principals {1} , {2}",new Object[] { puser,mappeduser,username}));
				}
			}
		 }

	 }
     if(oneWarning)
	     result.setStatus(Result.WARNING);
	 else
	 {
	     result.setStatus(Result.PASSED);
	     result.passed(smh.getLocalString(getClass().getName()+".passed","PASSED [AS-CONNECTOR rolemap map-element]: All principals are uniquely mapped to backend-principals"));
	 }
     }
     return result;