geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r726624 - in /geronimo/server/trunk/framework/modules: geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/
Date Mon, 15 Dec 2008 06:23:17 GMT
Author: gawor
Date: Sun Dec 14 22:23:17 2008
New Revision: 726624

URL: http://svn.apache.org/viewvc?rev=726624&view=rev
Log:
Support for binding to a specific ip address for RMI registry and JMX connectors (GERONIMO-4442)

Added:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
  (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java
    geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXSecureConnector.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/RMIRegistryService.java

Modified: geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java?rev=726624&r1=726623&r2=726624&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java
Sun Dec 14 22:23:17 2008
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.rmi.server.RMIServerSocketFactory;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,13 +28,15 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
+import javax.management.remote.rmi.RMIConnectorServer;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.rmi.GeronimoRMIServerSocketFactory;
 import org.apache.geronimo.system.jmx.MBeanServerReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A connector that supports the server side of JSR 160 JMX Remoting.
@@ -183,6 +186,8 @@
         } else {
             log.warn("Starting unauthenticating JMXConnector for " + jmxServiceURL);
         }
+        RMIServerSocketFactory serverSocketFactory = new GeronimoRMIServerSocketFactory(host);
+        env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverSocketFactory);
         server = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, env, mbeanServer);
         NotificationFilterSupport filter = new NotificationFilterSupport();
         filter.enableType(JMXConnectionNotification.OPENED);

Modified: geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXSecureConnector.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXSecureConnector.java?rev=726624&r1=726623&r2=726624&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXSecureConnector.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXSecureConnector.java
Sun Dec 14 22:23:17 2008
@@ -17,7 +17,9 @@
 package org.apache.geronimo.jmxremoting;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.ServerSocket;
+import java.net.UnknownHostException;
 import java.rmi.server.RMIClientSocketFactory;
 import java.rmi.server.RMIServerSocketFactory;
 import java.util.HashMap;
@@ -141,7 +143,7 @@
         }
         
         SSLServerSocketFactory sssf = keystoreManager.createSSLServerFactory(null, secureProtocol,
algorithm, keyStore, keyAlias, trustStore, classLoader);
-        RMIServerSocketFactory rssf = new GeronimoSslRMIServerSocketFactory(sssf, clientAuth);
+        RMIServerSocketFactory rssf = new GeronimoSslRMIServerSocketFactory(sssf, host, clientAuth);
         RMIClientSocketFactory rcsf = new SslRMIClientSocketFactory();
         env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rssf);
         env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rcsf);
@@ -159,14 +161,16 @@
     private static class GeronimoSslRMIServerSocketFactory implements RMIServerSocketFactory
{
         private SSLServerSocketFactory sssf;
         private boolean clientAuth;
+        private InetAddress bindAddress;
         
-        public GeronimoSslRMIServerSocketFactory(SSLServerSocketFactory sssf, boolean clientAuth)
{
+        public GeronimoSslRMIServerSocketFactory(SSLServerSocketFactory sssf, String bindHost,
boolean clientAuth) throws UnknownHostException {
             this.sssf = sssf;
+            this.bindAddress = InetAddress.getByName(bindHost);
             this.clientAuth = clientAuth;
         }
         
         public ServerSocket createServerSocket(int port) throws IOException {
-            SSLServerSocket ss = (SSLServerSocket) sssf.createServerSocket(port);
+            SSLServerSocket ss = (SSLServerSocket) sssf.createServerSocket(port, 0, this.bindAddress);
             ss.setNeedClientAuth(clientAuth);
             return ss;
         }

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java?rev=726624&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
Sun Dec 14 22:23:17 2008
@@ -0,0 +1,40 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.rmi;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+import java.rmi.server.RMIServerSocketFactory;
+
+public class GeronimoRMIServerSocketFactory implements RMIServerSocketFactory {
+
+    private InetAddress bindAddress;
+
+    public GeronimoRMIServerSocketFactory(String bindHost) throws UnknownHostException {
+        this.bindAddress = InetAddress.getByName(bindHost);
+    }
+    
+    public ServerSocket createServerSocket(int port) throws IOException {
+        ServerSocket socket = new ServerSocket(port, 0, this.bindAddress);
+        return socket;
+    }
+    
+}
+    
\ No newline at end of file

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/GeronimoRMIServerSocketFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/RMIRegistryService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/RMIRegistryService.java?rev=726624&r1=726623&r2=726624&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/RMIRegistryService.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/rmi/RMIRegistryService.java
Sun Dec 14 22:23:17 2008
@@ -18,6 +18,9 @@
 
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RMISocketFactory;
 import java.rmi.server.UnicastRemoteObject;
 import java.net.InetSocketAddress;
 
@@ -61,7 +64,9 @@
 
     public void doStart() throws Exception {
         System.setProperty("java.rmi.server.RMIClassLoaderSpi",RMIClassLoaderSpiImpl.class.getName());
-        registry = LocateRegistry.createRegistry(port);
+        RMIClientSocketFactory socketFactory = RMISocketFactory.getDefaultSocketFactory();
+        RMIServerSocketFactory serverSocketFactory = new GeronimoRMIServerSocketFactory(host);
+        registry = LocateRegistry.createRegistry(port, socketFactory, serverSocketFactory);
         log.debug("Started RMI Registry on port: {}", port);
     }
 



Mime
View raw message