From ba170891db5e5a75d02391a73085dee6e7a6074d Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Sat, 12 Jul 2014 07:21:55 +0200 Subject: [PATCH] PR 56678 allow tsa proxy host to be used without tsaurl in signjar --- .../apache/tools/ant/taskdefs/SignJar.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java index a15df4f46..f971001fa 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java @@ -549,21 +549,6 @@ public class SignJar extends AbstractJarSignerTask { if (tsaurl != null) { addValue(cmd, "-tsa"); addValue(cmd, tsaurl); - - if (tsaproxyhost != null) { - final String connectionType; - if (tsaurl.startsWith("https")) { - connectionType = "https"; - } else { - connectionType = "http"; - } - - addValue(cmd, "-J-D" + connectionType + ".proxyHost=" + tsaproxyhost); - - if (tsaproxyport != null) { - addValue(cmd, "-J-D" + connectionType + ".proxyPort=" + tsaproxyport); - } - } } if (tsacert != null) { @@ -571,6 +556,14 @@ public class SignJar extends AbstractJarSignerTask { addValue(cmd, tsacert); } + if (tsaproxyhost != null) { + if (tsaurl == null || tsaurl.startsWith("https")) { + addProxyFor(cmd, "https"); + } + if (tsaurl == null || !tsaurl.startsWith("https")) { + addProxyFor(cmd, "http"); + } + } } /** @@ -641,4 +634,12 @@ public class SignJar extends AbstractJarSignerTask { public void setPreserveLastModified(boolean preserveLastModified) { this.preserveLastModified = preserveLastModified; } + + private void addProxyFor(final ExecTask cmd, final String scheme) { + addValue(cmd, "-J-D" + scheme + ".proxyHost=" + tsaproxyhost); + + if (tsaproxyport != null) { + addValue(cmd, "-J-D" + scheme + ".proxyPort=" + tsaproxyport); + } + } }