Move the check for a security manager in Felix.init down one if statement to fix a security exception (FELIX-2589).
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1000155 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 1ec8304..62ac4ab 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -528,48 +528,48 @@
Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE);
try
{
- String security = (String) m_configMap.get(Constants.FRAMEWORK_SECURITY);
- if (security != null)
- {
- if (System.getSecurityManager() != null)
- {
- 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()
- {
- public void checkPermission(Permission perm)
- {
- 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)
- {
- throw new SecurityException("Unable to install custom SecurityManager: " + security, t);
- }
- }
- }
if ((getState() == Bundle.INSTALLED) || (getState() == Bundle.RESOLVED))
{
+ String security = (String) m_configMap.get(Constants.FRAMEWORK_SECURITY);
+ if (security != null)
+ {
+ if (System.getSecurityManager() != null)
+ {
+ 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()
+ {
+ public void checkPermission(Permission perm)
+ {
+ 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)
+ {
+ throw new SecurityException("Unable to install custom SecurityManager: " + security, t);
+ }
+ }
+ }
// 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);