diff options
author | Thomas Watson | 2011-02-01 20:51:12 +0000 |
---|---|---|
committer | Thomas Watson | 2011-02-01 20:51:12 +0000 |
commit | 65a6b6ce374167a53f19e50f68517a46887cbac9 (patch) | |
tree | 8c72824d3cc5293d3eb47c8fd21ec027834f08a3 /bundles/org.eclipse.osgi/osgi/src/org/osgi | |
parent | 4a83192ba95b3d7fb2454eeaedf34ee145572c26 (diff) | |
download | rt.equinox.framework-65a6b6ce374167a53f19e50f68517a46887cbac9.tar.gz rt.equinox.framework-65a6b6ce374167a53f19e50f68517a46887cbac9.tar.xz rt.equinox.framework-65a6b6ce374167a53f19e50f68517a46887cbac9.zip |
Bug 334553 - OSGi added weave action to AdminPermission
Diffstat (limited to 'bundles/org.eclipse.osgi/osgi/src/org/osgi')
-rw-r--r-- | bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java | 115 |
1 files changed, 69 insertions, 46 deletions
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java index 85c5a8f4d..fc7b1f4aa 100644 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2011). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import java.util.Map; * class Bundle.loadClass * execute Bundle.start * Bundle.stop - * StartLevel.setBundleStartLevel + * BundleStartLevel.setStartLevel * extensionLifecycle BundleContext.installBundle for extension bundles * Bundle.update for extension bundles * Bundle.uninstall for extension bundles @@ -56,23 +56,25 @@ import java.util.Map; * BundleContext.removeBundleListener for SynchronousBundleListener * metadata Bundle.getHeaders * Bundle.getLocation - * resolve PackageAdmin.refreshPackages - * PackageAdmin.resolveBundles + * resolve FrameworkWiring.refreshBundles + * FrameworkWiring.resolveBundles * resource Bundle.getResource * Bundle.getResources * Bundle.getEntry * Bundle.getEntryPaths * Bundle.findEntries * Bundle resource/entry URL creation - * startlevel StartLevel.setStartLevel - * StartLevel.setInitialBundleStartLevel + * startlevel FrameworkStartLevel.setStartLevel + * FrameworkStartLevel.setInitialBundleStartLevel * context Bundle.getBundleContext + * weave WovenClass.setBytes + * WovenClass.getDynamicImports for modification * </pre> * * <p> * The special action "*" will represent all actions. The - * {@code resolve} action is implied by the {@code class}, - * {@code execute} and {@code resource} actions. + * {@code resolve} action is implied by the {@code class}, {@code execute} and + * {@code resource} actions. * <p> * The name of this permission is a filter expression. The filter gives access * to the following attributes: @@ -87,7 +89,7 @@ import java.util.Map; * Filter attribute names are processed in a case sensitive manner. * * @ThreadSafe - * @version $Id: 8488ac114b71f92331d3a6739b878e4bd55fecdb $ + * @version $Id: 43baf9a6d7ce5e6108507834e841e340fd91c513 $ */ public final class AdminPermission extends BasicPermission { @@ -160,6 +162,13 @@ public final class AdminPermission extends BasicPermission { */ public final static String CONTEXT = "context"; + /** + * The action string {@code weave}. + * + * @since 1.6 + */ + public final static String WEAVE = "weave"; + private final static int ACTION_CLASS = 0x00000001; private final static int ACTION_EXECUTE = 0x00000002; private final static int ACTION_LIFECYCLE = 0x00000004; @@ -170,6 +179,7 @@ public final class AdminPermission extends BasicPermission { private final static int ACTION_STARTLEVEL = 0x00000100; private final static int ACTION_EXTENSIONLIFECYCLE = 0x00000200; private final static int ACTION_CONTEXT = 0x00000400; + private final static int ACTION_WEAVE = 0x00000800; private final static int ACTION_ALL = ACTION_CLASS | ACTION_EXECUTE | ACTION_LIFECYCLE @@ -179,7 +189,8 @@ public final class AdminPermission extends BasicPermission { | ACTION_RESOURCE | ACTION_STARTLEVEL | ACTION_EXTENSIONLIFECYCLE - | ACTION_CONTEXT; + | ACTION_CONTEXT + | ACTION_WEAVE; final static int ACTION_NONE = 0; /** @@ -247,14 +258,13 @@ public final class AdminPermission extends BasicPermission { * Null arguments are equivalent to "*". * * @param filter A filter expression that can use signer, location, id, and - * name keys. A value of "*" or {@code null} matches - * all bundle. Filter attribute names are processed in a case - * sensitive manner. - * @param actions {@code class}, {@code execute}, - * {@code extensionLifecycle}, {@code lifecycle}, - * {@code listener}, {@code metadata}, {@code resolve} - * , {@code resource}, {@code startlevel} or - * {@code context}. A value of "*" or {@code null} + * name keys. A value of "*" or {@code null} matches all + * bundle. Filter attribute names are processed in a case sensitive + * manner. + * @param actions {@code class}, {@code execute}, {@code extensionLifecycle} + * , {@code lifecycle}, {@code listener}, {@code metadata}, + * {@code resolve} , {@code resource}, {@code startlevel}, + * {@code context} or {@code weave}. A value of "*" or {@code null} * indicates all actions. * @throws IllegalArgumentException If the filter has an invalid syntax. */ @@ -265,17 +275,16 @@ public final class AdminPermission extends BasicPermission { } /** - * Creates a new requested {@code AdminPermission} object to be used by - * the code that must perform {@code checkPermission}. - * {@code AdminPermission} objects created with this constructor cannot - * be added to an {@code AdminPermission} permission collection. + * Creates a new requested {@code AdminPermission} object to be used by the + * code that must perform {@code checkPermission}. {@code AdminPermission} + * objects created with this constructor cannot be added to an + * {@code AdminPermission} permission collection. * * @param bundle A bundle. - * @param actions {@code class}, {@code execute}, - * {@code extensionLifecycle}, {@code lifecycle}, - * {@code listener}, {@code metadata}, {@code resolve} - * , {@code resource}, {@code startlevel}, - * {@code context}. A value of "*" or {@code null} + * @param actions {@code class}, {@code execute}, {@code extensionLifecycle} + * , {@code lifecycle}, {@code listener}, {@code metadata}, + * {@code resolve} , {@code resource}, {@code startlevel}, + * {@code context}, {@code weave}. A value of "*" or {@code null} * indicates all actions. * @since 1.3 */ @@ -503,19 +512,29 @@ public final class AdminPermission extends BasicPermission { } else - if (i >= 0 && - - (a[i] == '*')) { - matchlen = 1; - mask |= ACTION_ALL; - - } - else { - // parse error - throw new IllegalArgumentException( - "invalid permission: " - + actions); + if (i >= 4 + && (a[i - 4] == 'w' || a[i - 4] == 'W') + && (a[i - 3] == 'e' || a[i - 3] == 'E') + && (a[i - 2] == 'a' || a[i - 2] == 'A') + && (a[i - 1] == 'v' || a[i - 1] == 'V') + && (a[i] == 'e' || a[i] == 'E')) { + matchlen = 5; + mask |= ACTION_WEAVE; + } + else + if (i >= 0 + && (a[i] == '*')) { + matchlen = 1; + mask |= ACTION_ALL; + + } + else { + // parse error + throw new IllegalArgumentException( + "invalid permission: " + + actions); + } // make sure we didn't just match the tail of a word // like "ackbarfstartlevel". Also, skip to the comma. @@ -668,14 +687,13 @@ public final class AdminPermission extends BasicPermission { * {@code AdminPermission} actions. * * <p> - * Always returns present {@code AdminPermission} actions in the - * following order: {@code class}, {@code execute}, - * {@code extensionLifecycle}, {@code lifecycle}, - * {@code listener}, {@code metadata}, {@code resolve}, - * {@code resource}, {@code startlevel}, {@code context}. + * Always returns present {@code AdminPermission} actions in the following + * order: {@code class}, {@code execute}, {@code extensionLifecycle}, + * {@code lifecycle}, {@code listener}, {@code metadata}, {@code resolve}, + * {@code resource}, {@code startlevel}, {@code context}, {@code weave}. * - * @return Canonical string representation of the - * {@code AdminPermission} actions. + * @return Canonical string representation of the {@code AdminPermission} + * actions. */ public String getActions() { String result = actions; @@ -732,6 +750,11 @@ public final class AdminPermission extends BasicPermission { sb.append(CONTEXT); sb.append(','); } + + if ((mask & ACTION_WEAVE) == ACTION_WEAVE) { + sb.append(WEAVE); + sb.append(','); + } // remove trailing comma if (sb.length() > 0) { |