From 7e7f02f000a476e525c866dd8d7f5328ddd83b6b Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 02 Mar 2015 14:59:47 +0000
Subject: [PATCH] CR-5578 fix OPENDJ-821: org.opends.server.protocols.jmx.client-unknown
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java | 2
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/JmxConnectionHandler.java | 10 +++++
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java | 2
opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/JMXConnectionHandlerConfiguration.xml | 12 ++---
opendj-server-legacy/src/admin/defn/org/opends/server/admin/std/JMXConnectionHandlerConfiguration.xml | 12 ++---
opendj-server-legacy/src/admin/messages/JMXConnectionHandlerCfgDefn.properties | 4 +-
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java | 35 ++++++++++-------
opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java | 13 ++----
8 files changed, 48 insertions(+), 42 deletions(-)
diff --git a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/JMXConnectionHandlerConfiguration.xml b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/JMXConnectionHandlerConfiguration.xml
index 975e4bf..7466fd2 100644
--- a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/JMXConnectionHandlerConfiguration.xml
+++ b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/JMXConnectionHandlerConfiguration.xml
@@ -23,7 +23,7 @@
!
!
! Copyright 2007-2009 Sun Microsystems, Inc.
- ! Portions Copyright 2013 ForgeRock AS.
+ ! Portions Copyright 2013-2015 ForgeRock AS.
! -->
<adm:managed-object name="jmx-connection-handler"
plural-name="jmx-connection-handlers"
@@ -67,16 +67,14 @@
</adm:defined>
</adm:default-behavior>
</adm:property-override>
- <adm:property name="listen-address" multi-valued="true" read-only="true">
+ <adm:property name="listen-address" multi-valued="false">
<adm:synopsis>
- Specifies the address or set of addresses on which this
+ Specifies the address on which this
<adm:user-friendly-name />
- should listen for connections from JMX clients. However JMX/RMI
- doesn't allow this, and this property cannot be set.
+ should listen for connections from JMX clients.
</adm:synopsis>
<adm:description>
- Multiple addresses may be provided as separate values for this
- attribute. If no values are provided, then the
+ If no value is provided, then the
<adm:user-friendly-name />
listens on all interfaces.
</adm:description>
diff --git a/opendj-server-legacy/src/admin/defn/org/opends/server/admin/std/JMXConnectionHandlerConfiguration.xml b/opendj-server-legacy/src/admin/defn/org/opends/server/admin/std/JMXConnectionHandlerConfiguration.xml
index 6f7d361..3b31a2f 100644
--- a/opendj-server-legacy/src/admin/defn/org/opends/server/admin/std/JMXConnectionHandlerConfiguration.xml
+++ b/opendj-server-legacy/src/admin/defn/org/opends/server/admin/std/JMXConnectionHandlerConfiguration.xml
@@ -23,7 +23,7 @@
!
!
! Copyright 2007-2009 Sun Microsystems, Inc.
- ! Portions Copyright 2013 ForgeRock AS.
+ ! Portions Copyright 2013-2015 ForgeRock AS.
! -->
<adm:managed-object name="jmx-connection-handler"
plural-name="jmx-connection-handlers"
@@ -67,16 +67,14 @@
</adm:defined>
</adm:default-behavior>
</adm:property-override>
- <adm:property name="listen-address" multi-valued="true" read-only="true">
+ <adm:property name="listen-address" multi-valued="false">
<adm:synopsis>
- Specifies the address or set of addresses on which this
+ Specifies the address on which this
<adm:user-friendly-name />
- should listen for connections from JMX clients. However JMX/RMI
- doesn't allow this, and this property cannot be set.
+ should listen for connections from JMX clients.
</adm:synopsis>
<adm:description>
- Multiple addresses may be provided as separate values for this
- attribute. If no values are provided, then the
+ If no value is provided, then the
<adm:user-friendly-name />
listens on all interfaces.
</adm:description>
diff --git a/opendj-server-legacy/src/admin/messages/JMXConnectionHandlerCfgDefn.properties b/opendj-server-legacy/src/admin/messages/JMXConnectionHandlerCfgDefn.properties
index 3544453..a685634 100644
--- a/opendj-server-legacy/src/admin/messages/JMXConnectionHandlerCfgDefn.properties
+++ b/opendj-server-legacy/src/admin/messages/JMXConnectionHandlerCfgDefn.properties
@@ -15,8 +15,8 @@
property.key-manager-provider.synopsis=Specifies the name of the key manager that should be used with this JMX Connection Handler .
property.key-manager-provider.requires-admin-action.synopsis=Changes to this property take effect immediately, but only for subsequent attempts to access the key manager provider for associated client connections.
property.key-manager-provider.syntax.aggregation.constraint-synopsis=The referenced key manager provider must be enabled when the JMX Connection Handler is enabled and configured to use SSL.
-property.listen-address.synopsis=Specifies the address or set of addresses on which this JMX Connection Handler should listen for connections from JMX clients. However JMX/RMI doesn't allow this, and this property cannot be set.
-property.listen-address.description=Multiple addresses may be provided as separate values for this attribute. If no values are provided, then the JMX Connection Handler listens on all interfaces.
+property.listen-address.synopsis=Specifies the address on which this JMX Connection Handler should listen for connections from JMX clients.
+property.listen-address.description=If no value is provided, then the JMX Connection Handler listens on all interfaces.
property.listen-port.synopsis=Specifies the port number on which the JMX Connection Handler will listen for connections from clients.
property.listen-port.description=Only a single port number may be provided.
property.rmi-port.synopsis=Specifies the port number on which the JMX RMI service will listen for connections from clients. A value of 0 indicates the service to choose a port of its own.
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
index 4145512..3dae06e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -944,7 +944,7 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.JMX;
}
- addAll(addresses, jmx.getListenAddress());
+ addresses.add(jmx.getListenAddress());
port = jmx.getListenPort();
}
else if (connHandler instanceof LDIFConnectionHandlerCfgClient)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index 9d72900..a8de7c6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -450,7 +450,7 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.JMX;
}
- addAll(addresses, jmx.getListenAddress());
+ addresses.add(jmx.getListenAddress());
port = jmx.getListenPort();
}
else if (connHandler instanceof LDIFConnectionHandlerCfg)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/JmxConnectionHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/JmxConnectionHandler.java
index 535f9b0..58d0bce 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/JmxConnectionHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/JmxConnectionHandler.java
@@ -31,6 +31,7 @@
import static org.opends.server.util.StaticUtils.*;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.LinkedList;
@@ -238,6 +239,15 @@
}
+ /**
+ * Get the JMX connection handler's listen address.
+ *
+ * @return Returns the JMX connection handler's listen address.
+ */
+ public InetAddress getListenAddress()
+ {
+ return currentConfig.getListenAddress();
+ }
/**
* Get the JMX connection handler's listen port.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
index 6056e0e..3c78b82 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
@@ -22,13 +22,14 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014-2015 ForgeRock AS.
*/
package org.opends.server.protocols.jmx;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.ServerSocket;
import java.rmi.server.RMIServerSocketFactory;
-import java.rmi.server.RMISocketFactory;
/**
@@ -52,29 +53,33 @@
*/
public class OpendsRmiServerSocketFactory implements RMIServerSocketFactory
{
+ /** The address to listen on, which could be INADDR_ANY. */
+ private final InetAddress listenAddress;
+
+ /** The Created ServerSocket. */
+ ServerSocket serverSocket;
/**
- * The Platform RMISocketFactory.
+ * Create a new socket factory which will listen on the specified address.
+ *
+ * @param listenAddress The address to listen on.
*/
- private RMIServerSocketFactory ssf =
- RMISocketFactory.getDefaultSocketFactory() ;
-
- /*
- * The Created ServerSocket.
- */
- ServerSocket serverSocket ;
+ public OpendsRmiServerSocketFactory(InetAddress listenAddress)
+ {
+ this.listenAddress = listenAddress;
+ }
/**
- * Create a server socket on the specified port
- * (port 0 indicates an anonymous port).
+ * Create a server socket on the specified port, listening on the address
+ * passed in the constructor. (port 0 indicates an anonymous port).
+ *
* @param port the port number
* @return the server socket on the specified port
* @throws IOException if an I/O error occurs during server socket creation
*/
- public ServerSocket createServerSocket(int port) throws IOException
+ public ServerSocket createServerSocket(int port) throws IOException
{
- serverSocket = ssf.createServerSocket(port) ;
- return serverSocket ;
+ return new ServerSocket(port, 100, listenAddress);
}
/**
@@ -84,6 +89,6 @@
*/
protected void close() throws IOException
{
- serverSocket.close() ;
+ serverSocket.close();
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java
index b14d48a..e4d3502 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/RmiConnector.java
@@ -27,6 +27,7 @@
package org.opends.server.protocols.jmx;
import java.io.IOException;
+import java.net.InetAddress;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@@ -76,13 +77,6 @@
*/
private MBeanServer mbs;
-
- /**
- * the client address to connect to the common registry. Note that a
- * remote client should use the correct IP address.
- */
- private String registryClientAddress = "0.0.0.0";
-
/**
* The associated JMX Connection Handler.
*/
@@ -198,6 +192,7 @@
*/
private void startCommonRegistry() throws Exception
{
+ final InetAddress listenAddress = jmxConnectionHandler.getListenAddress();
int registryPort = jmxConnectionHandler.getListenPort();
//
@@ -213,7 +208,7 @@
// TODO Not yet implemented: If the host has several interfaces
if (registry == null)
{
- rmiSsf = new OpendsRmiServerSocketFactory();
+ rmiSsf = new OpendsRmiServerSocketFactory(listenAddress);
registry = LocateRegistry.createRegistry(registryPort, null, rmiSsf);
}
}
@@ -367,7 +362,7 @@
// Create the JMX Service URL
String uri = "org.opends.server.protocols.jmx.client-unknown";
String serviceUrl = "service:jmx:rmi:///jndi/rmi://"
- + registryClientAddress + ":" + jmxConnectionHandler.getListenPort()
+ + jmxConnectionHandler.getListenAddress().getHostName() + ":" + jmxConnectionHandler.getListenPort()
+ "/" + uri;
JMXServiceURL url = new JMXServiceURL(serviceUrl);
--
Gitblit v1.10.0