KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > api > CommonMethodDesc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: CommonMethodDesc.java,v 1.2 2004/09/17 09:44:19 joaninh Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ejb.deployment.api;
27
28 import java.security.PermissionCollection JavaDoc;
29 import java.security.Permissions JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import javax.security.jacc.EJBMethodPermission JavaDoc;
33
34 import org.objectweb.jonas_ejb.deployment.xml.Method;
35 import org.objectweb.jonas_ejb.deployment.xml.MethodParams;
36
37 /**
38  * Defines a ExcludeListDesc class for the management of
39  * EJBMEthodPermissions in JACC
40  * @author Florent Benoit : Initial developer
41  */

42 public class CommonMethodDesc {
43
44     /**
45      * List of EJBMethodPermission
46      */

47     private PermissionCollection JavaDoc ejbMethodPermissions = null;
48
49
50     /**
51      * Constructor for CommonMethodDesc
52      * @param list given methods
53      */

54     public CommonMethodDesc(List JavaDoc list) {
55         this.ejbMethodPermissions = new Permissions JavaDoc();
56         generateEJBMethodPermissions(list);
57     }
58
59
60     /**
61      * Build all ejbMethodPermissions for the given methods
62      * @param methodList given methods
63      */

64     protected void generateEJBMethodPermissions(List JavaDoc methodList) {
65         Iterator JavaDoc it = methodList.iterator();
66
67         // Manage permissions
68
while (it.hasNext()) {
69             Method method = (Method) it.next();
70             MethodParams methodParams = method.getMethodParams();
71             String JavaDoc[] methodParamsArray = null;
72             if (methodParams != null) {
73
74                 List JavaDoc methodParamsList = method.getMethodParams().getMethodParamList();
75                 String JavaDoc[] methodParamSize = new String JavaDoc[methodParamsList.size()];
76                 methodParamsArray = (String JavaDoc[]) methodParamsList.toArray(methodParamSize);
77             }
78
79             // * or null value means that permission pertains to all methods
80
String JavaDoc methodName = method.getMethodName();
81             if (methodName.equals("*")) {
82                 methodName = null;
83             }
84
85
86             EJBMethodPermission JavaDoc ejbMethodPermission =
87                 new EJBMethodPermission JavaDoc(method.getEjbName(),
88                                         methodName,
89                                         method.getMethodIntf(),
90                                         methodParamsArray);
91             // Add the permission
92
ejbMethodPermissions.add(ejbMethodPermission);
93         }
94     }
95
96     /**
97      * Gets EJBMethod permissions
98      * @return the EJBMethodPermissions
99      */

100     public PermissionCollection JavaDoc getEJBMethodPermissions() {
101         return ejbMethodPermissions;
102     }
103 }
104
Popular Tags