You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/11/05 19:29:44 UTC
svn commit: r1031699 - in /james/server/trunk: ./ container-spring/
container-spring/src/main/config/james/
container-spring/src/main/java/org/apache/james/container/spring/
Author: norman
Date: Fri Nov 5 18:29:43 2010
New Revision: 1031699
URL: http://svn.apache.org/viewvc?rev=1031699&view=rev
Log:
Bind JMX to localhost by default and disable user/pass for it (JAMES-1104)
Added:
james/server/trunk/container-spring/src/main/config/james/jmx.properties
Removed:
james/server/trunk/container-spring/src/main/config/james/jmx.access
james/server/trunk/container-spring/src/main/config/james/jmx.password
Modified:
james/server/trunk/container-spring/pom.xml
james/server/trunk/container-spring/src/main/config/james/database.properties
james/server/trunk/container-spring/src/main/config/james/spring-beans.xml
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/RestrictingRMISocketFactory.java
james/server/trunk/pom.xml
Modified: james/server/trunk/container-spring/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/pom.xml?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/container-spring/pom.xml (original)
+++ james/server/trunk/container-spring/pom.xml Fri Nov 5 18:29:43 2010
@@ -146,58 +146,46 @@
</property>
<property>
<name>wrapper.java.additional.4</name>
- <value>${jmx.system-property3}</value>
- </property>
- <property>
- <name>wrapper.java.additional.5</name>
- <value>${jmx.system-property4}</value>
- </property>
- <property>
- <name>wrapper.java.additional.6</name>
- <value>${jmx.system-property5}</value>
- </property>
- <property>
- <name>wrapper.java.additional.7</name>
<value>${javamail.system-property1}</value>
</property>
<property>
- <name>wrapper.java.additional.8</name>
+ <name>wrapper.java.additional.5</name>
<value>${javamail.system-property2}</value>
</property>
<property>
- <name>wrapper.java.additional.9</name>
+ <name>wrapper.java.additional.6</name>
<value>${javamail.system-property3}</value>
</property>
<property>
- <name>wrapper.java.additional.10</name>
+ <name>wrapper.java.additional.7</name>
<value>${javamail.system-property4}</value>
</property>
<property>
- <name>wrapper.java.additional.11</name>
+ <name>wrapper.java.additional.8</name>
<value>${javamail.system-property5}</value>
</property>
<property>
- <name>wrapper.java.additional.12</name>
+ <name>wrapper.java.additional.9</name>
<value>${javamail.system-property6}</value>
</property>
<property>
- <name>wrapper.java.additional.13</name>
+ <name>wrapper.java.additional.10</name>
<value>${javamail.system-property7}</value>
</property>
<property>
- <name>wrapper.java.additional.14</name>
+ <name>wrapper.java.additional.11</name>
<value>${javamail.system-property8}</value>
</property>
<property>
- <name>wrapper.java.additional.15</name>
+ <name>wrapper.java.additional.12</name>
<value>${javamail.system-property9}</value>
</property>
<property>
- <name>wrapper.java.additional.16</name>
+ <name>wrapper.java.additional.13</name>
<value>${javamail.system-property10}</value>
</property>
<property>
- <name>wrapper.java.additional.17</name>
+ <name>wrapper.java.additional.14</name>
<value>${james.system-property1}</value>
</property>
</configuration>
Modified: james/server/trunk/container-spring/src/main/config/james/database.properties
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/database.properties?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/database.properties (original)
+++ james/server/trunk/container-spring/src/main/config/james/database.properties Fri Nov 5 18:29:43 2010
@@ -1,19 +1,37 @@
-
-# Use derby as default
-database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-database.url=jdbc:derby:../var/derbydb;create=true
-database.username=app
-database.password=app
-
-# Supported adapters are:
-# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
-vendorAdapter.database=DERBY
-
-# Use streaming for Blobs
-# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
-# it.
-#
-# See:
-# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming
-#
+# 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.
+#
+
+
+# Use derby as default
+database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
+database.url=jdbc:derby:../var/derbydb;create=true
+database.username=app
+database.password=app
+
+# Supported adapters are:
+# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
+vendorAdapter.database=DERBY
+
+# Use streaming for Blobs
+# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
+# it.
+#
+# See:
+# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming
+#
openjpa.streaming=false
\ No newline at end of file
Added: james/server/trunk/container-spring/src/main/config/james/jmx.properties
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/jmx.properties?rev=1031699&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/jmx.properties (added)
+++ james/server/trunk/container-spring/src/main/config/james/jmx.properties Fri Nov 5 18:29:43 2010
@@ -0,0 +1,24 @@
+# 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.
+#
+
+# Bind JMX only to this address. If you want to have it on every addresses just use 0.0.0.0
+jmx.address=127.0.0.1
+
+# Bind JMX only to this port
+jmx.port=9999
+
Modified: james/server/trunk/container-spring/src/main/config/james/spring-beans.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/spring-beans.xml?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/spring-beans.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/spring-beans.xml Fri Nov 5 18:29:43 2010
@@ -26,7 +26,34 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.5.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.4.1.xsd">
-
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="ignoreUnresolvablePlaceholders" value="true"/>
+ <property name="location" value="file://conf/jmx.properties"/>
+ </bean>
+
+ <!-- Make sure we can bind jmx sockets to a specific ipaddress -->
+ <!-- https://issues.apache.org/jira/browse/JAMES-1104 -->
+ <bean id="restrictedRmiSocketFactory" class="org.apache.james.container.spring.RestrictingRMISocketFactory">
+ <constructor-arg value="${jmx.address}"/>
+ </bean>
+
+ <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
+ <property name="port" value="${jmx.port}" />
+ <property name="serverSocketFactory" ref="restrictedRmiSocketFactory"/>
+ <property name="clientSocketFactory" ref="restrictedRmiSocketFactory"/>
+ </bean>
+
+ <bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServerFactoryBean" >
+ <property name="locateExistingServerIfPossible" value="true"/>
+ <property name="registerWithFactory" value="true"/>
+ </bean>
+
+ <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="registry">
+ <property name="objectName" value="connector:name=rmi" />
+ <property name="serviceUrl" value="service:jmx:rmi://${jmx.address}/jndi/rmi://${jmx.address}:${jmx.port}/jmxrmi" />
+ </bean>
+
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
@@ -51,10 +78,6 @@
</bean>
</property>
</bean>
-
- <bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServerFactoryBean" >
- <property name="locateExistingServerIfPossible" value="true"/>
- </bean>
<bean id="processormanagement" class="org.apache.james.mailetcontainer.lib.ProcessorManagement"/>
@@ -93,6 +116,7 @@
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name = "location" value="file://conf/database.properties"/>
</bean>
Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java (original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java Fri Nov 5 18:29:43 2010
@@ -19,7 +19,6 @@
package org.apache.james.container.spring;
import java.io.IOException;
-import java.rmi.server.RMISocketFactory;
/**
* Bootstraps James using a Spring container
@@ -27,10 +26,6 @@ import java.rmi.server.RMISocketFactory;
public class Main {
public static void main(String[] args) throws IOException {
- // Make sure we can bind jmx sockets to a specific ipaddress
- // https://issues.apache.org/jira/browse/JAMES-1104
- RMISocketFactory.setSocketFactory(new RestrictingRMISocketFactory());
-
final JamesServerApplicationContext context = new JamesServerApplicationContext(new String[] { "spring-beans.xml" });
context.registerShutdownHook();
}
Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/RestrictingRMISocketFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/RestrictingRMISocketFactory.java?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/RestrictingRMISocketFactory.java (original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/RestrictingRMISocketFactory.java Fri Nov 5 18:29:43 2010
@@ -1,56 +1,62 @@
-/****************************************************************
- * 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.james.container.spring;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.rmi.server.RMISocketFactory;
-
-public class RestrictingRMISocketFactory extends RMISocketFactory {
-
- private String address;
-
- public RestrictingRMISocketFactory() {
- address = System.getProperty("james.jmx.address");
- if (address == null) {
- address = "localhost";
- }
- }
-
- /**
- * Create a {@link ServerSocket} which is bound to an specific address and the given port.
- * The address can be specified by the System Property james.jmx.address. If none is given it will use
- * localhost
- */
- public ServerSocket createServerSocket(int port) throws IOException {
- ServerSocket socket = new ServerSocket();
- socket.bind(new InetSocketAddress(address, port));
- return socket;
- }
-
- /**
- * Create a new {@link Socket} for the given host and port
- */
- public Socket createSocket(String host, int port) throws IOException {
- return new Socket(host, port);
- }
-
-}
+/****************************************************************
+ * 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.james.container.spring;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+/**
+ * {@link RMISocketFactory} implementation which allow to bind JMX to a specific IP
+ *
+ */
+public class RestrictingRMISocketFactory extends RMISocketFactory {
+
+ private String address;
+
+ public RestrictingRMISocketFactory(String address) {
+ this.address = address;
+ }
+
+ public RestrictingRMISocketFactory() {
+ this("localhost");
+ }
+
+
+ /**
+ * Create a {@link ServerSocket} which is bound to an specific address and the given port.
+ * The address can be specified by the System Property james.jmx.address. If none is given it will use
+ * localhost
+ */
+ public ServerSocket createServerSocket(int port) throws IOException {
+ ServerSocket socket = new ServerSocket();
+ socket.bind(new InetSocketAddress(address, port));
+ return socket;
+ }
+
+ /**
+ * Create a new {@link Socket} for the given host and port
+ */
+ public Socket createSocket(String host, int port) throws IOException {
+ return new Socket(host, port);
+ }
+
+}
Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=1031699&r1=1031698&r2=1031699&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Fri Nov 5 18:29:43 2010
@@ -1252,11 +1252,8 @@
<!-- For more details see -->
<!-- http://download.oracle.com/javase/1.5.0/docs/guide/management/agent.html -->
<jmx.system-property1>-Dcom.sun.management.jmxremote=true</jmx.system-property1>
- <jmx.system-property2>-Dcom.sun.management.jmxremote.ssl=false</jmx.system-property2>
- <jmx.system-property3>-Dcom.sun.management.jmxremote.access.file=../conf/jmx.access</jmx.system-property3>
- <jmx.system-property4>-Dcom.sun.management.jmxremote.password.file=../conf/jmx.password</jmx.system-property4>
- <jmx.system-property5>-Dcom.sun.management.jmxremote.port=9999</jmx.system-property5>
- <jmx.system-properties>${jmx.system-property1} ${jmx.system-property2} ${jmx.system-property3} ${jmx.system-property4} ${jmx.system-property5}</jmx.system-properties>
+ <jmx.system-property2>-Dcom.sun.management.jmxremote.authenticate=false</jmx.system-property2>
+ <jmx.system-properties>${jmx.system-property1} ${jmx.system-property2}</jmx.system-properties>
<!-- Use filesystem to copy message by default -->
<james.system-property1>-Djames.message.usememorycopy=false</james.system-property1>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org