1 23 24 package com.sun.enterprise.tools.verifier.tests.connector.ias; 25 26 import com.sun.enterprise.deployment.ConnectorDescriptor; 27 import com.sun.enterprise.tools.common.dd.connector.*; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import com.sun.enterprise.tools.verifier.tests.connector.*; 31 import java.util.Hashtable ; 32 33 34 public class ASConnectorPrincipal extends ConnectorTest implements ConnectorCheck { 35 public Result check(ConnectorDescriptor descriptor) 36 { 37 Result result = getInitializedResult(); 38 ComponentNameConstructor compName = new ComponentNameConstructor(descriptor); 39 boolean oneFailed = false; 40 boolean oneWarning = false; 41 SunConnector sc = descriptor.getSunDescriptor(); 42 if(sc == null) 43 { 44 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1", 45 "NOTAPPLICABLE [ASCONNECTOR]: sun-ra.xml descriptor object could not be obtained")); 46 } 47 else{ 48 RoleMap rm = sc.getRoleMap(); 49 if(rm == null){ 50 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2","NOTAPPLICABLE [AS-CONNECTOR]: rolemap element not defined")); 51 return result; 52 } 53 MapElement[] marr = rm.getMapElement(); 54 int size = marr.length; 55 if(size == 0) 56 { 57 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable3","NOTAPPLICABLE [AS-CONNECTOR rolemap]: map-elements not defined")); 58 return result; 59 } 60 Hashtable ht = new Hashtable (); 61 for(int i=0; i < size ;i++) 62 { 63 String username = marr[i].getAttributeValue("backend-principal","user-name"); 64 Principal[] p = marr[i].getPrincipal(); 65 for(int j=0; j< p.length ; j++) 66 { 67 String puser = p[j].getAttributeValue("user-name"); 68 String mappeduser = (String )ht.get(puser); 69 if(mappeduser == null) 70 ht.put(puser,username); 71 else 72 { 73 if(!(mappeduser.equals(username))) 74 { 75 oneWarning = true; 76 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})); 77 } 78 } 79 } 80 81 } 82 if(oneWarning) 83 result.setStatus(Result.WARNING); 84 else 85 { 86 result.setStatus(Result.PASSED); 87 result.passed(smh.getLocalString(getClass().getName()+".passed","PASSED [AS-CONNECTOR rolemap map-element]: All principals are uniquely mapped to backend-principals")); 88 } 89 } 90 return result; 91 } 92 } 93 | Popular Tags |