01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999-2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 5450 2004-09-17 09:44:19Z joaninh $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ejb.deployment.api;
25:
26: import java.security.PermissionCollection;
27: import java.security.Permissions;
28: import java.util.List;
29: import java.util.Iterator;
30: import javax.security.jacc.EJBMethodPermission;
31:
32: import org.objectweb.jonas_ejb.deployment.xml.Method;
33: import org.objectweb.jonas_ejb.deployment.xml.MethodParams;
34:
35: /**
36: * Defines a ExcludeListDesc class for the management of
37: * EJBMEthodPermissions in JACC
38: * @author Florent Benoit : Initial developer
39: */
40: public class CommonMethodDesc {
41:
42: /**
43: * List of EJBMethodPermission
44: */
45: private PermissionCollection ejbMethodPermissions = null;
46:
47: /**
48: * Constructor for CommonMethodDesc
49: * @param list given methods
50: */
51: public CommonMethodDesc(List list) {
52: this .ejbMethodPermissions = new Permissions();
53: generateEJBMethodPermissions(list);
54: }
55:
56: /**
57: * Build all ejbMethodPermissions for the given methods
58: * @param methodList given methods
59: */
60: protected void generateEJBMethodPermissions(List methodList) {
61: Iterator it = methodList.iterator();
62:
63: // Manage permissions
64: while (it.hasNext()) {
65: Method method = (Method) it.next();
66: MethodParams methodParams = method.getMethodParams();
67: String[] methodParamsArray = null;
68: if (methodParams != null) {
69:
70: List methodParamsList = method.getMethodParams()
71: .getMethodParamList();
72: String[] methodParamSize = new String[methodParamsList
73: .size()];
74: methodParamsArray = (String[]) methodParamsList
75: .toArray(methodParamSize);
76: }
77:
78: // * or null value means that permission pertains to all methods
79: String methodName = method.getMethodName();
80: if (methodName.equals("*")) {
81: methodName = null;
82: }
83:
84: EJBMethodPermission ejbMethodPermission = new EJBMethodPermission(
85: method.getEjbName(), methodName, method
86: .getMethodIntf(), methodParamsArray);
87: // Add the permission
88: ejbMethodPermissions.add(ejbMethodPermission);
89: }
90: }
91:
92: /**
93: * Gets EJBMethod permissions
94: * @return the EJBMethodPermissions
95: */
96: public PermissionCollection getEJBMethodPermissions() {
97: return ejbMethodPermissions;
98: }
99: }
|