aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1339648 - in /aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container: BlueprintContainerImpl.java BlueprintDomainCombiner.java BlueprintProtectionDomain.java
Date Thu, 17 May 2012 15:22:47 GMT
Author: gnodet
Date: Thu May 17 15:22:46 2012
New Revision: 1339648

URL: http://svn.apache.org/viewvc?rev=1339648&view=rev
Log:
[ARIES-838] ClassCircularityError in BlueprintContainerImpl when using a security manager

Added:
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintDomainCombiner.java
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintProtectionDomain.java
Modified:
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java

Modified: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java?rev=1339648&r1=1339647&r2=1339648&view=diff
==============================================================================
--- aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
(original)
+++ aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
Thu May 17 15:22:46 2012
@@ -23,12 +23,9 @@ import java.net.URI;
 import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.AccessController;
-import java.security.DomainCombiner;
-import java.security.Permission;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
-import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -100,6 +97,11 @@ public class BlueprintContainerImpl impl
 
     private static final Logger LOGGER = LoggerFactory.getLogger(BlueprintContainerImpl.class);
 
+    private static final Class[] SECURITY_BUGFIX = {
+            BlueprintDomainCombiner.class,
+            BlueprintProtectionDomain.class,
+    };
+    
     private enum State {
         Unknown,
         WaitForNamespaceHandlers,
@@ -151,7 +153,7 @@ public class BlueprintContainerImpl impl
         this.executors = executors;
         this.processors = new ArrayList<Processor>();
         if (System.getSecurityManager() != null) {
-            this.accessControlContext = createAccessControlContext();
+            this.accessControlContext = BlueprintDomainCombiner.createAccessControlContext(bundleContext);
         }
     }
 
@@ -426,21 +428,6 @@ public class BlueprintContainerImpl impl
         }
     }
     
-    private AccessControlContext createAccessControlContext() {
-        return new AccessControlContext(AccessController.getContext(),
-                new DomainCombiner() {               
-                    public ProtectionDomain[] combine(ProtectionDomain[] arg0,
-                                                      ProtectionDomain[] arg1) {        
           
-                        return new ProtectionDomain[] { new ProtectionDomain(null, null)
{                        
-                            public boolean implies(Permission permission) {             
                                             
-                                return bundleContext.getBundle().hasPermission(permission);
-                            }
-                        } 
-                    };
-                }
-        });
-    }
-    
     public AccessControlContext getAccessControlContext() {
         return accessControlContext;
     }
@@ -875,5 +862,6 @@ public class BlueprintContainerImpl impl
         }
     }
 
+
 }
 

Added: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintDomainCombiner.java
URL: http://svn.apache.org/viewvc/aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintDomainCombiner.java?rev=1339648&view=auto
==============================================================================
--- aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintDomainCombiner.java
(added)
+++ aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintDomainCombiner.java
Thu May 17 15:22:46 2012
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.container;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.DomainCombiner;
+import java.security.ProtectionDomain;
+
+import org.osgi.framework.BundleContext;
+
+public class BlueprintDomainCombiner implements DomainCombiner {
+    private final BundleContext bundleContext;
+
+    public static AccessControlContext createAccessControlContext(BundleContext bundleContext)
{
+        return new AccessControlContext(AccessController.getContext(), new BlueprintDomainCombiner(bundleContext));
+    }
+
+    BlueprintDomainCombiner(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public ProtectionDomain[] combine(ProtectionDomain[] arg0,
+                                      ProtectionDomain[] arg1) {
+        return new ProtectionDomain[] { new BlueprintProtectionDomain(bundleContext) };
+    }
+
+}

Added: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintProtectionDomain.java
URL: http://svn.apache.org/viewvc/aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintProtectionDomain.java?rev=1339648&view=auto
==============================================================================
--- aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintProtectionDomain.java
(added)
+++ aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintProtectionDomain.java
Thu May 17 15:22:46 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.container;
+
+import java.security.Permission;
+import java.security.ProtectionDomain;
+
+import org.osgi.framework.BundleContext;
+
+public class BlueprintProtectionDomain extends ProtectionDomain {
+
+    private final BundleContext bundleContext;
+
+    public BlueprintProtectionDomain(BundleContext bundleContext) {
+        super(null, null);
+        this.bundleContext = bundleContext;
+    }
+
+    public boolean implies(Permission permission) {
+        try {
+            return bundleContext.getBundle().hasPermission(permission);
+        } catch (IllegalStateException e) {
+            return false;
+        }
+    }
+}



Mime
View raw message