private BundleProtectionDomain createProtectionDomain(Bundle bundle, SecurityAdmin sa) { PermissionInfoCollection impliedPermissions = getImpliedPermission(bundle); PermissionInfo[] restrictedInfos = getFileRelativeInfos( SecurityAdmin.getPermissionInfos( bundle.getEntry("OSGI-INF/permissions.perm"), framework), bundle); //$NON-NLS-1$ PermissionInfoCollection restrictedPermissions = restrictedInfos == null ? null : new PermissionInfoCollection(restrictedInfos); BundlePermissions bundlePermissions = new BundlePermissions(bundle, sa, impliedPermissions, restrictedPermissions); return new BundleProtectionDomain(bundlePermissions, null, bundle); }
private PermissionInfoCollection getImpliedPermission(Bundle bundle) { if (impliedPermissionInfos == null) return null; // create the implied AdminPermission actions for this bundle PermissionInfo impliedAdminPermission = new PermissionInfo( AdminPermission.class.getName(), "(id=" + bundle.getBundleId() + ")", ADMIN_IMPLIED_ACTIONS); //$NON-NLS-1$ //$NON-NLS-2$ PermissionInfo[] bundleImpliedInfos = new PermissionInfo[impliedPermissionInfos.length + 1]; System.arraycopy( impliedPermissionInfos, 0, bundleImpliedInfos, 0, impliedPermissionInfos.length); bundleImpliedInfos[impliedPermissionInfos.length] = impliedAdminPermission; return new PermissionInfoCollection(getFileRelativeInfos(bundleImpliedInfos, bundle)); }