KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > runtime > ASEjbPrincipal


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

25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
32
33 import com.sun.enterprise.deployment.RunAsIdentityDescriptor;
34
35 /** ejb [0,n]
36  * principal ?
37  * name [String]
38  *
39  * The principal tag defines a username on the platform
40  * @author Irfan Ahmed
41  */

42 public class ASEjbPrincipal extends EjbTest implements EjbCheck {
43
44
45     public Result check(EjbDescriptor descriptor)
46     {
47     Result result = getInitializedResult();
48         
49     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
50         
51         boolean oneFailed = false;
52         try{
53             if (descriptor.getUsesCallerIdentity() == false){
54                 RunAsIdentityDescriptor runAsIdDesc = descriptor.getRunAsIdentity();
55                 if (runAsIdDesc != null){
56                     String JavaDoc principal = runAsIdDesc.getPrincipal();
57                     if (principal == null){
58                         addNaDetails(result, compName);
59                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
60                         "NOT APPLICABLE [AS-EJB ejb] : principal element not defined"));
61                     }else{
62                         if(principal.length()==0){
63                             addErrorDetails(result, compName);
64                             result.failed(smh.getLocalString(getClass().getName()+".failed",
65                             "FAILED [AS-EJB principal] : name cannot be an empty String"));
66                         }else{
67                             addGoodDetails(result, compName);
68                             result.passed(smh.getLocalString(getClass().getName()+".passed",
69                             "PASSED [AS-EJB principal] : name is {0}", new Object JavaDoc[]{principal}));
70                         }
71                     }
72                 }
73             }else{
74                 addNaDetails(result, compName);
75                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
76                     "NOT APPLICABLE [AS-EJB ejb] run-as Element is not defined"));
77             }
78         }catch(Exception JavaDoc ex){
79             addErrorDetails(result, compName);
80             result.addErrorDetails(smh.getLocalString
81                  (getClass().getName() + ".notRun",
82                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
83         }
84
85         return result;
86     }
87 }
88
Popular Tags