karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject git commit: [KARAF-2989]rmiServerHost configruation doesn't work on Karaf 3.x
Date Tue, 20 May 2014 03:51:08 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 133d8c139 -> ee022a275


[KARAF-2989]rmiServerHost configruation doesn't work on Karaf 3.x


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ee022a27
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ee022a27
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ee022a27

Branch: refs/heads/karaf-3.0.x
Commit: ee022a2757f470bab295b599007e55c9f392051c
Parents: 133d8c1
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Tue May 20 11:43:05 2014 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Tue May 20 11:43:05 2014 +0800

----------------------------------------------------------------------
 .../etc/org.apache.karaf.management.cfg         | 12 +++++++-
 .../management/ConnectorServerFactory.java      | 29 +++++++++++++++++---
 2 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/ee022a27/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.management.cfg
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.management.cfg
b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.management.cfg
index 12d026a..16a0c08 100644
--- a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.management.cfg
+++ b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.management.cfg
@@ -27,11 +27,21 @@
 rmiRegistryPort = 1099
 
 #
+# Host for RMI registry
+#
+rmiRegistryHost = 0.0.0.0
+
+#
 # Port number for RMI server connection
 #
 rmiServerPort = 44444
 
 #
+# Host for RMI server
+#
+rmiServerHost = 0.0.0.0
+
+#
 # Name of the JAAS realm used for authentication
 #
 jmxRealm = karaf
@@ -39,7 +49,7 @@ jmxRealm = karaf
 #
 # The service URL for the JMXConnectorServer
 #
-serviceUrl = service:jmx:rmi://0.0.0.0:${rmiServerPort}/jndi/rmi://0.0.0.0:${rmiRegistryPort}/karaf-${karaf.name}
+serviceUrl = service:jmx:rmi://${rmiServerHost}:${rmiServerPort}/jndi/rmi://${rmiRegistryHost}:${rmiRegistryPort}/karaf-${karaf.name}
 
 #
 # Whether any threads started for the JMXConnectorServer should be started as daemon threads

http://git-wip-us.apache.org/repos/asf/karaf/blob/ee022a27/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
----------------------------------------------------------------------
diff --git a/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
b/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
index afb7fb4..f962427 100644
--- a/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
+++ b/management/server/src/main/java/org/apache/karaf/management/ConnectorServerFactory.java
@@ -218,7 +218,7 @@ public class ConnectorServerFactory {
             throw new IllegalArgumentException("server must be set");
         }
         JMXServiceURL url = new JMXServiceURL(this.serviceUrl);
-
+        setupKarafRMIServerSocketFactory();
         if ( isClientAuth() ) {
             this.secured = true;
         }
@@ -292,7 +292,7 @@ public class ConnectorServerFactory {
     private void setupSsl() throws GeneralSecurityException {
 
         SSLServerSocketFactory sssf = keystoreManager.createSSLServerFactory(null, secureProtocol,
algorithm, keyStore, keyAlias, trustStore,keyStoreAvailabilityTimeout);
-        RMIServerSocketFactory rssf = new KarafSslRMIServerSocketFactory(sssf, this.isClientAuth());
+        RMIServerSocketFactory rssf = new KarafSslRMIServerSocketFactory(sssf, this.isClientAuth(),
getRmiServerHost());
         RMIClientSocketFactory rcsf = new SslRMIClientSocketFactory();
         environment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rssf);
         environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rcsf);
@@ -300,20 +300,41 @@ public class ConnectorServerFactory {
         //env.put("com.sun.jndi.rmi.factory.socket", rcsf);
     }
 
+    private void setupKarafRMIServerSocketFactory() {
+        RMIServerSocketFactory rmiServerSocketFactory = new KarafRMIServerSocketFactory(getRmiServerHost());
+        environment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rmiServerSocketFactory);
+    }
+
     private static class KarafSslRMIServerSocketFactory implements RMIServerSocketFactory
{
         private SSLServerSocketFactory sssf;
         private boolean clientAuth;
+        private String rmiServerHost;
 
-        public KarafSslRMIServerSocketFactory(SSLServerSocketFactory sssf, boolean clientAuth)
{
+        public KarafSslRMIServerSocketFactory(SSLServerSocketFactory sssf, boolean clientAuth,
String rmiServerHost) {
             this.sssf = sssf;
             this.clientAuth = clientAuth;
+            this.rmiServerHost = rmiServerHost;
         }
 
         public ServerSocket createServerSocket(int port) throws IOException {
-            SSLServerSocket ss = (SSLServerSocket) sssf.createServerSocket(port);
+            SSLServerSocket ss = (SSLServerSocket) sssf.createServerSocket(port, 50, InetAddress.getByName(rmiServerHost));
             ss.setNeedClientAuth(clientAuth);
             return ss;
         }
     }
 
+    private static class KarafRMIServerSocketFactory implements RMIServerSocketFactory {
+        private String rmiServerHost;
+
+        public KarafRMIServerSocketFactory(String rmiServerHost) {
+            this.rmiServerHost = rmiServerHost;
+        }
+
+        public ServerSocket createServerSocket(int port) throws IOException {
+            ServerSocket serverSocket = (ServerSocket) ServerSocketFactory.getDefault().createServerSocket(port,
50, InetAddress.getByName(rmiServerHost));
+            return serverSocket;
+        }
+    }
+
+
 }


Mime
View raw message