felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r437838 - /incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java
Date Mon, 28 Aug 2006 21:04:47 GMT
Author: pauls
Date: Mon Aug 28 14:04:47 2006
New Revision: 437838

URL: http://svn.apache.org/viewvc?rev=437838&view=rev
Log:
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)

Modified:
    incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java

Modified: incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java?rev=437838&r1=437837&r2=437838&view=diff
==============================================================================
--- incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java
(original)
+++ incubator/felix/trunk/framework/src/main/java/org/osgi/framework/AdminPermission.java
Mon Aug 28 14:04:47 2006
@@ -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());
+    }
+}



Mime
View raw message