Author: pauls
Date: Wed Sep 22 19:44:36 2010
New Revision: 1000155

URL: http://svn.apache.org/viewvc?rev=1000155&view=rev
Log:
Move the check for a security manager in Felix.init down one if statement to 
fix a security exception (FELIX-2589).

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: 
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1000155&r1=1000154&r2=1000155&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java 
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java 
Wed Sep 22 19:44:36 2010
@@ -528,48 +528,48 @@ public class Felix extends BundleImpl im
             Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | 
Bundle.ACTIVE);
         try
         {
-            String security = (String) 
m_configMap.get(Constants.FRAMEWORK_SECURITY);
-            if (security != null)
+            if ((getState() == Bundle.INSTALLED) || (getState() == 
Bundle.RESOLVED))
             {
-                if (System.getSecurityManager() != null)
-                {
-                    throw new SecurityException("SecurityManager already 
installed");
-                }
-                security = security.trim();
-                if 
(Constants.FRAMEWORK_SECURITY_OSGI.equalsIgnoreCase(security) || 
(security.length() == 0))
+                String security = (String) 
m_configMap.get(Constants.FRAMEWORK_SECURITY);
+                if (security != null)
                 {
-                    // TODO: SECURITY - we only need our own security manager 
to convert the exceptions
-                    //       because the 4.2.0 ct does expect them like this 
in one case. 
-                    System.setSecurityManager(m_securityManager = new 
SecurityManager()
+                    if (System.getSecurityManager() != null)
                     {
-                        public void checkPermission(Permission perm) 
+                        throw new SecurityException("SecurityManager already 
installed");
+                    }
+                    security = security.trim();
+                    if 
(Constants.FRAMEWORK_SECURITY_OSGI.equalsIgnoreCase(security) || 
(security.length() == 0))
+                    {
+                        // TODO: SECURITY - we only need our own security 
manager to convert the exceptions
+                        //       because the 4.2.0 ct does expect them like 
this in one case. 
+                        System.setSecurityManager(m_securityManager = new 
SecurityManager()
                         {
-                            try
+                            public void checkPermission(Permission perm) 
                             {
-                                super.checkPermission(perm);
-                            }
-                            catch (AccessControlException ex)
-                            {
-                                throw new SecurityException(ex);
+                                try
+                                {
+                                    super.checkPermission(perm);
+                                }
+                                catch (AccessControlException ex)
+                                {
+                                    throw new SecurityException(ex);
+                                }
                             }
-                        }
-                    });
-                }
-                else
-                {
-                    try 
-                    {
-                        System.setSecurityManager(m_securityManager = 
-                            (SecurityManager) 
Class.forName(security).newInstance());
-                    } 
-                    catch (Throwable t)
+                        });
+                    }
+                    else
                     {
-                        throw new SecurityException("Unable to install custom 
SecurityManager: " + security, t); 
+                        try 
+                        {
+                            System.setSecurityManager(m_securityManager = 
+                                (SecurityManager) 
Class.forName(security).newInstance());
+                        } 
+                        catch (Throwable t)
+                        {
+                            throw new SecurityException("Unable to install 
custom SecurityManager: " + security, t); 
+                        }
                     }
                 }
-            }
-            if ((getState() == Bundle.INSTALLED) || (getState() == 
Bundle.RESOLVED))
-            {
                 // Get any system bundle activators.
                 m_activatorList = (List) 
m_configMutableMap.get(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP);
                 m_activatorList = (m_activatorList == null) ? new ArrayList() 
: new ArrayList(m_activatorList);


Reply via email to