PermissionOps.java

00001 /*
00002  * Copyright (c) 2006, KNOPFLERFISH project
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following
00007  * conditions are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  *
00012  * - Redistributions in binary form must reproduce the above
00013  *   copyright notice, this list of conditions and the following
00014  *   disclaimer in the documentation and/or other materials
00015  *   provided with the distribution.
00016  *
00017  * - Neither the name of the KNOPFLERFISH project nor the names of its
00018  *   contributors may be used to endorse or promote products derived
00019  *   from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00030  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00032  * OF THE POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 package org.knopflerfish.framework;
00036 
00037 import java.io.InputStream;
00038 import java.security.ProtectionDomain;
00039 import java.util.*;
00040 
00041 import org.osgi.framework.*;
00042 
00043 
00048 class PermissionOps {
00049 
00050   void registerService() {
00051   }
00052 
00053   boolean checkPermissions() {
00054     return false;
00055   }
00056 
00057   //
00058   // Permission checks
00059   //
00060 
00061   boolean okClassAdminPerm(Bundle b) {
00062     return true;
00063   }
00064 
00065   void checkExecuteAdminPerm(Bundle b) {
00066   }
00067 
00068   void checkExtensionLifecycleAdminPerm(Bundle b) {
00069   }
00070 
00071   void checkExtensionLifecycleAdminPerm(Bundle b, Object checkContext) {
00072   }
00073 
00074   void checkLifecycleAdminPerm(Bundle b) {
00075   }
00076 
00077   void checkLifecycleAdminPerm(Bundle b, Object checkContext) {
00078   }
00079 
00080   void checkListenerAdminPerm(Bundle b) {
00081   }
00082 
00083   void checkMetadataAdminPerm(Bundle b) {
00084   }
00085 
00086   void checkResolveAdminPerm() {
00087   }
00088   
00089   void checkResourceAdminPerm(Bundle b) {
00090   }
00091   
00092   boolean okResourceAdminPerm(Bundle b) {
00093     return true;
00094   }
00095   
00096   void checkStartLevelAdminPerm() {
00097   }
00098 
00099   //
00100   // Bundle permission checks
00101   //
00102 
00103   boolean okFragmentBundlePerm(BundleImpl b) {
00104     return true;
00105   }
00106 
00107   boolean okHostBundlePerm(BundleImpl b) {
00108     return true;
00109   }
00110 
00111   boolean okProvideBundlePerm(BundleImpl b) {
00112     return true;
00113   }
00114 
00115   boolean okRequireBundlePerm(BundleImpl b) {
00116     return true;
00117   }
00118 
00119   //
00120   // Package permission checks
00121   //
00122 
00123   boolean hasImportPackagePermission(BundleImpl b, String pkg) {
00124     return true;
00125   }
00126 
00127 
00134   String missingMandatoryPackagePermissions(BundlePackages bpkgs, List okImports) {
00135     for (Iterator i = bpkgs.getImports(); i.hasNext(); ) {
00136       okImports.add(i.next());
00137     }
00138     return null;
00139   }
00140 
00141   //
00142   // Service permission checks
00143   //  
00144 
00145   void checkRegisterServicePerm(String clazz) {
00146   }
00147 
00148   boolean okGetServicePerm(String clazz) {
00149     return true;
00150   }
00151 
00152   void checkGetServicePerms(String [] classes) {
00153   }
00154 
00155   boolean okGetServicePerms(String [] classes) {
00156     return true;
00157   }
00158 
00159   void filterGetServicePermission(Set srs) {
00160   }
00161 
00162   //
00163   // BundleArchive secure operations
00164   //
00165 
00166   InputStream callGetInputStream(final BundleArchive archive,
00167                                  final String name,
00168                                  final int ix) {
00169     return archive.getInputStream(name, ix);
00170   }
00171 
00172 
00173   Enumeration callFindResourcesPath(final BundleArchive archive,
00174                                     final String path) {
00175     return archive.findResourcesPath(path);
00176   }
00177 
00178   //
00179   // BundleClassLoader secure operations
00180   //
00181 
00182   Object callSearchFor(final BundleClassLoader cl,
00183                        final String name,
00184                        final String pkg,
00185                        final String path,
00186                        final BundleClassLoader.SearchAction action,
00187                        final boolean onlyFirst,
00188                        final BundleClassLoader requestor,
00189                        final HashSet visited) {
00190     return cl.searchFor(name, pkg, path, action, onlyFirst, requestor, visited);
00191   }
00192 
00193   //
00194   // BundleImpl Secure operations
00195   //
00196 
00197   void callStart0(final BundleImpl b) throws BundleException {
00198     b.start0();
00199   }
00200 
00201 
00202   BundleException callStop0(final BundleImpl b, final boolean resetPersistent)  {
00203     return b.stop0(resetPersistent);
00204   }
00205 
00206 
00207   void callUpdate0(final BundleImpl b, final InputStream in, final boolean wasActive)
00208     throws BundleException {
00209     b.update0(in, wasActive);
00210   }
00211 
00212 
00213   void callUninstall0(final BundleImpl b) {
00214     b.uninstall0();
00215   }
00216 
00217 
00218   void callStartOnLaunch(final BundleImpl b, final boolean flag) {
00219     b.startOnLaunch(flag);
00220   }
00221 
00222 
00223   void callSetPersistent(final BundleImpl b, final boolean flag) {
00224     b.setPersistent(flag);
00225   }
00226 
00227 
00228   ClassLoader callGetClassLoader0(final BundleImpl b) {
00229     return b.getClassLoader0();
00230   }
00231 
00232 
00233   HeaderDictionary callGetHeaders0(final BundleImpl b, final String locale) {
00234     return b.getHeaders0(locale);
00235   }
00236 
00237 
00238   Enumeration callFindEntries0(final BundleImpl b, final String path,
00239                                final String filePattern, final boolean recurse) {
00240     return b.findEntries0(path, filePattern, recurse);
00241   }
00242 
00243   //
00244   // Bundles Secure operation
00245   //
00246 
00247   BundleImpl callInstall0(final Bundles bs, final String location, final InputStream in)
00248     throws BundleException {
00249     return bs.install0(location, in, null);
00250   }
00251 
00252   //
00253   // Listeners Secure operations
00254   //
00255 
00256   void callBundleChanged(final BundleListener bl, final BundleEvent evt) {
00257      bl.bundleChanged(evt);
00258   }
00259 
00260   void callFrameworkEvent(final FrameworkListener fl, final FrameworkEvent evt) {
00261      fl.frameworkEvent(evt);
00262   }
00263 
00264   void callServiceChanged(final ServiceListener sl, final ServiceEvent evt) {
00265      sl.serviceChanged(evt);
00266   }
00267 
00268   //
00269   // Main Secure operations
00270   //
00271 
00272   void callMainRestart() {
00273      Main.restart();
00274   }
00275 
00276   void callMainShutdown(final int exitcode) {
00277      Main.shutdown(exitcode);
00278   }
00279 
00280   //
00281   // PackageAdmin secure operations
00282   //
00283 
00284   void callRefreshPackages0(final PackageAdminImpl pa, final Bundle [] bundles) {
00285     pa.refreshPackages0(bundles);
00286   }
00287 
00288   //
00289   // ServiceReferenceImpl secure operations
00290   //
00291 
00292   Object callGetService(final ServiceFactory sf,
00293                         final Bundle b,
00294                         final ServiceRegistration sr) {
00295     return sf.getService(b, sr);
00296   }
00297 
00298   //
00299   // ServiceRegisterationImpl secure operations
00300   //
00301 
00302   void callUnregister0(final ServiceRegistrationImpl sr) {
00303     sr.unregister0();
00304   }
00305 
00306   //
00307   // Permissions package functionality
00308   //
00309 
00310   ProtectionDomain getProtectionDomain(BundleImpl b) {
00311     return null;
00312   }
00313 
00314   //
00315   // Cleaning
00316   //
00317 
00321   void purge(BundleImpl b, ProtectionDomain pc) {
00322   }
00323 
00324 }

Generated on Mon Jan 11 21:19:16 2010 for OpenMobileIS by  doxygen 1.5.4