Skip to content

Commit

Permalink
0001050: Introduce conf/symmetric-server.properties which contains ht…
Browse files Browse the repository at this point in the history
…tp/https/jmx port/enabled settings and other server specific setting

0001051: --jmx-port and --jmx-disabled command line help is not available
  • Loading branch information
chenson42 committed Feb 18, 2013
1 parent 22e8337 commit bc5463a
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 31 deletions.
Expand Up @@ -283,6 +283,11 @@ public TypedProperties reload() {
}

protected Resource[] buildLocations(File propertiesFile) {
/*
* System properties always override the properties found in
* these files. System properties are merged in the parameter
* service.
*/
List<Resource> resources = new ArrayList<Resource>();
resources.add(new ClassPathResource("/symmetric-default.properties"));
resources.add(new ClassPathResource("/symmetric-console-default.properties"));
Expand Down
Expand Up @@ -15,13 +15,15 @@ Common.Option.storetype=Type of keystore format [jks].
Common.Option.providerClass=Class name of alternate crypto provider.
Common.Option.help=Print help with each option and description.

Launcher.Option.server=Start an embedded instance of SymmetricDS that accepts HTTP.
Launcher.Option.server=Start an embedded instance of SymmetricDS that accepts HTTP. Setting this on the command line overrides the enable settings in symmetric-server.properties.
Launcher.Option.client=Start an embedded, client-only, instance of SymmetricDS.
Launcher.Option.secure-server=Start an embedded instance of SymmetricDS that accepts HTTPS.
Launcher.Option.mixed-server=Start an embedded instance of SymmetricDS that accepts HTTP/HTTPS.
Launcher.Option.secure-server=Start an embedded instance of SymmetricDS that accepts HTTPS. Setting this on the command line overrides the enable settings in symmetric-server.properties.
Launcher.Option.mixed-server=Start an embedded instance of SymmetricDS that accepts HTTP/HTTPS. Setting this on the command line overrides the enable settings in symmetric-server.properties.
Launcher.Option.host=Optionally pass in the network interface the server should bind to. If this option is not provided, the server will bind to all interfaces.
Launcher.Option.port=Optionally pass in the HTTP port number to use for the server instance.
Launcher.Option.secure-port=Optionally pass in the HTTPS port number to use for the server instance.
Launcher.Option.port=Optionally pass in the HTTP port number to use for the server instance. If this parameter is not passed in, then port from the symmetric-server.properties file will be used.
Launcher.Option.jmx-port=Optionally pass in the port to use for JMX. If this parameter is not passed in, then port from the symmetric-server.properties file will be used.
Launcher.Option.jmx-disable=Set the value to true to disable the JMX http interface. If this parameter is not passed in, then value from the symmetric-server.properties file will be used.
Launcher.Option.secure-port=Optionally pass in the HTTPS port number to use for the server instance. If this parameter is not passed in, then port from the symmetric-server.properties file will be used.
Launcher.Option.max-idle-time=Max idle time in milliseconds when a connection is forced to close [900000].
Launcher.Option.no-nio=Do not use Non-blocking IO for the HTTP connector.
Launcher.Option.no-directbuffer=Do not use direct buffers for the NIO HTTP connector.
Expand Down
Expand Up @@ -154,8 +154,6 @@ private ParameterConstants() {
public final static String TRANSPORT_HTTP_BASIC_AUTH_PASSWORD = "http.basic.auth.password";
public final static String TRANSPORT_TYPE = "transport.type";
public final static String TRANSPORT_MAX_BYTES_TO_SYNC = "transport.max.bytes.to.sync";
public final static String TRANSPORT_HTTPS_VERIFIED_SERVERS = "https.verified.server.names";
public final static String TRANSPORT_HTTPS_ALLOW_SELF_SIGNED_CERTS = "https.allow.self.signed.certs";

public final static String CACHE_TIMEOUT_GROUPLETS_IN_MS = "cache.grouplets.time.ms";
public final static String CACHE_TIMEOUT_NODE_SECURITY_IN_MS = "cache.node.security.time.ms";
Expand Down
@@ -0,0 +1,42 @@
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* 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.jumpmind.symmetric.common;

/**
* These are properties that are server wide. They can be accessed via the parameter service or via System properties.
*/
public class ServerConstants {

public final static String HOST_BIND_NAME = "host.bind.name";

public final static String HTTP_ENABLE = "http.enable";
public final static String HTTP_PORT = "http.port";

public final static String HTTPS_ENABLE = "https.enable";
public final static String HTTPS_PORT = "https.port";

public final static String HTTPS_VERIFIED_SERVERS = "https.verified.server.names";
public final static String HTTPS_ALLOW_SELF_SIGNED_CERTS = "https.allow.self.signed.certs";

public final static String JMX_HTTP_ENABLE = "jmx.http.enable";
public final static String JMX_HTTP_PORT = "jmx.http.port";

}
Expand Down
Expand Up @@ -31,6 +31,7 @@ public class SystemConstants {
public static final String SYSPROP_STANDALONE_WEB = "symmetric.standalone.web";
public static final String SYSPROP_ENGINES_DIR = "symmetric.engines.dir";
public static final String SYSPROP_WEB_DIR = "symmetric.default.web.dir";
public static final String SYSPROP_SERVER_PROPERTIES_PATH = "symmetric.server.properties.path";
public static final String SYSPROP_DEFAULT_HTTP_PORT = "symmetric.default.http.port";
public static final String SYSPROP_DEFAULT_HTTPS_PORT = "symmetric.default.https.port";
public static final String SYSPROP_KEYSTORE_TYPE = "sym.keystore.type";
Expand Down
Expand Up @@ -39,6 +39,7 @@
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.ServerConstants;
import org.jumpmind.symmetric.transport.http.HttpTransportManager;
import org.jumpmind.symmetric.transport.http.SelfSignedX509TrustManager;
import org.jumpmind.symmetric.transport.internal.InternalTransportManager;
Expand All @@ -57,7 +58,7 @@ public ITransportManager create() {
ParameterConstants.TRANSPORT_TYPE);
if (Constants.PROTOCOL_HTTP.equalsIgnoreCase(transport)) {
final String httpSslVerifiedServerNames = symmetricEngine.getParameterService()
.getString(ParameterConstants.TRANSPORT_HTTPS_VERIFIED_SERVERS);
.getString(ServerConstants.HTTPS_VERIFIED_SERVERS);
if (!StringUtils.isBlank(httpSslVerifiedServerNames)) {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String s, SSLSession sslsession) {
Expand All @@ -83,7 +84,7 @@ public boolean verify(String s, SSLSession sslsession) {

// Allow self signed certs based on the parameter value.
boolean allowSelfSignedCerts = symmetricEngine.getParameterService().is(
ParameterConstants.TRANSPORT_HTTPS_ALLOW_SELF_SIGNED_CERTS, false);
ServerConstants.HTTPS_ALLOW_SELF_SIGNED_CERTS, false);
if (allowSelfSignedCerts) {
HttpsURLConnection.setDefaultSSLSocketFactory(createSelfSignedSocketFactory());
}
Expand Down
2 changes: 0 additions & 2 deletions symmetric-server/src/main/deploy/conf/sym_service.conf
Expand Up @@ -59,8 +59,6 @@ wrapper.java.maxmemory=256
wrapper.app.parameter.1=org.jumpmind.symmetric.SymmetricLauncher
wrapper.app.parameter.2=--no-log-console
wrapper.app.parameter.3=--server
wrapper.app.parameter.4=--port
wrapper.app.parameter.5=31415

#********************************************************************
# Wrapper Logging Properties
Expand Down
13 changes: 13 additions & 0 deletions symmetric-server/src/main/deploy/conf/symmetric-server.properties
@@ -0,0 +1,13 @@
#host.bind.name=

http.enable=true
http.port=${select.install.httpPort}

https.enable=false
https.port=31417

https.allow.self.signed.certs=true
https.verified.server.names=all

jmx.http.enable=${select.install.jmxEnabled}
jmx.http.port=${select.install.jmxPort}
Expand Up @@ -110,8 +110,8 @@ protected void buildOptions(Options options) {
protected boolean executeWithOptions(CommandLine line) throws Exception {

String host = null;
int httpPort = Integer.parseInt(SymmetricWebServer.DEFAULT_HTTP_PORT);
int httpSecurePort = Integer.parseInt(SymmetricWebServer.DEFAULT_HTTPS_PORT);
int httpPort = 0;
int httpSecurePort = 0;
int jmxPort = 0;

String webDir = SymmetricWebServer.DEFAULT_WEBAPP_DIR;
Expand Down Expand Up @@ -158,9 +158,13 @@ protected boolean executeWithOptions(CommandLine line) throws Exception {
jmxPort = new Integer(line.getOptionValue(OPTION_JMX_PORT));
} else {
if (line.hasOption(OPTION_START_SECURE_SERVER)) {
jmxPort = httpSecurePort + 1;
if (httpSecurePort > 0) {
jmxPort = httpSecurePort + 1;
}
} else {
jmxPort = httpPort + 1;
if (httpPort > 0) {
jmxPort = httpPort + 1;
}
}
}
}
Expand All @@ -175,13 +179,36 @@ protected boolean executeWithOptions(CommandLine line) throws Exception {
webServer.setHost(host);
webServer.setBasicAuthUsername(httpBasicAuthUser);
webServer.setBasicAuthPassword(httpBasicAuthPassword);

if (jmxPort > 0) {
webServer.setJmxPort(jmxPort);
}

if (line.hasOption(OPTION_START_MIXED_SERVER)) {
webServer.startMixed(httpPort, httpSecurePort, jmxPort);
webServer.setHttpEnabled(true);
webServer.setHttpsEnabled(true);
if (httpPort > 0) {
webServer.setHttpPort(httpPort);
}
if (httpSecurePort > 0) {
webServer.setHttpsPort(httpSecurePort);
}
} else if (line.hasOption(OPTION_START_SECURE_SERVER)) {
webServer.startSecure(httpSecurePort, jmxPort);
webServer.setHttpEnabled(false);
webServer.setHttpsEnabled(true);
if (httpSecurePort > 0) {
webServer.setHttpsPort(httpSecurePort);
}
} else {
webServer.start(httpPort, jmxPort);
webServer.setHttpEnabled(true);
webServer.setHttpsEnabled(false);
if (httpPort > 0) {
webServer.setHttpPort(httpPort);
}
}

webServer.start();

return true;
}

Expand Down

0 comments on commit bc5463a

Please sign in to comment.