KickJava   Java API By Example, From Geeks To Geeks.

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


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.ejb;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import java.util.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.security.acl.*;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32 /**
33  * The role-name element must conform to the lexical rules for an NMTOKEN
34  */

35 public class RoleNameNMTOKEN extends EjbTest implements EjbCheck {
36
37
38
39     /**
40      * The role-name element must conform to the lexical rules for an NMTOKEN
41      *
42      * @param descriptor the Enterprise Java Bean deployment descriptor
43      *
44      * @return <code>Result</code> the results for this assertion
45      */

46     public Result check(EjbDescriptor descriptor) {
47
48     Result result = getInitializedResult();
49     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
50
51     if (!descriptor.getPermissionedRoles().isEmpty()) {
52         for (Iterator itr = descriptor.getPermissionedRoles().iterator();
53          itr.hasNext();) {
54
55         Role nextRole = (Role) itr.next();
56         if (NameToken.isNMTOKEN(nextRole.getName())) {
57             result.addGoodDetails(smh.getLocalString
58                       ("tests.componentNameConstructor",
59                        "For [ {0} ]",
60                        new Object JavaDoc[] {compName.toString()}));
61             result.addGoodDetails
62             (smh.getLocalString
63              (getClass().getName() + ".passed",
64               "Role name [ {0} ] conforms to the lexical rules of NMTOKEN within bean [ {1} ]",
65               new Object JavaDoc[] {nextRole.getName(), descriptor.getName()}));
66             if (result.getStatus()!= Result.FAILED)
67             result.setStatus(Result.PASSED);
68         } else {
69             result.addErrorDetails(smh.getLocalString
70                        ("tests.componentNameConstructor",
71                         "For [ {0} ]",
72                         new Object JavaDoc[] {compName.toString()}));
73             result.failed
74             (smh.getLocalString
75              (getClass().getName() + ".failed",
76               "Role name [ {0} ] does not conform to the lexical rules of NMTOKEN within bean [ {1} ]",
77               new Object JavaDoc[] {nextRole.getName(), descriptor.getName()}));
78         }
79         }
80     } else {
81         result.addNaDetails(smh.getLocalString
82                 ("tests.componentNameConstructor",
83                  "For [ {0} ]",
84                  new Object JavaDoc[] {compName.toString()}));
85         result.notApplicable(smh.getLocalString
86                  (getClass().getName() + ".notApplicable",
87                   "No permissioned roles defined for this bean [ {0} ]",
88                   new Object JavaDoc[] {descriptor.getName()}));
89     }
90     return result;
91     }
92 }
93
Popular Tags