You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/05/10 09:34:02 UTC
svn commit: r1336510 - in /karaf/cellar/branches/cellar-2.2.x/obr/src/main:
java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
resources/OSGI-INF/blueprint/management.xml
Author: jbonofre
Date: Thu May 10 07:34:01 2012
New Revision: 1336510
URL: http://svn.apache.org/viewvc?rev=1336510&view=rev
Log:
[KARAF-1429] CellarOBRMBean now check if the URL or bundle ID is allowed outbound
Modified:
karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/management.xml
Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java?rev=1336510&r1=1336509&r2=1336510&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java Thu May 10 07:34:01 2012
@@ -16,17 +16,16 @@ package org.apache.karaf.cellar.obr.mana
import org.apache.felix.bundlerepository.Repository;
import org.apache.felix.bundlerepository.RepositoryAdmin;
import org.apache.felix.bundlerepository.Resource;
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Configurations;
-import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.GroupManager;
+import org.apache.karaf.cellar.core.*;
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
+import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.cellar.obr.Constants;
import org.apache.karaf.cellar.obr.ObrBundleEvent;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
import org.apache.karaf.cellar.obr.ObrUrlEvent;
import org.apache.karaf.cellar.obr.management.CellarOBRMBean;
+import org.osgi.service.cm.ConfigurationAdmin;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
@@ -43,6 +42,7 @@ public class CellarOBRMBeanImpl extends
private ClusterManager clusterManager;
private GroupManager groupManager;
private EventProducer eventProducer;
+ private ConfigurationAdmin configurationAdmin;
private RepositoryAdmin obrService;
public CellarOBRMBeanImpl() throws NotCompliantMBeanException {
@@ -108,6 +108,15 @@ public class CellarOBRMBeanImpl extends
throw new IllegalStateException("Cluster event producer is OFF");
}
+ // check if the URL is allowed outbound
+ CellarSupport support = new CellarSupport();
+ support.setClusterManager(this.clusterManager);
+ support.setGroupManager(this.groupManager);
+ support.setConfigurationAdmin(this.configurationAdmin);
+ if (!support.isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) {
+ throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound");
+ }
+
// push the OBR URL in the distributed set
Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
urls.add(url);
@@ -142,6 +151,15 @@ public class CellarOBRMBeanImpl extends
throw new IllegalStateException("Cluster event producer is OFF");
}
+ // check if the URL is allowed outbound
+ CellarSupport support = new CellarSupport();
+ support.setClusterManager(this.clusterManager);
+ support.setGroupManager(this.groupManager);
+ support.setConfigurationAdmin(this.configurationAdmin);
+ if (!support.isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) {
+ throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound");
+ }
+
// remove URL from the distributed map
Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
urls.remove(url);
@@ -175,6 +193,15 @@ public class CellarOBRMBeanImpl extends
throw new IllegalStateException("Cluster event producer is OFF");
}
+ // check if the bundle ID is allowed outbound
+ CellarSupport support = new CellarSupport();
+ support.setClusterManager(this.clusterManager);
+ support.setGroupManager(this.groupManager);
+ support.setConfigurationAdmin(this.configurationAdmin);
+ if (!support.isAllowed(group, Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.OUTBOUND)) {
+ throw new IllegalArgumentException("OBR bundle " + bundleId + " is blocked outbound");
+ }
+
// create an event and produce it
int type = 0;
ObrBundleEvent event = new ObrBundleEvent(bundleId, type);
@@ -215,4 +242,12 @@ public class CellarOBRMBeanImpl extends
this.obrService = obrService;
}
+ public ConfigurationAdmin getConfigurationAdmin() {
+ return configurationAdmin;
+ }
+
+ public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
+ this.configurationAdmin = configurationAdmin;
+ }
+
}
Modified: karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/management.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/management.xml?rev=1336510&r1=1336509&r2=1336510&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/management.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/obr/src/main/resources/OSGI-INF/blueprint/management.xml Thu May 10 07:34:01 2012
@@ -22,6 +22,7 @@
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="eventProducer" ref="eventProducer"/>
+ <property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
<bean id="mbeanRegister" class="org.apache.karaf.management.MBeanRegistrer">