KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CredentialInterface.java
25  *
26  * Created on October 3, 2000, 2:42 PM
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
37 /**
38  * All Credential interface declared in the DD should be one of the
39  * allowed interface
40  *
41  * @author Jerome Dochez
42  * @version
43  */

44 public class CredentialInterface extends ConnectorTest implements ConnectorCheck {
45
46
47     private static String JavaDoc[] allowedInterfaces = new String JavaDoc[] {
48                               "javax.resource.spi.security.PasswordCredential",
49                               "org.ietf.jgss.GSSCredential",
50                               "javax.resource.spi.security.GenericCredential" };
51
52     /** <p>
53      * All Credential interface declared in the DD should be one of the
54      * allowed interface
55      * </p>
56      *
57      * @paramm descriptor deployment descriptor for the rar file
58      * @return result object containing the result of the individual test
59      * performed
60      */

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