KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > ias > ASConnectorPrincipal


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

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 JavaDoc;
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 [AS­CONNECTOR]: 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 JavaDoc ht = new Hashtable JavaDoc();
61      for(int i=0; i < size ;i++)
62      {
63          String JavaDoc 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 JavaDoc puser = p[j].getAttributeValue("user-name");
68             String JavaDoc mappeduser = (String JavaDoc)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 JavaDoc[] { 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