aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/org
diff options
context:
space:
mode:
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.java52
1 files changed, 46 insertions, 6 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 edf7ce268..4d4c7fa88 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
@@ -26,10 +26,12 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
/**
* @author tlenz
@@ -39,10 +41,48 @@ import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException
*/
public class MOAHttpClient extends HttpClient {
-
- public void setCustomSSLTrustStore(String metadataURL, ProtocolSocketFactory protoSocketFactory) throws MOAHttpProtocolSocketFactoryException, MalformedURLException {
- ;
-
+ public MOAHttpClient() {
+ super();
+ injectProxyCredentials();
+
+ }
+
+ public void injectProxyCredentials() {
+ //set proxy functionality
+ String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
+ String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
+ String user = System.getProperty("http.proxyUser"); //$NON-NLS-1$
+ String pass = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
+
+ if (MiscUtil.isNotEmpty(host)) {
+ int p = -1;
+ if (MiscUtil.isNotEmpty(port)) {
+ try {
+ p = Integer.parseInt(port);
+
+ } catch (Exception e) {
+ Logger.error("'http.proxyPort' not valid!", e);
+
+ }
+ }
+ 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);
+ getState().setProxyCredentials(authscope, credentials);
+ Logger.info(" Use Proxy with Username: " + user + " and password: "
+ + (Logger.isTraceEnabled() ? pass : "*******"));
+
+ }
+
+ }
+ }
+
+ public void setCustomSSLTrustStore(String metadataURL, ProtocolSocketFactory protoSocketFactory)
+ throws MalformedURLException {
+
URL url = new URL(metadataURL);
int port = -1;
if (url.getPort() < 0)
@@ -52,7 +92,7 @@ public class MOAHttpClient extends HttpClient {
Protocol authhttps = new Protocol("https", protoSocketFactory, 443);
getHostConfiguration().setHost(url.getHost(), port, authhttps);
-
+
}
public int executeMethod(HostConfiguration hostconfig,