KickJava   Java API By Example, From Geeks To Geeks.

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


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  * AuthMechType.java
25  *
26  * Created on October 3, 2000, 9:17 AM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector;
30
31 import java.util.*;
32 import com.sun.enterprise.tools.verifier.Result;
33 import com.sun.enterprise.deployment.ConnectorDescriptor;
34 import com.sun.enterprise.tools.verifier.tests.*;
35 import com.sun.enterprise.deployment.AuthMechanism;
36 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
37
38 /**
39  * All Authorization Mechanism type should be of an allowed type
40  * @author Jerome Dochez
41  * @version
42  */

43 public class AuthMechType extends ConnectorTest implements ConnectorCheck {
44
45
46     private static String JavaDoc[] allowedMechs = {
47         ConnectorTagNames.DD_BASIC_PASSWORD,
48         ConnectorTagNames.DD_KERBEROS };
49
50     /** <p>
51      * All Authorization Mechanism type should be of an allowed type
52      * </p>
53      *
54      * @paramm descriptor deployment descriptor for the rar file
55      * @return result object containing the result of the individual test
56      * performed
57      */

58     public Result check(ConnectorDescriptor descriptor) {
59         boolean oneFailed = false;
60         Result result = getInitializedResult();
61     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
62         if(!descriptor.getOutBoundDefined())
63         {
64           result.addNaDetails(smh.getLocalString
65               ("tests.componentNameConstructor",
66                "For [ {0} ]",
67                new Object JavaDoc[] {compName.toString()}));
68           result.notApplicable(smh.getLocalString
69               ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
70                "Resource Adapter does not provide outbound communication"));
71           return result;
72         }
73         Set mechanisms =
74         descriptor.getOutboundResourceAdapter().getAuthMechanisms();
75         if (mechanisms.isEmpty()) {
76             // passed
77
result.addGoodDetails(smh.getLocalString
78                   ("tests.componentNameConstructor",
79                    "For [ {0} ]",
80                    new Object JavaDoc[] {compName.toString()}));
81         result.passed(smh.getLocalString
82                 ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.nonexist",
83                  "No authentication mechanism defined for this resource adapater"));
84             return result;
85         }
86         Iterator mechIterator = mechanisms.iterator();
87         while (mechIterator.hasNext()) {
88             AuthMechanism am = (AuthMechanism) mechIterator.next();
89             String JavaDoc authMechType = am.getAuthMechType();
90             boolean allowedMech = false;
91             if (authMechType!=null) {
92                 for (int i=0;i<allowedMechs.length;i++) {
93                     if (authMechType.equals(allowedMechs[i])) {
94                         allowedMech = true;
95                         break;
96                     }
97                 }
98             }
99             if (!allowedMech || authMechType == null) {
100                 // failed
101
oneFailed = true;
102             result.addErrorDetails(smh.getLocalString
103                        ("tests.componentNameConstructor",
104                     "For [ {0} ]",
105                     new Object JavaDoc[] {compName.toString()}));
106         result.failed(smh.getLocalString
107                     ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.failed",
108                     "Authentication mechanism type [ {0} ] is not allowed"));
109             }
110         }
111         if (!oneFailed) {
112         result.addGoodDetails(smh.getLocalString
113                        ("tests.componentNameConstructor",
114                     "For [ {0} ]",
115                     new Object JavaDoc[] {compName.toString()}));
116         result.passed(smh.getLocalString
117                 ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.passed",
118                  "All defined authentication mechanism types are allowed"));
119         }
120         return result;
121     }
122 }
123
Popular Tags