Source:
private synchronized SecurityProvider loadDelegate() { StringConfigMap brooklynProperties = mgmt.getConfig(); String className = brooklynProperties.getConfig(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME); if (delegate != null && BrooklynWebConfig.hasNoSecurityOptions(mgmt.getConfig())) { log.debug("{} refusing to change from {}: No security provider set in reloaded properties.", this, delegate); return delegate; } log.info("REST using security provider " + className); try { Class<? extends SecurityProvider> clazz; try { clazz = (Class<? extends SecurityProvider>) Class.forName(className); } catch (Exception e) { String oldPackage = "brooklyn.web.console.security."; if (className.startsWith(oldPackage)) { className = Strings.removeFromStart(className, oldPackage); className = DelegatingSecurityProvider.class.getPackage().getName() + "." + className; clazz = (Class<? extends SecurityProvider>) Class.forName(className); log.warn("Deprecated package " + oldPackage + " detected; please update security provider to point to " + className); } else throw e; } Constructor<? extends SecurityProvider> constructor; try { constructor = clazz.getConstructor(ManagementContext.class); delegate = constructor.newInstance(mgmt); } catch (Exception e) { constructor = clazz.getConstructor(); Object delegateO = constructor.newInstance(); if (!(delegateO instanceof SecurityProvider)) { throw new ClassCastException("Delegate is either not a security provider or has an incompatible classloader: "+delegateO); } delegate = (SecurityProvider) delegateO; } } catch (Exception e) { log.warn("REST unable to instantiate security provider " + className + "; all logins are being disallowed", e); e.printStackTrace(); delegate = new BlackholeSecurityProvider(); } return delegate; }

Target:
private synchronized SecurityProvider loadDelegate() { StringConfigMap brooklynProperties = mgmt.getConfig(); String className = brooklynProperties.getConfig(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME); if (delegate != null && BrooklynWebConfig.hasNoSecurityOptions(mgmt.getConfig())) { log.debug("{} refusing to change from {}: No security provider set in reloaded properties.", this, delegate); return delegate; } log.info("REST using security provider " + className); try { Class<? extends SecurityProvider> clazz; try { clazz = (Class<? extends SecurityProvider>) Class.forName(className); } catch (Exception e) { String oldPackage = "brooklyn.web.console.security."; if (className.startsWith(oldPackage)) { className = Strings.removeFromStart(className, oldPackage); className = DelegatingSecurityProvider.class.getPackage().getName() + "." + className; clazz = (Class<? extends SecurityProvider>) Class.forName(className); log.warn("Deprecated package " + oldPackage + " detected; please update security provider to point to " + className); } else throw e; } Constructor<? extends SecurityProvider> constructor; try { constructor = clazz.getConstructor(ManagementContext.class); delegate = constructor.newInstance(mgmt); } catch (Exception e) { constructor = clazz.getConstructor(); Object delegateO = constructor.newInstance(); if (!(delegateO instanceof SecurityProvider)) { throw new ClassCastException("Delegate is either not a security provider or has an incompatible classloader: "+delegateO); } delegate = (SecurityProvider) delegateO; } } catch (Exception e) { log.warn("REST unable to instantiate security provider " + className + "; all logins are being disallowed", e); delegate = new BlackholeSecurityProvider(); } return delegate; }