KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > permissionadmin > PermissionAdmin


1 /*
2  * $Header: /cvshome/build/org.osgi.service.permissionadmin/src/org/osgi/service/permissionadmin/PermissionAdmin.java,v 1.12 2006/06/16 16:31:44 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2001, 2006). All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.osgi.service.permissionadmin;
20
21 /**
22  * The Permission Admin service allows management agents to manage the
23  * permissions of bundles. There is at most one Permission Admin service present
24  * in the OSGi environment.
25  * <p>
26  * Access to the Permission Admin service is protected by corresponding
27  * <code>ServicePermission</code>. In addition <code>AdminPermission</code> is
28  * required to actually set permissions.
29  *
30  * <p>
31  * Bundle permissions are managed using a permission table. A bundle's location
32  * serves as the key into this permission table. The value of a table entry is
33  * the set of permissions (of type <code>PermissionInfo</code>) granted to the
34  * bundle named by the given location. A bundle may have an entry in the
35  * permission table prior to being installed in the Framework.
36  *
37  * <p>
38  * The permissions specified in <code>setDefaultPermissions</code> are used as the
39  * default permissions which are granted to all bundles that do not have an
40  * entry in the permission table.
41  *
42  * <p>
43  * Any changes to a bundle's permissions in the permission table will take
44  * effect no later than when bundle's <code>java.security.ProtectionDomain</code>
45  * is next involved in a permission check, and will be made persistent.
46  *
47  * <p>
48  * Only permission classes on the system classpath or from an exported package
49  * are considered during a permission check. Additionally, only permission
50  * classes that are subclasses of <code>java.security.Permission</code> and define
51  * a 2-argument constructor that takes a <i>name </i> string and an <i>actions
52  * </i> string can be used.
53  * <p>
54  * Permissions implicitly granted by the Framework (for example, a bundle's
55  * permission to access its persistent storage area) cannot be changed, and are
56  * not reflected in the permissions returned by <code>getPermissions</code> and
57  * <code>getDefaultPermissions</code>.
58  *
59  * @version $Revision: 1.12 $
60  */

61 public interface PermissionAdmin {
62     /**
63      * Gets the permissions assigned to the bundle with the specified location.
64      *
65      * @param location The location of the bundle whose permissions are to be
66      * returned.
67      *
68      * @return The permissions assigned to the bundle with the specified
69      * location, or <code>null</code> if that bundle has not been assigned
70      * any permissions.
71      */

72     PermissionInfo[] getPermissions(String JavaDoc location);
73
74     /**
75      * Assigns the specified permissions to the bundle with the specified
76      * location.
77      *
78      * @param location The location of the bundle that will be assigned the
79      * permissions.
80      * @param permissions The permissions to be assigned, or <code>null</code> if
81      * the specified location is to be removed from the permission table.
82      * @throws SecurityException If the caller does not have
83      * <code>AllPermission</code>.
84      */

85     void setPermissions(String JavaDoc location, PermissionInfo[] permissions);
86
87     /**
88      * Returns the bundle locations that have permissions assigned to them, that
89      * is, bundle locations for which an entry exists in the permission table.
90      *
91      * @return The locations of bundles that have been assigned any permissions,
92      * or <code>null</code> if the permission table is empty.
93      */

94     String JavaDoc[] getLocations();
95
96     /**
97      * Gets the default permissions.
98      *
99      * <p>
100      * These are the permissions granted to any bundle that does not have
101      * permissions assigned to its location.
102      *
103      * @return The default permissions, or <code>null</code> if no default
104      * permissions are set.
105      */

106     PermissionInfo[] getDefaultPermissions();
107
108     /**
109      * Sets the default permissions.
110      *
111      * <p>
112      * These are the permissions granted to any bundle that does not have
113      * permissions assigned to its location.
114      *
115      * @param permissions The default permissions, or <code>null</code> if the
116      * default permissions are to be removed from the permission table.
117      * @throws SecurityException If the caller does not have
118      * <code>AllPermission</code>.
119      */

120     void setDefaultPermissions(PermissionInfo[] permissions);
121 }
122
Popular Tags