01: /*
02: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License version
07: * 2 only, as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful, but
10: * WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * General Public License version 2 for more details (a copy is
13: * included at /legal/license.txt).
14: *
15: * You should have received a copy of the GNU General Public License
16: * version 2 along with this work; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18: * 02110-1301 USA
19: *
20: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21: * Clara, CA 95054 or visit www.sun.com if you need additional
22: * information or have any questions.
23: */
24:
25: package com.sun.j2me.app;
26:
27: import com.sun.j2me.security.Permission;
28:
29: /**
30: * Abstraction for application package
31: */
32: public class AppPackage {
33:
34: /** Static instance. Only one package can be run in a isolate */
35: private static AppPackage instance = new AppPackage();
36:
37: /** Guard from 'new' operator */
38: private AppPackage() {
39: }
40:
41: public static AppPackage getInstance() {
42: return instance;
43: }
44:
45: public int getId() {
46: return 0;
47: }
48:
49: /** Unused ID */
50: public static final int UNUSED_APP_ID = -1;
51:
52: /**
53: * Returns permission status for the specified permission
54: *
55: * @param p permission to check
56: * @return 1 if allowed; 0 if denied; -1 if status is unknown
57: */
58: public int checkPermission(Permission p) {
59: /* Stub: always allowed */
60: return 1;
61: }
62:
63: /**
64: * Checks for specified permission status. Throws an exception
65: * if permission is not allowed. May be blocked to ask user
66: *
67: * @param p a permission to check
68: * @exception SecurityException if permission is not allowed
69: * @exception InterruptedException if another thread interrupts a calling
70: * thread while asking user
71: */
72: public void checkForPermission(Permission p)
73: throws InterruptedException {
74: }
75:
76: /**
77: * Throws an exception if a status for the permission is not allowed
78: *
79: * @param p a permission to check
80: * @exception SecurityException if a status for the permission is not allowed
81: */
82: public void checkIfPermissionAllowed(Permission p) {
83: if (checkPermission(p) != 1) {
84: throw new SecurityException();
85: }
86: }
87:
88: /**
89: * Gets the name of CA that authorized this suite.
90: *
91: * @return name of a CA or null if the suite was not signed
92: */
93: public String getCA() {
94: return null;
95: }
96: }
|