01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.satsa.acl;
28:
29: /**
30: * This class represents a set of JCRMI permissions.
31: */
32: public class JCRMIPermissions extends ACLPermissions {
33:
34: /**
35: * Constructs new object.
36: * @param parent parent ACFile object.
37: */
38: public JCRMIPermissions(ACSlot parent) {
39: super (parent);
40: }
41:
42: /**
43: * Verifies that the MIDlet have permission for this remote method.
44: * @param className the name of class.
45: * @param method method name and signature.
46: * @throws SecurityException if access denied
47: */
48: public void checkPermission(String className, String method) {
49:
50: if (type == ALLOW) {
51: return;
52: }
53: if (type == DISALLOW) {
54: throw new SecurityException("Access denied");
55: }
56:
57: for (int i = 0; i < permissions.size(); i++) {
58:
59: JCRMIPermission p = (JCRMIPermission) permissions
60: .elementAt(i);
61: if (p.checkAccess(className, method)) {
62: return;
63: }
64: }
65: throw new SecurityException("Access denied: " + className + " "
66: + method);
67: }
68:
69: /**
70: * Initializes internal variables, verifies that operation is
71: * supported and permitted, returns method name and signature for
72: * given PIN operation.
73: * @param pinID PIN identifier.
74: * @param unblockID unblocking PIN identifier.
75: * @param action PIN operation.
76: * @param className the name of class.
77: * @return method name and signature.
78: * @throws java.lang.SecurityException if access denied
79: */
80: public String preparePIN(int pinID, int unblockID, int action,
81: String className) {
82:
83: checkPINOperation(pinID, unblockID, action);
84: String result = (String) getPINCommand(pinID, action);
85: if (result == null) {
86: throw new SecurityException();
87: }
88: checkPermission(className, result);
89: return result;
90: }
91: }
|