aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/org
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-09-21 10:39:06 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-09-21 10:39:06 +0200
commitff7c68939563b8ac1cc1b293b8195cd9801877c7 (patch)
tree19a007cefe0da6de90e203f9607eb28a056830a3 /id/server/moa-id-commons/src/main/java/org
parent775f70c77247ab91a58b48c3798fbf91d104e4d2 (diff)
downloadmoa-id-spss-ff7c68939563b8ac1cc1b293b8195cd9801877c7.tar.gz
moa-id-spss-ff7c68939563b8ac1cc1b293b8195cd9801877c7.tar.bz2
moa-id-spss-ff7c68939563b8ac1cc1b293b8195cd9801877c7.zip
fix possible nullpointer exception
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/org')
-rw-r--r--id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java b/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
index 04e9a8ab9..751e27b95 100644
--- a/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
+++ b/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
@@ -45,6 +45,7 @@ public class MOAHttpClient extends HttpClient {
public MOAHttpClient() {
super();
+ injectProxyCredentials();
}
@@ -93,8 +94,12 @@ public class MOAHttpClient extends HttpClient {
HttpState interalState = (state == null ? getState() : state);
- if (requiresProxy(uri.getURI())) {
- injectProxyCredentials(hostconfig, interalState);
+ if (!requiresProxy(uri.getURI())
+ && MiscUtil.isNotEmpty(hostconfig.getProxyHost())) {
+ Logger.info("RequestURL is on proxy-ignore list. Remove proxy from request", null);
+ hostconfig.setProxyHost(null);
+
+
}
@@ -102,12 +107,12 @@ public class MOAHttpClient extends HttpClient {
getHttpConnectionManager(),
hostconfig,
getParams(),
- state);
+ interalState);
methodDirector.executeMethod(method);
return method.getStatusCode();
}
- public void injectProxyCredentials(HostConfiguration hostconfig, HttpState interalState) {
+ public void injectProxyCredentials() {
//set proxy functionality
String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
@@ -125,14 +130,14 @@ public class MOAHttpClient extends HttpClient {
}
}
- Logger.debug("Set HTTP-Proxy to Host: " + host + " and port: " + p);
- hostconfig.setProxy(host, p);
+ Logger.info("Set HTTP-Proxy to Host: " + host + " and port: " + p);
+ getHostConfiguration().setProxy(host, p);
if (MiscUtil.isNotEmpty(user) && pass != null) {
//set proxy credentials
AuthScope authscope = new AuthScope(host, p);
Credentials credentials = new UsernamePasswordCredentials(user, pass);
- interalState.setProxyCredentials(authscope, credentials);
- Logger.debug(" Use Proxy with Username: " + user + " and password: "
+ getState().setProxyCredentials(authscope, credentials);
+ Logger.info(" Use Proxy with Username: " + user + " and password: "
+ (Logger.isTraceEnabled() ? pass : "*******"));
}
@@ -150,8 +155,7 @@ public class MOAHttpClient extends HttpClient {
{
boolean requiresProxy = true;
final String nonProxyHosts = System.getProperty("http.nonProxyHosts");
- if (nonProxyHosts != null)
- {
+ if (nonProxyHosts != null) {
StringTokenizer tokenizer = new StringTokenizer(nonProxyHosts, "|");
while (tokenizer.hasMoreTokens())
{