Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2009-02-20 16:26:32 -0500
committerThomas Watson2009-02-20 16:26:32 -0500
commit15f5c5812673f1be4825a8e08db3743ed491d9c3 (patch)
tree29e67eb9635ac5f61bc6d11bb91564c1efec6914 /bundles/org.eclipse.osgi/resolver
parent622d0da7d1f82dcd8adc93aa97f071ed5b1e873a (diff)
downloadrt.equinox.framework-15f5c5812673f1be4825a8e08db3743ed491d9c3.tar.gz
rt.equinox.framework-15f5c5812673f1be4825a8e08db3743ed491d9c3.tar.xz
rt.equinox.framework-15f5c5812673f1be4825a8e08db3743ed491d9c3.zip
Bug 262921 PackageAdmin getExportedPackage[s] methods return package even if exporter does not have EXPORT permission
Diffstat (limited to 'bundles/org.eclipse.osgi/resolver')
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/PermissionChecker.java10
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java5
2 files changed, 12 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/PermissionChecker.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/PermissionChecker.java
index 3d7844f07..7fc6632de 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/PermissionChecker.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/PermissionChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,6 +32,7 @@ public class PermissionChecker {
public boolean checkPermission(VersionConstraint vc, BaseDescription bd) {
if (!checkPermissions)
return true;
+ // TODO could optimize out the producer permission check on export package
boolean success = false;
Permission producerPermission = null, consumerPermission = null;
Bundle producer = null, consumer = null;
@@ -72,4 +73,11 @@ public class PermissionChecker {
return success;
}
+
+ boolean checkPackagePermission(ExportPackageDescription export) {
+ if (!checkPermissions)
+ return true;
+ Bundle bundle = context.getBundle(export.getExporter().getBundleId());
+ return bundle == null ? false : bundle.hasPermission(new PackagePermission(export.getName(), PackagePermission.EXPORT));
+ }
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index a0b5bba10..8fdd0ddfd 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -53,7 +53,7 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
// The State associated with this resolver
private State state;
// Used to check permissions for import/export, provide/require, host/fragment
- private PermissionChecker permissionChecker;
+ private final PermissionChecker permissionChecker;
// Set of bundles that are pending removal
private MappedList removalPending = new MappedList();
// Indicates whether this resolver has been initialized
@@ -1456,7 +1456,8 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
ResolverExport[] exports = rb.getSelectedExports();
ArrayList selectedExports = new ArrayList(exports.length);
for (int i = 0; i < exports.length; i++) {
- selectedExports.add(exports[i].getExportPackageDescription());
+ if (permissionChecker.checkPackagePermission(exports[i].getExportPackageDescription()))
+ selectedExports.add(exports[i].getExportPackageDescription());
}
ExportPackageDescription[] selectedExportsArray = (ExportPackageDescription[]) selectedExports.toArray(new ExportPackageDescription[selectedExports.size()]);

Back to the top