View | Details | Raw Unified | Return to bug 55017
Collapse All | Expand All

(-)webapps/docs/config/listeners.xml (+4 lines)
Lines 433-438 Link Here
433
        <p>The port to be used by the Platform JMX/RMI server.</p>
433
        <p>The port to be used by the Platform JMX/RMI server.</p>
434
      </attribute>
434
      </attribute>
435
435
436
      <attribute name="rmiBindAddress" required="false">
437
        <p>Address of interface to be used by JMX/RMI server. This option is incompatible with <code>com.sun.management.jmxremote.ssl = true</code>.</p>
438
      </attribute>
439
436
      <attribute name="useLocalPorts" required="false">
440
      <attribute name="useLocalPorts" required="false">
437
        <p>Should any clients using these ports be forced to use local ports to
441
        <p>Should any clients using these ports be forced to use local ports to
438
        connect to the the JMX/RMI server. This is useful when tunnelling
442
        connect to the the JMX/RMI server. This is useful when tunnelling
(-)java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (-3 / +50 lines)
Lines 21-27 Link Here
21
import java.io.Serializable;
21
import java.io.Serializable;
22
import java.lang.management.ManagementFactory;
22
import java.lang.management.ManagementFactory;
23
import java.net.MalformedURLException;
23
import java.net.MalformedURLException;
24
import java.net.UnknownHostException;
24
import java.net.Socket;
25
import java.net.Socket;
26
import java.net.ServerSocket;
27
import java.net.InetAddress;
25
import java.rmi.RemoteException;
28
import java.rmi.RemoteException;
26
import java.rmi.registry.LocateRegistry;
29
import java.rmi.registry.LocateRegistry;
27
import java.rmi.server.RMIClientSocketFactory;
30
import java.rmi.server.RMIClientSocketFactory;
Lines 61-66 Link Here
61
    protected static final StringManager sm =
64
    protected static final StringManager sm =
62
        StringManager.getManager(Constants.Package);
65
        StringManager.getManager(Constants.Package);
63
66
67
    protected String rmiBindAddress = null;
64
    protected int rmiRegistryPortPlatform = -1;
68
    protected int rmiRegistryPortPlatform = -1;
65
    protected int rmiServerPortPlatform = -1;
69
    protected int rmiServerPortPlatform = -1;
66
    protected boolean rmiSSL = true;
70
    protected boolean rmiSSL = true;
Lines 76-81 Link Here
76
    protected JMXConnectorServer csPlatform = null;
80
    protected JMXConnectorServer csPlatform = null;
77
    
81
    
78
    /**
82
    /**
83
     * Get the inet address on which the Platform RMI server is exported.
84
     * @return The textual representation of inet address
85
     */
86
    public String getRmiBindAddress() {
87
        return rmiBindAddress;
88
    }
89
90
    /**
91
     * Set the inet address on which the Platform RMI server is exported.
92
     * @param theRmiBindAddress The textual representation of inet address
93
     */
94
    public void setRmiBindAddress(String theRmiBindAddress) {
95
        rmiBindAddress = theRmiBindAddress;
96
    }
