diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java index 756cf87..50cf752 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpBuilder.java @@ -23,6 +23,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.SystemDefaultRoutePlanner; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; import org.dom4j.DocumentHelper; @@ -34,6 +35,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import java.io.*; +import java.net.ProxySelector; import java.security.GeneralSecurityException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -109,13 +111,18 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce httpClientBuilder.setSSLContext(sslContextBuilder.build()); } if(options.containsKey("proxySettings") && Boolean.parseBoolean(options.get("proxySettings").toString())){ - log.log(5, "using proxy IP: " + options.get("proxyIP").toString()); - log.log(5, "using proxy Port: " + options.get("proxyPort").toString()); + log.log(5, "proxy IP set in job: " + options.get("proxyIP").toString()); HttpHost proxy = new HttpHost(options.get("proxyIP").toString(), Integer.valueOf((String)options.get("proxyPort")), "http"); httpClientBuilder.setProxy(proxy); } + if(options.get("useSystemProxySettings").equals("true")) { + + httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())); + + } + return httpClientBuilder.build(); } diff --git a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java index db1034f..5cead91 100644 --- a/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java +++ b/src/main/java/edu/ohio/ais/rundeck/HttpDescription.java @@ -2,6 +2,7 @@ import com.dtolabs.rundeck.core.plugins.configuration.Describable; import com.dtolabs.rundeck.core.plugins.configuration.Description; +import com.dtolabs.rundeck.core.plugins.configuration.PropertyScope; import com.dtolabs.rundeck.core.plugins.configuration.StringRenderingConstants; import com.dtolabs.rundeck.plugins.util.DescriptionBuilder; import com.dtolabs.rundeck.plugins.util.PropertyBuilder; @@ -165,6 +166,12 @@ public Description getDescription() { .defaultValue("false") .renderingOption(StringRenderingConstants.GROUP_NAME,"Print") .build()) + .property(PropertyBuilder.builder() + .booleanType("useSystemProxySettings") + .description("Choose whether to use proxy settings set on the JVM.") + .defaultValue("false") + .scope(PropertyScope.Project) + .build()) .build(); } }