summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2015-11-05 14:50:34 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2015-11-05 14:50:34 +0100
commitcf2c64272ef684cdab9d96671dea44912e02a348 (patch)
tree316825e5d3212a95da4478f37a3dd82cded1357d /pdf-over-gui/src
parent621c0d15963cac3519b4dce7b14fbf63c7d2761b (diff)
downloadpdf-over-cf2c64272ef684cdab9d96671dea44912e02a348.tar.gz
pdf-over-cf2c64272ef684cdab9d96671dea44912e02a348.tar.bz2
pdf-over-cf2c64272ef684cdab9d96671dea44912e02a348.zip
Don't use proxy in HttpClient for local connections
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java39
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java2
3 files changed, 27 insertions, 16 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
index 20cc04bb..765a6706 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
@@ -36,28 +36,39 @@ public class BKUHelper {
/**
* Get a HTTP Client instance
+ * @param useProxy whether to use a potentially set proxy
* @return the HttpClient
*/
- public static HttpClient getHttpClient() {
+ public static HttpClient getHttpClient(boolean useProxy) {
HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", //$NON-NLS-1$
Constants.USER_AGENT_STRING);
-
- String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
- String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
- if (host != null && !host.isEmpty() &&
- port != null && !port.isEmpty()) {
- int p = Integer.parseInt(port);
- client.getHostConfiguration().setProxy(host, p);
- String user = System.getProperty("http.proxyUser"); //$NON-NLS-1$
- String pass = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
- if (user != null && !user.isEmpty() && pass != null) {
- client.getState().setProxyCredentials(new AuthScope(host, p),
- new UsernamePasswordCredentials(user, pass));
+
+ if (useProxy) {
+ String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
+ String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
+ if (host != null && !host.isEmpty() &&
+ port != null && !port.isEmpty()) {
+ int p = Integer.parseInt(port);
+ client.getHostConfiguration().setProxy(host, p);
+ String user = System.getProperty("http.proxyUser"); //$NON-NLS-1$
+ String pass = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
+ if (user != null && !user.isEmpty() && pass != null) {
+ client.getState().setProxyCredentials(new AuthScope(host, p),
+ new UsernamePasswordCredentials(user, pass));
+ }
}
}
-
+
return client;
}
+ /**
+ * Get a HTTP Client instance
+ * @return the HttpClient
+ */
+ public static HttpClient getHttpClient() {
+ return getHttpClient(true);
+ }
+
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
index eb1b57d6..3d18bfc8 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
@@ -68,7 +68,7 @@ public class LocalBKUConnector implements BkuSlConnector {
@Override
public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
try {
- HttpClient client = BKUHelper.getHttpClient();
+ HttpClient client = BKUHelper.getHttpClient(false);
PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
String sl_request = request.getRequest();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index eaccae5d..5507c739 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -104,7 +104,7 @@ public class LocalBKUState extends State {
public void run() {
try {
- HttpClient client = BKUHelper.getHttpClient();
+ HttpClient client = BKUHelper.getHttpClient(false);
PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);