felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1189621 - in /felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl: ConfigurationAdapter.java ConfigurationAdminImpl.java ConfigurationManager.java
Date Thu, 27 Oct 2011 06:12:38 GMT
Author: fmeschbe
Date: Thu Oct 27 06:12:37 2011
New Revision: 1189621

URL: http://svn.apache.org/viewvc?rev=1189621&view=rev
Log:
FELIX-3176 Implement Config Admin 1.4 Changes
  - Implicit permission for bundles to read, manage, and receive their own config and un-owned
config
  - A lot of DEBUG logging statements

Modified:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java?rev=1189621&r1=1189620&r2=1189621&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
(original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
Thu Oct 27 06:12:37 2011
@@ -85,7 +85,7 @@ public class ConfigurationAdapter implem
     {
         // CM 1.4 / 104.13.2.4
         configurationAdmin.checkPermission( delegatee.getBundleLocation() );
-        configurationAdmin.checkPermission( bundleLocation );
+        configurationAdmin.checkPermission( ( bundleLocation == null ) ? "*" : bundleLocation
);
         checkDeleted();
         delegatee.setStaticBundleLocation( bundleLocation );
     }

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java?rev=1189621&r1=1189620&r2=1189621&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
(original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
Thu Oct 27 06:12:37 2011
@@ -25,6 +25,7 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ConfigurationPermission;
+import org.osgi.service.log.LogService;
 
 
 /**
@@ -95,6 +96,10 @@ public class ConfigurationAdminImpl impl
 
         if ( config.getBundleLocation() == null )
         {
+            configurationManager.log( LogService.LOG_DEBUG, "Binding configuration {0} (isNew:
{1}) to bundle {2}",
+                new Object[]
+                    { config.getPid(), Boolean.valueOf( config.isNew() ), getBundle().getLocation()
} );
+
             config.setStaticBundleLocation( this.getBundle().getLocation() );
         }
         else if ( !config.getBundleLocation().equals( this.getBundle().getLocation() ) )
@@ -178,11 +183,9 @@ public class ConfigurationAdminImpl impl
      * the given permission for the given bundle location and throws a
      * <code>SecurityException</code> if this is not the case.
      *
-     * @param name The bundle location to check for permission. If
-     *   <code>null</code> assumes <code>*</code>.
-     * @param permission The actual permission to check. This must be one
-     *    of the constants defined in the
-     *    <code>ConfigurationPermission</code> class.
+     * @param name The bundle location to check for permission. If this
+     *      is <code>null</code> or exactly matches the using bundle's
+     *      location, permission is always granted.
      *
      * @throws SecurityException if the access control context does not
      *      have the appropriate permission
@@ -193,11 +196,34 @@ public class ConfigurationAdminImpl impl
         final SecurityManager sm = System.getSecurityManager();
         if ( sm != null )
         {
-            if (name == null) {
-                name = "*";
+            // CM 1.4 / 104.11.1 Implicit permission
+            if ( name != null && !name.equals( getBundle().getLocation() ) )
+            {
+                sm.checkPermission( new ConfigurationPermission( name, ConfigurationPermission.CONFIGURE
) );
+
+                if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+                {
+                    configurationManager.log( LogService.LOG_DEBUG,
+                        "Explicit Permission; grant CONFIGURE permission on configuration
bound to {0} to bundle {1}",
+                        new Object[]
+                            { name, getBundle().getLocation() } );
+                }
             }
+            else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+            {
+                configurationManager.log( LogService.LOG_DEBUG,
+                    "Implicit Permission; grant CONFIGURE permission on configuration bound
to {0} to bundle {1}",
+                    new Object[]
+                        { name, getBundle().getLocation() } );
 
-            sm.checkPermission( new ConfigurationPermission( name, ConfigurationPermission.CONFIGURE
) );
+            }
+        }
+        else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+        {
+            configurationManager.log( LogService.LOG_DEBUG,
+                "No SecurityManager installed; grant CONFIGURE permission on configuration
bound to {0} to bundle {1}",
+                new Object[]
+                    { name, getBundle().getLocation() } );
         }
     }
 

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1189621&r1=1189620&r2=1189621&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
(original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Thu Oct 27 06:12:37 2011
@@ -434,6 +434,8 @@ public class ConfigurationManager implem
         ConfigurationImpl config = getCachedConfiguration( pid );
         if ( config != null )
         {
+            log( LogService.LOG_DEBUG, "Found cached configuration {0} bound to {1}", new
Object[]
+                { pid, config.getBundleLocation() } );
             return config;
         }
 
@@ -444,6 +446,8 @@ public class ConfigurationManager implem
             {
                 Dictionary props = pmList[i].load( pid );
                 config = new ConfigurationImpl( this, pmList[i], props );
+                log( LogService.LOG_DEBUG, "Found existing configuration {0} bound to {1}",
new Object[]
+                    { pid, config.getBundleLocation() } );
                 return cacheConfiguration( config );
             }
         }
@@ -504,7 +508,7 @@ public class ConfigurationManager implem
                 {
                     log(
                         LogService.LOG_DEBUG,
-                        "Omitting configuration {0}: No permission for {1} on {2}",
+                        "Omitting configuration {0}: No permission for bundle {1} on configuration
bound to {2}",
                         new Object[]
                             { config.get( Constants.SERVICE_PID ), configurationAdmin.getBundle().getLocation(),
                                 config.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) }
);



Mime
View raw message