@Test public void testStartActivatorNoServicesSecured() throws Exception { Properties oldProps = new Properties(); oldProps.putAll(System.getProperties()); try { Properties newProps = removeProperties(System.getProperties(), GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); System.setProperties(newProps); BundleContext bc = EasyMock.createNiceMock(BundleContext.class); EasyMock.replay(bc); Activator a = new Activator(); a.start(bc); assertNull(a.guardProxyCatalog); } finally { System.setProperties(oldProps); } }
@Override public void start(BundleContext bundleContext) throws Exception { String f = System.getProperty(GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); Filter securedServicesFilter; if (f == null) { logger.info("No role-based security for services as its system property is not set: {}", GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); return; } else { securedServicesFilter = bundleContext.createFilter(f); logger.info("Adding role-based security to services with filter: {}", f); } guardProxyCatalog = new GuardProxyCatalog(bundleContext); guardingEventHook = new GuardingEventHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(EventListenerHook.class, guardingEventHook, null); guardingFindHook = new GuardingFindHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(FindHook.class, guardingFindHook, null); }
Activator implements BundleActivator { @Override public void start(BundleContext bundleContext) throws Exception { String f = System.getProperty(GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); Filter securedServicesFilter; if (f == null) { logger.info("No role-based security for services as its system property is not set: {}", GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); return; } else { securedServicesFilter = bundleContext.createFilter(f); logger.info("Adding role-based security to services with filter: {}", f); } guardProxyCatalog = new GuardProxyCatalog(bundleContext); guardingEventHook = new GuardingEventHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(EventListenerHook.class, guardingEventHook, null); guardingFindHook = new GuardingFindHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(FindHook.class, guardingFindHook, null); } }
Activator implements BundleActivator { @Override public void start(BundleContext bundleContext) throws Exception { String f = System.getProperty(GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); Filter securedServicesFilter; if (f == null) { logger.info("No role-based security for services as its system property is not set: {}", GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); return; } else { securedServicesFilter = bundleContext.createFilter(f); logger.info("Adding role-based security to services with filter: {}", f); } guardProxyCatalog = new GuardProxyCatalog(bundleContext); guardingEventHook = new GuardingEventHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(EventListenerHook.class, guardingEventHook, null); guardingFindHook = new GuardingFindHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(FindHook.class, guardingFindHook, null); }  }
Activator implements BundleActivator { @Override public void start(BundleContext bundleContext) throws Exception { String f = System.getProperty(GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); Filter securedServicesFilter; if (f == null) { logger.info("No role-based security for services as its system property is not set: {}", GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); return; } else { securedServicesFilter = bundleContext.createFilter(f); logger.info("Adding role-based security to services with filter: {}", f); } guardProxyCatalog = new GuardProxyCatalog(bundleContext); guardingEventHook = new GuardingEventHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(EventListenerHook.class, guardingEventHook, null); guardingFindHook = new GuardingFindHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(FindHook.class, guardingFindHook, null); }  @Override void start(BundleContext bundleContext); @Override void stop(BundleContext bundleContext); }
Activator implements BundleActivator { @Override public void start(BundleContext bundleContext) throws Exception { String f = System.getProperty(GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); Filter securedServicesFilter; if (f == null) { logger.info("No role-based security for services as its system property is not set: {}", GuardProxyCatalog.KARAF_SECURED_SERVICES_SYSPROP); return; } else { securedServicesFilter = bundleContext.createFilter(f); logger.info("Adding role-based security to services with filter: {}", f); } guardProxyCatalog = new GuardProxyCatalog(bundleContext); guardingEventHook = new GuardingEventHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(EventListenerHook.class, guardingEventHook, null); guardingFindHook = new GuardingFindHook(bundleContext, guardProxyCatalog, securedServicesFilter); bundleContext.registerService(FindHook.class, guardingFindHook, null); }  @Override void start(BundleContext bundleContext); @Override void stop(BundleContext bundleContext);  }