private String findAgentUrl(Configuration pConfig) { // System property has precedence String url = System.getProperty("jolokia." + ConfigKey.DISCOVERY_AGENT_URL.getKeyValue()); if (url == null) { url = System.getenv("JOLOKIA_DISCOVERY_AGENT_URL"); if (url == null) { url = pConfig.get(ConfigKey.DISCOVERY_AGENT_URL); } } return NetworkUtil.replaceExpression(url); }
public AgentDetails(Configuration pConfig) { this(NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID))); agentDescription = pConfig.get(ConfigKey.AGENT_DESCRIPTION); }
private Dictionary<String,String> getConfiguration() { Dictionary<String,String> config = new Hashtable<String,String>(); for (ConfigKey key : ConfigKey.values()) { String value = getConfiguration(key); if (value != null) { config.put(key.getKeyValue(),value); } } String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue())); if (jolokiaId == null) { config.put(ConfigKey.AGENT_ID.getKeyValue(), NetworkUtil.getAgentId(hashCode(),"osgi")); } config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi"); return config; }
/** * Start this server. If we manage an own HttpServer, then the HttpServer will * be started as well. */ public void start() { // URL as configured takes precedence String configUrl = NetworkUtil.replaceExpression(config.getJolokiaConfig().get(ConfigKey.DISCOVERY_AGENT_URL)); jolokiaHttpHandler.start(lazy,configUrl != null ? configUrl : url, config.getAuthenticator() != null); if (httpServer != null) { // Starting our own server in an own thread group with a fixed name // so that the cleanup thread can recognize it. ThreadGroup threadGroup = new ThreadGroup("jolokia"); threadGroup.setDaemon(false); Thread starterThread = new Thread(threadGroup,new Runnable() { @Override public void run() { httpServer.start(); } }); starterThread.start(); cleaner = new CleanupThread(httpServer,threadGroup); cleaner.start(); } }
/** * Create a new local dispatcher which accesses local MBeans. * * @param pConverters object/string converters * @param pRestrictor restrictor which checks the access for various operations * @param pConfig agent configuration * @param pLogHandler local handler used for logging out errors and warnings */ public LocalRequestDispatcher(Converters pConverters, Restrictor pRestrictor, Configuration pConfig, LogHandler pLogHandler) { // Get all MBean servers we can find. This is done by a dedicated // handler object mBeanServerHandler = new MBeanServerHandler(pConfig,pLogHandler); qualifier = pConfig.get(ConfigKey.MBEAN_QUALIFIER); log = pLogHandler; agentId = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID)); // Request handling manager requestHandlerManager = new RequestHandlerManager(pConfig,pConverters,mBeanServerHandler.getServerHandle(),pRestrictor); }
public static Restrictor createRestrictor(Configuration pConfig, LogHandler logHandler) { Restrictor customRestrictor = createCustomRestrictor(pConfig); if (customRestrictor != null) { logHandler.info("Using restrictor " + customRestrictor.getClass().getCanonicalName()); return customRestrictor; } String location = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.POLICY_LOCATION)); try { Restrictor ret = RestrictorFactory.lookupPolicyRestrictor(location); if (ret != null) { logHandler.info("Using policy access restrictor " + location); return ret; } else { logHandler.info("No access restrictor found, access to any MBean is allowed"); return new AllowAllRestrictor(); } } catch (IOException e) { logHandler.error("Error while accessing access restrictor at " + location + ". Denying all access to MBeans for security reasons. Exception: " + e, e); return new DenyAllRestrictor(); } }
public RBACRestrictor(Configuration config) { this(NetworkUtil.replaceExpression(config.get(ConfigKey.POLICY_LOCATION))); }
private String findAgentUrl(Configuration pConfig) { // System property has precedence String url = System.getProperty("jolokia." + ConfigKey.DISCOVERY_AGENT_URL.getKeyValue()); if (url == null) { url = System.getenv("JOLOKIA_DISCOVERY_AGENT_URL"); if (url == null) { url = pConfig.get(ConfigKey.DISCOVERY_AGENT_URL); } } return NetworkUtil.replaceExpression(url); }
private String findAgentUrl(Configuration pConfig) { // System property has precedence String url = System.getProperty("jolokia." + ConfigKey.DISCOVERY_AGENT_URL.getKeyValue()); if (url == null) { url = System.getenv("JOLOKIA_DISCOVERY_AGENT_URL"); if (url == null) { url = pConfig.get(ConfigKey.DISCOVERY_AGENT_URL); } } return NetworkUtil.replaceExpression(url); }
public AgentDetails(Configuration pConfig) { this(NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID))); agentDescription = pConfig.get(ConfigKey.AGENT_DESCRIPTION); }
public AgentDetails(Configuration pConfig) { this(NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID))); agentDescription = pConfig.get(ConfigKey.AGENT_DESCRIPTION); }
protected void initDelegate(Configuration config) { String location = NetworkUtil.replaceExpression(config.get(ConfigKey.POLICY_LOCATION)); try { this.delegate = RestrictorFactory.lookupPolicyRestrictor(location); if (this.delegate != null) { LOG.debug("Delegate - Using policy access restrictor {}", location); } else { LOG.debug("Delegate - No policy access restrictor found, access to any MBean is allowed"); this.delegate = new AllowAllRestrictor(); } } catch (IOException e) { LOG.error("Delegate - Error while accessing access policy restrictor at " + location + ". Denying all access to MBeans for security reasons. Exception: " + e, e); this.delegate = new DenyAllRestrictor(); } }
private Dictionary<String,String> getConfiguration() { Dictionary<String,String> config = new Hashtable<String,String>(); for (ConfigKey key : ConfigKey.values()) { String value = getConfiguration(key); if (value != null) { config.put(key.getKeyValue(),value); } } String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue())); if (jolokiaId == null) { config.put(ConfigKey.AGENT_ID.getKeyValue(), NetworkUtil.getAgentId(hashCode(),"osgi")); } config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi"); return config; }
/** * Create a new local dispatcher which accesses local MBeans. * * @param pConverters object/string converters * @param pRestrictor restrictor which checks the access for various operations * @param pConfig agent configuration * @param pLogHandler local handler used for logging out errors and warnings */ public LocalRequestDispatcher(Converters pConverters, Restrictor pRestrictor, Configuration pConfig, LogHandler pLogHandler) { // Get all MBean servers we can find. This is done by a dedicated // handler object mBeanServerHandler = new MBeanServerHandler(pConfig,pLogHandler); qualifier = pConfig.get(ConfigKey.MBEAN_QUALIFIER); log = pLogHandler; agentId = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID)); // Request handling manager requestHandlerManager = new RequestHandlerManager(pConfig,pConverters,mBeanServerHandler.getServerHandle(),pRestrictor); }
/** * Create a new local dispatcher which accesses local MBeans. * * @param pConverters object/string converters * @param pRestrictor restrictor which checks the access for various operations * @param pConfig agent configuration * @param pLogHandler local handler used for logging out errors and warnings */ public LocalRequestDispatcher(Converters pConverters, Restrictor pRestrictor, Configuration pConfig, LogHandler pLogHandler) { // Get all MBean servers we can find. This is done by a dedicated // handler object mBeanServerHandler = new MBeanServerHandler(pConfig,pLogHandler); qualifier = pConfig.get(ConfigKey.MBEAN_QUALIFIER); log = pLogHandler; agentId = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.AGENT_ID)); // Request handling manager requestHandlerManager = new RequestHandlerManager(pConfig,pConverters,mBeanServerHandler.getServerHandle(),pRestrictor); }
public static Restrictor createRestrictor(Configuration pConfig, LogHandler logHandler) { Restrictor customRestrictor = createCustomRestrictor(pConfig); if (customRestrictor != null) { logHandler.info("Using restrictor " + customRestrictor.getClass().getCanonicalName()); return customRestrictor; } String location = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.POLICY_LOCATION)); try { Restrictor ret = RestrictorFactory.lookupPolicyRestrictor(location); if (ret != null) { logHandler.info("Using policy access restrictor " + location); return ret; } else { logHandler.info("No access restrictor found, access to any MBean is allowed"); return new AllowAllRestrictor(); } } catch (IOException e) { logHandler.error("Error while accessing access restrictor at " + location + ". Denying all access to MBeans for security reasons. Exception: " + e, e); return new DenyAllRestrictor(); } }
public static Restrictor createRestrictor(Configuration pConfig, LogHandler logHandler) { Restrictor customRestrictor = createCustomRestrictor(pConfig); if (customRestrictor != null) { logHandler.info("Using restrictor " + customRestrictor.getClass().getCanonicalName()); return customRestrictor; } String location = NetworkUtil.replaceExpression(pConfig.get(ConfigKey.POLICY_LOCATION)); try { Restrictor ret = RestrictorFactory.lookupPolicyRestrictor(location); if (ret != null) { logHandler.info("Using policy access restrictor " + location); return ret; } else { logHandler.info("No access restrictor found, access to any MBean is allowed"); return new AllowAllRestrictor(); } } catch (IOException e) { logHandler.error("Error while accessing access restrictor at " + location + ". Denying all access to MBeans for security reasons. Exception: " + e, e); return new DenyAllRestrictor(); } }