KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > appclient > AppClientCallbackHandler


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 package com.sun.enterprise.tools.verifier.tests.appclient;
24
25 import com.sun.enterprise.deployment.*;
26 import com.sun.enterprise.tools.verifier.*;
27 import com.sun.enterprise.tools.verifier.tests.*;
28 import java.lang.ClassLoader JavaDoc;
29 import com.sun.enterprise.tools.verifier.tests.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 /**
34  * AppClient callback handler test.
35  * The AppClient provider may provide a JAAS callback handler.
36  */

37 public class AppClientCallbackHandler extends AppClientTest implements AppClientCheck {
38
39       
40
41     /**
42      * AppClient name test.
43      * The AppClient provider must assign a display-name to each AppClient module
44      *
45      *
46      * @param descriptor the app-client deployment descriptor
47      *
48      * @return <code>Result</code> the results for this assertion
49      */

50     public Result check(ApplicationClientDescriptor descriptor) {
51     Result result = getInitializedResult();
52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53     String JavaDoc callbackHandler = descriptor.getCallbackHandler();
54
55     if(callbackHandler == null) {
56         result.addGoodDetails(smh.getLocalString
57                       ("tests.componentNameConstructor",
58                        "For [ {0} ]",
59                        new Object JavaDoc[] {compName.toString()}));
60         result.passed(smh.getLocalString(getClass().getName() + ".passed",
61                          "AppClient callback handler is not specified"));
62     }
63     else if (callbackHandler.length() > 0)
64     {
65         try {
66             Context context = getVerifierContext();
67         ClassLoader JavaDoc jcl = context.getClassLoader();
68             Class JavaDoc c = Class.forName(callbackHandler, false, getVerifierContext().getClassLoader());
69             Object JavaDoc obj = c.newInstance();
70             if( obj instanceof javax.security.auth.callback.CallbackHandler JavaDoc) {
71             result.addGoodDetails(smh.getLocalString
72                       ("tests.componentNameConstructor",
73                        "For [ {0} ]",
74                        new Object JavaDoc[] {compName.toString()}));
75             result.passed(smh.getLocalString(getClass().getName() + ".passed1", "AppClient callback handler is : [ {0} ] and is loadable", new Object JavaDoc [] {callbackHandler}));
76             } else {
77             result.addErrorDetails(smh.getLocalString
78                        ("tests.componentNameConstructor",
79                         "For [ {0} ]",
80                         new Object JavaDoc[] {compName.toString()}));
81             result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: AppClient callback handler is not loadable."));
82             }
83         } catch (Exception JavaDoc e) {
84         result.addErrorDetails(smh.getLocalString
85                        ("tests.componentNameConstructor",
86                     "For [ {0} ]",
87                     new Object JavaDoc[] {compName.toString()}));
88         result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: AppClient callback handler is not loadable."));
89         }
90     } else {
91         // it's blank, test should not pass
92
result.addErrorDetails(smh.getLocalString
93                        ("tests.componentNameConstructor",
94                     "For [ {0} ]",
95                     new Object JavaDoc[] {compName.toString()}));
96         result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: AppClient callback handler must not be blank."));
97     }
98     return result;
99     }
100 }
101
Popular Tags