/**
 * Copyright (C) 2011, FuseSource Corp.  All rights reserved.
 * http://fusesource.com
 *
 * The software in this package is published under the terms of the
 * CDDL license a copy of which has been included with this distribution
 * in the license.txt file.
 */
package org.fusesource.fabric.jaas;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Dictionary;

public class Activator implements BundleActivator {

    private static final Logger LOG = LoggerFactory.getLogger(Activator.class);

    @Override
    public void start(BundleContext context) throws Exception {
        ServiceReference configurationAdminReference =
                context.getServiceReference(ConfigurationAdmin.class.getName());

        if (configurationAdminReference != null) {
            LOG.info("Changing security realm to zookeeper");
            ConfigurationAdmin confAdmin = (ConfigurationAdmin) context.getService(configurationAdminReference);
            Configuration config = confAdmin.getConfiguration("org.apache.karaf.shell");
            Dictionary props = config.getProperties();
            props.put("sshRealm", "zookeeper");
            config.update(props);

            config = confAdmin.getConfiguration("org.apache.karaf.management");
            props = config.getProperties();
            props.put("jmxRealm", "zookeeper");
            config.update(props);
        }
    }

    @Override
    public void stop(BundleContext context) throws Exception {
        ServiceReference configurationAdminReference =
                context.getServiceReference(ConfigurationAdmin.class.getName());

        if (configurationAdminReference != null) {
            LOG.info("Changing security realm to karaf");
            ConfigurationAdmin confAdmin = (ConfigurationAdmin) context.getService(configurationAdminReference);
            Configuration config = confAdmin.getConfiguration("org.apache.karaf.shell");
            Dictionary props = config.getProperties();
            props.put("sshRealm", "karaf");
            config.update(props);

            config = confAdmin.getConfiguration("org.apache.karaf.management");
            props = config.getProperties();
            props.put("jmxRealm", "karaf");
            config.update(props);
        }
    }
}

@@ -297,16 +297,46 @@
 .jaas;%0A%0A
+import java.util.Dictionary;%0A%0A
 import o
@@ -370,16 +370,16 @@
 ivator;%0A
-
 import o
@@ -606,38 +606,8 @@
 y;%0A%0A
-import java.util.Dictionary;%0A%0A
 publ
@@ -1361,32 +1361,76 @@
 , %22zookeeper%22);%0A
+            config.setBundleLocation(null);%0A
             conf
@@ -1612,32 +1612,76 @@
 , %22zookeeper%22);%0A
+            config.setBundleLocation(null);%0A
             conf
@@ -2331,32 +2331,76 @@
 alm%22, %22karaf%22);%0A
+            config.setBundleLocation(null);%0A
             conf
@@ -2534,32 +2534,32 @@
 etProperties();%0A
-
             prop
@@ -2578,32 +2578,76 @@
 alm%22, %22karaf%22);%0A
+            config.setBundleLocation(null);%0A
             conf

Fix fabric-jaas by making sure the config is not bound to fabric-jaas bundle