Apply patch from BJ Hargrave that moves AdminPermissionCollection out of AdminPermission.
Minus the part of the patch that makes Signer none public - I'll comment on the JIRA separately.
(FELIX-22)
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@437838 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/osgi/framework/AdminPermission.java b/framework/src/main/java/org/osgi/framework/AdminPermission.java
index f017881..f46cf54 100644
--- a/framework/src/main/java/org/osgi/framework/AdminPermission.java
+++ b/framework/src/main/java/org/osgi/framework/AdminPermission.java
@@ -57,7 +57,7 @@
RESOLVE_MASK | RESOURCE_MASK | STARTLEVEL_MASK;
private String m_actions = null;
- private int m_actionMask = 0;
+ int m_actionMask = 0;
// Cached filter for permissions created with a filter when
// granting admin permissions.
@@ -93,7 +93,7 @@
// This constructor is only used by the admin permission collection
// when combining admin permissions or by the default constructor when granting
// an admin permission
- private AdminPermission(String filter, int actionMask)
+ AdminPermission(String filter, int actionMask)
{
super((filter == null) || (filter.equals("*")) ? "(id=*)" : filter);
m_actionMask = actionMask;
@@ -360,63 +360,6 @@
return sb.toString();
}
- final class AdminPermissionCollection extends PermissionCollection
- {
- private HashMap m_map = new HashMap();
-
- public void add(Permission permission)
- {
- if (!(permission instanceof AdminPermission))
- {
- throw new IllegalArgumentException("Invalid permission: " + permission);
- }
- else if (isReadOnly())
- {
- throw new SecurityException(
- "Cannot add to read-only permission collection.");
- }
-
- AdminPermission admin = (AdminPermission) permission;
- AdminPermission current = (AdminPermission) m_map.get(admin.getName());
- if (current != null)
- {
- if (admin.m_actionMask != current.m_actionMask)
- {
- m_map.put(admin.getName(),
- new AdminPermission(admin.getName(),
- admin.m_actionMask | current.m_actionMask));
- }
- }
- else
- {
- m_map.put(admin.getName(), admin);
- }
- }
-
- public boolean implies(Permission permission)
- {
- if (!(permission instanceof AdminPermission))
- {
- return false;
- }
-
- for (Iterator iter = m_map.values().iterator(); iter.hasNext(); )
- {
- if (((AdminPermission) iter.next()).implies(permission))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public Enumeration elements()
- {
- return Collections.enumeration(m_map.values());
- }
- }
-
public static final class Signer implements PrivilegedAction
{
private Bundle m_bundleImpl = null;
@@ -869,4 +812,62 @@
return pos;
}
}
-}
\ No newline at end of file
+}
+
+final class AdminPermissionCollection extends PermissionCollection
+{
+ private static final long serialVersionUID = 3747361397420496672L;
+ private HashMap m_map = new HashMap();
+
+ public void add(Permission permission)
+ {
+ if (!(permission instanceof AdminPermission))
+ {
+ throw new IllegalArgumentException("Invalid permission: " + permission);
+ }
+ else if (isReadOnly())
+ {
+ throw new SecurityException(
+ "Cannot add to read-only permission collection.");
+ }
+
+ AdminPermission admin = (AdminPermission) permission;
+ AdminPermission current = (AdminPermission) m_map.get(admin.getName());
+ if (current != null)
+ {
+ if (admin.m_actionMask != current.m_actionMask)
+ {
+ m_map.put(admin.getName(),
+ new AdminPermission(admin.getName(),
+ admin.m_actionMask | current.m_actionMask));
+ }
+ }
+ else
+ {
+ m_map.put(admin.getName(), admin);
+ }
+ }
+
+ public boolean implies(Permission permission)
+ {
+ if (!(permission instanceof AdminPermission))
+ {
+ return false;
+ }
+
+ for (Iterator iter = m_map.values().iterator(); iter.hasNext(); )
+ {
+ if (((AdminPermission) iter.next()).implies(permission))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Enumeration elements()
+ {
+ return Collections.enumeration(m_map.values());
+ }
+}