The Unified and Autonomous Development Platform
Add appropriate instructions on how to install JCE unlimited length policy files
robin shine46273fc5bb5a
diff --git a/commons.jsw/wrapper/customization/wrapper.conf b/commons.jsw/wrapper/customization/wrapper.confindex af774cec5c..6710d95ca0 100644--- a/commons.jsw/wrapper/customization/wrapper.conf+++ b/commons.jsw/wrapper/customization/wrapper.conf@@ -43,12 +43,10 @@ wrapper.single_invocation=TRUE#********************************************************************# Wrapper Java Properties. GitPlex requires at least Java version 8#********************************************************************-# Java Application-# Locate the java8 or higher binary on the system PATH:+# Specify Java 8 executable to be used. You may simply specify it as "java"+# if the one in system path is appropriate, or specify the full path to+# desired java executablewrapper.java.command=java-# Specify a specific java8 or higher binary:-#set.JAVA_HOME=/java/path-#wrapper.java.command=%JAVA_HOME%/bin/java# Tell the Wrapper to log the full generated Java command line.#wrapper.java.command.loglevel=INFOdiff --git a/commons.util/src/main/java/com/gitplex/commons/util/ExceptionUtils.java b/commons.util/src/main/java/com/gitplex/commons/util/ExceptionUtils.javaindex 72de8787c1..1b77b69001 100644--- a/commons.util/src/main/java/com/gitplex/commons/util/ExceptionUtils.java+++ b/commons.util/src/main/java/com/gitplex/commons/util/ExceptionUtils.java@@ -1,8 +1,12 @@package com.gitplex.commons.util;+import java.io.File;import java.util.HashSet;import java.util.Set;+import javax.annotation.Nullable;+import javax.net.ssl.SSLHandshakeException;+import com.gitplex.commons.bootstrap.BootstrapUtils;public class ExceptionUtils extends org.apache.commons.lang3.exception.ExceptionUtils {@@ -31,4 +35,35 @@ public class ExceptionUtils extends org.apache.commons.lang3.exception.Exceptionreturn BootstrapUtils.unchecked(e);}+ @Nullable+ public static String suggestSolution(Exception e) {+ if (find(e, SSLHandshakeException.class) != null && System.getProperty("java.vendor").contains("Oracle")) {+ File securityDir;+ String javaHome = System.getProperty("java.home");+ if (javaHome != null) {+ if (new File(javaHome, "lib/security/local_policy.jar").exists()) {+ securityDir = new File(javaHome, "lib/security");+ } else if (new File(javaHome, "jre/lib/security/local_policy.jar").exists()) {+ securityDir = new File(javaHome, "jre/lib/security");+ } else {+ securityDir = null;+ }+ } else {+ securityDir = null;+ }+ String downloadUrl;+ String javaVersion = System.getProperty("java.version");+ if (javaVersion.startsWith("1.8.")) {+ downloadUrl = "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html";+ } else {+ downloadUrl = null;+ }+ return String.format("You probably need to download Oracle JCE unlimited strength policy package %s, "+ + "and place extracted jar files into %s to overwrite existing files, followed by restarting GitPlex",+ downloadUrl!=null?"from \"" + downloadUrl + "\"":"for your JVM version",+ securityDir!=null?"directory \""+securityDir.getAbsolutePath()+"\"":"security directory of your JVM");+ }+ return null;+ }+}diff --git a/pom.xml b/pom.xmlindex eccbbfa6c0..aaaa059449 100644--- a/pom.xml+++ b/pom.xml@@ -365,7 +365,7 @@<dependency><groupId>org.apache.commons</groupId><artifactId>commons-email</artifactId>- <version>1.3.3</version>+ <version>1.4</version></dependency><dependency><groupId>org.jsoup</groupId>diff --git a/server.core/src/main/java/com/gitplex/server/core/manager/impl/DefaultMailManager.java b/server.core/src/main/java/com/gitplex/server/core/manager/impl/DefaultMailManager.javaindex aeb3ca9245..3603b5fa7d 100644--- a/server.core/src/main/java/com/gitplex/server/core/manager/impl/DefaultMailManager.java+++ b/server.core/src/main/java/com/gitplex/server/core/manager/impl/DefaultMailManager.java@@ -83,7 +83,7 @@ public class DefaultMailManager implements MailManager {email.setSocketTimeout(mailSetting.getTimeout()*1000);email.setStartTLSEnabled(true);-+ email.setSSLOnConnect(mailSetting.isEnableSSL());email.setSSLCheckServerIdentity(false);String senderEmail = mailSetting.getSenderAddress();diff --git a/server.core/src/main/java/com/gitplex/server/core/migration/DatabaseMigrator.java b/server.core/src/main/java/com/gitplex/server/core/migration/DatabaseMigrator.javaindex f4990bd0eb..8688b7e49b 100644--- a/server.core/src/main/java/com/gitplex/server/core/migration/DatabaseMigrator.java+++ b/server.core/src/main/java/com/gitplex/server/core/migration/DatabaseMigrator.java@@ -84,4 +84,17 @@ public class DatabaseMigrator implements Migrator {}}+ private void migrate5(File dataDir, Stack<Integer> versions) {+ for (File file: dataDir.listFiles()) {+ if (file.getName().startsWith("Configs.xml")) {+ VersionedDocument dom = VersionedDocument.fromFile(file);+ for (Element element: dom.getRootElement().elements()) {+ if (element.elementTextTrim("key").equals("MAIL"))+ element.element("setting").addElement("enableSSL").setText("false");+ }+ dom.writeToFile(file, false);+ }+ }+ }+}diff --git a/server.core/src/main/java/com/gitplex/server/core/setting/MailSetting.java b/server.core/src/main/java/com/gitplex/server/core/setting/MailSetting.javaindex e645e10450..e74308b4f6 100644--- a/server.core/src/main/java/com/gitplex/server/core/setting/MailSetting.java+++ b/server.core/src/main/java/com/gitplex/server/core/setting/MailSetting.java@@ -16,13 +16,15 @@ public class MailSetting implements Serializable {private int smtpPort = 587;+ private boolean enableSSL;+private String smtpUser;private String smtpPassword;private String senderAddress;- private int timeout = 300;+ private int timeout = 60;@Editable(order=100, name="SMTP Host", description="Specify the SMTP mail host used by GitPlex to send email."@@ -48,6 +50,15 @@ public class MailSetting implements Serializable {this.smtpPort = smtpPort;}+ @Editable(order=250, name="Enable SSL", description="Whether or not to enable SSL")+ public boolean isEnableSSL() {+ return enableSSL;+ }++ public void setEnableSSL(boolean enableSSL) {+ this.enableSSL = enableSSL;+ }+@Editable(order=300, name="SMTP User", description="Optionally specify user name here if the SMTP host needs authentication")diff --git a/server.web/src/main/java/com/gitplex/server/web/page/admin/MailSettingPage.java b/server.web/src/main/java/com/gitplex/server/web/page/admin/MailSettingPage.javaindex 60c78e0862..6381dd1479 100644--- a/server.web/src/main/java/com/gitplex/server/web/page/admin/MailSettingPage.java+++ b/server.web/src/main/java/com/gitplex/server/web/page/admin/MailSettingPage.java@@ -13,6 +13,7 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.google.common.collect.Sets;+import com.gitplex.commons.util.ExceptionUtils;import com.gitplex.commons.wicket.behavior.testform.TestFormBehavior;import com.gitplex.commons.wicket.behavior.testform.TestResult;import com.gitplex.commons.wicket.editable.BeanContext;@@ -70,6 +71,9 @@ public class MailSettingPage extends AdministrationPage {currentUser.getEmail() + ", please check your mail box.");} catch (Exception e) {logger.error("Error sending test email", e);+ String suggestedSolution = ExceptionUtils.suggestSolution(e);+ if (suggestedSolution != null)+ logger.warn("!!! " + suggestedSolution);return new TestResult.Failed("Error sending test email: " + e.getMessage() + ", check server log for details.");}}