equal
deleted
inserted
replaced
78 import sun.management.Agent; |
78 import sun.management.Agent; |
79 import sun.management.AgentConfigurationError; |
79 import sun.management.AgentConfigurationError; |
80 import static sun.management.AgentConfigurationError.*; |
80 import static sun.management.AgentConfigurationError.*; |
81 import sun.management.ConnectorAddressLink; |
81 import sun.management.ConnectorAddressLink; |
82 import sun.management.FileSystem; |
82 import sun.management.FileSystem; |
83 import sun.management.snmp.util.MibLogger; |
83 import com.sun.jmx.remote.util.ClassLogger; |
84 |
84 |
85 import com.sun.jmx.remote.internal.RMIExporter; |
85 import com.sun.jmx.remote.internal.RMIExporter; |
86 import com.sun.jmx.remote.security.JMXPluggableAuthenticator; |
86 import com.sun.jmx.remote.security.JMXPluggableAuthenticator; |
87 |
87 |
88 /** |
88 /** |
113 |
113 |
114 public static final String PORT = |
114 public static final String PORT = |
115 "com.sun.management.jmxremote.port"; |
115 "com.sun.management.jmxremote.port"; |
116 public static final String CONFIG_FILE_NAME = |
116 public static final String CONFIG_FILE_NAME = |
117 "com.sun.management.config.file"; |
117 "com.sun.management.config.file"; |
|
118 public static final String USE_LOCAL_ONLY = |
|
119 "com.sun.management.jmxremote.local.only"; |
118 public static final String USE_SSL = |
120 public static final String USE_SSL = |
119 "com.sun.management.jmxremote.ssl"; |
121 "com.sun.management.jmxremote.ssl"; |
120 public static final String USE_REGISTRY_SSL = |
122 public static final String USE_REGISTRY_SSL = |
121 "com.sun.management.jmxremote.registry.ssl"; |
123 "com.sun.management.jmxremote.registry.ssl"; |
122 public static final String USE_AUTHENTICATION = |
124 public static final String USE_AUTHENTICATION = |
382 accessFileName = props.getProperty(PropertyNames.ACCESS_FILE_NAME, |
384 accessFileName = props.getProperty(PropertyNames.ACCESS_FILE_NAME, |
383 getDefaultFileName(DefaultValues.ACCESS_FILE_NAME)); |
385 getDefaultFileName(DefaultValues.ACCESS_FILE_NAME)); |
384 checkAccessFile(accessFileName); |
386 checkAccessFile(accessFileName); |
385 } |
387 } |
386 |
388 |
387 if (log.isDebugOn()) { |
389 if (log.debugOn()) { |
388 log.debug("initialize", |
390 log.debug("initialize", |
389 Agent.getText("jmxremote.ConnectorBootstrap.initialize") + |
391 Agent.getText("jmxremote.ConnectorBootstrap.initialize") + |
390 "\n\t" + PropertyNames.PORT + "=" + port + |
392 "\n\t" + PropertyNames.PORT + "=" + port + |
391 "\n\t" + PropertyNames.USE_SSL + "=" + useSsl + |
393 "\n\t" + PropertyNames.USE_SSL + "=" + useSsl + |
392 "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl + |
394 "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl + |
475 } |
477 } |
476 |
478 |
477 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); |
479 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); |
478 try { |
480 try { |
479 JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0); |
481 JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0); |
|
482 // Do we accept connections from local interfaces only? |
|
483 Properties props = Agent.getManagementProperties(); |
|
484 if (props == null) { |
|
485 props = new Properties(); |
|
486 } |
|
487 String useLocalOnlyStr = props.getProperty( |
|
488 PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY); |
|
489 boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue(); |
|
490 if (useLocalOnly) { |
|
491 env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, |
|
492 new LocalRMIServerSocketFactory()); |
|
493 } |
480 JMXConnectorServer server = |
494 JMXConnectorServer server = |
481 JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); |
495 JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); |
482 server.start(); |
496 server.start(); |
483 return server; |
497 return server; |
484 } catch (Exception e) { |
498 } catch (Exception e) { |
762 * This class cannot be instantiated. |
776 * This class cannot be instantiated. |
763 **/ |
777 **/ |
764 private ConnectorBootstrap() { |
778 private ConnectorBootstrap() { |
765 } |
779 } |
766 |
780 |
767 // XXX Revisit: should probably clone this MibLogger.... |
781 private static final ClassLogger log = |
768 private static final MibLogger log = |
782 new ClassLogger(ConnectorBootstrap.class.getPackage().getName(), |
769 new MibLogger(ConnectorBootstrap.class); |
783 "ConnectorBootstrap"); |
770 } |
784 } |