97
98
    /**
79
     * Get the port on which the Platform RMI server is exported. This is the
99
     * Get the port on which the Platform RMI server is exported. This is the
80
     * port that is normally chosen by the RMI stack.
100
     * port that is normally chosen by the RMI stack.
81
     * @return The port number
101
     * @return The port number
Lines 189-199 Link Here
189
209
190
            // Configure SSL for RMI connection if required
210
            // Configure SSL for RMI connection if required
191
            if (rmiSSL) {
211
            if (rmiSSL) {
212
                if (rmiBindAddress != null) {
213
                    throw new IllegalStateException(sm.getString("jmxRemoteLifecycleListener.sslIncompatibleWithRmiBindAddress"));
214
                }
215
192
                csf = new SslRMIClientSocketFactory();
216
                csf = new SslRMIClientSocketFactory();
193
                ssf = new SslRMIServerSocketFactory(ciphers, protocols,
217
                ssf = new SslRMIServerSocketFactory(ciphers, protocols,
194
                            clientAuth);
218
                            clientAuth);
195
            }
219
            }
196
            
220
            
221
            // Force server bind address if required
222
            if (rmiBindAddress != null) {
223
                try {
224
                    ssf = new RmiServerBindSocketFactory(InetAddress.getByName(rmiBindAddress));
225
                } catch (UnknownHostException e) {
226
                    log.error(sm.getString("jmxRemoteLifecycleListener.invalidRmiBindAddress", rmiBindAddress), e);
227
                }
228
            }
229
197
            // Force the use of local ports if required
230
            // Force the use of local ports if required
198
            if (useLocalPorts) {
231
            if (useLocalPorts) {
199
                csf = new RmiClientLocalhostSocketFactory(csf);
232
                csf = new RmiClientLocalhostSocketFactory(csf);
Lines 219-225 Link Here
219
252
220
            // Create the Platform server
253
            // Create the Platform server
221
            csPlatform = createServer("Platform", rmiRegistryPortPlatform,
254
            csPlatform = createServer("Platform", rmiRegistryPortPlatform,
222
                    rmiServerPortPlatform, env,
255
                    rmiServerPortPlatform, env, csf, ssf,
223
                    ManagementFactory.getPlatformMBeanServer());
256
                    ManagementFactory.getPlatformMBeanServer());
224
            
257
            
225
        } else if (Lifecycle.STOP_EVENT == event.getType()) {
258
        } else if (Lifecycle.STOP_EVENT == event.getType()) {
Lines 229-239 Link Here
229
262
230
    private JMXConnectorServer createServer(String serverName,
263
    private JMXConnectorServer createServer(String serverName,
231
            int theRmiRegistryPort, int theRmiServerPort,
264
            int theRmiRegistryPort, int theRmiServerPort,
232
            HashMap<String,Object> theEnv, MBeanServer theMBeanServer) {
265
            HashMap<String,Object> theEnv, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, MBeanServer theMBeanServer) {
233
        
266
        
234
        // Create the RMI registry
267
        // Create the RMI registry
235
        try {
268
        try {
236
            LocateRegistry.createRegistry(theRmiRegistryPort);
269
            LocateRegistry.createRegistry(theRmiRegistryPort, csf, ssf);
237
        } catch (RemoteException e) {
270
        } catch (RemoteException e) {
238
            log.error(sm.getString(
271
            log.error(sm.getString(
239
                    "jmxRemoteLifecycleListener.createRegistryFailed",
272
                    "jmxRemoteLifecycleListener.createRegistryFailed",
Lines 311-314 Link Here
311
344
312
        
345
        
313
    }
346
    }
347
348
    public static class RmiServerBindSocketFactory
349
    implements RMIServerSocketFactory {
350
        private final InetAddress bindAddress;
351
352
        public RmiServerBindSocketFactory(InetAddress address) {
353
            bindAddress = address;
314
}
354
}
355
356
        public ServerSocket createServerSocket(int port) throws IOException  {
357
            return new ServerSocket(port, 0, bindAddress);
358
        }
359
360
    }
361
}
(-)java/org/apache/catalina/mbeans/LocalStrings.properties (+2 lines)
Lines 18-20 Link Here
18
jmxRemoteLifecycleListener.destroyServerFailed=The JMX connector server could not be stopped for the {0} server
18
jmxRemoteLifecycleListener.destroyServerFailed=The JMX connector server could not be stopped for the {0} server
19
jmxRemoteLifecycleListener.invalidURL=The JMX Service URL requested for the {0} server, "{1}", was invalid
19
jmxRemoteLifecycleListener.invalidURL=The JMX Service URL requested for the {0} server, "{1}", was invalid
20
jmxRemoteLifecycleListener.start=The JMX Remote Listener has configured the registry on port {0} and the server on port {1} for the {2} server
20
jmxRemoteLifecycleListener.start=The JMX Remote Listener has configured the registry on port {0} and the server on port {1} for the {2} server
21
jmxRemoteLifecycleListener.sslIncompatibleWithRmiBindAddress=rmiBindAddress is incompatible with com.sun.management.jmxremote.ssl = true
22
jmxRemoteLifecycleListener.invalidRmiBindAddress=Invalid RMI bind address "{0}"

Return to bug 55017