Author: thomas.heute(a)jboss.com
Date: 2008-06-04 09:42:23 -0400 (Wed, 04 Jun 2008)
New Revision: 10920
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLTools.java
Log:
JBPORTAL-2034: use http.proxyUser and http.proxyPassword for proxy authentication
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLTools.java
===================================================================
---
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLTools.java 2008-06-04
13:35:16 UTC (rev 10919)
+++
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLTools.java 2008-06-04
13:42:23 UTC (rev 10920)
@@ -31,7 +31,9 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.Authenticator;
import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
@@ -118,6 +120,17 @@
throw new IllegalArgumentException("No negative connection timeout" +
connTimeoutMillis);
}
+ if (System.getProperty("http.proxyUser") != null)
+ {
+ Authenticator.setDefault(new Authenticator(){
+
+ protected PasswordAuthentication getPasswordAuthentication()
+ {
+ return (new
PasswordAuthentication(System.getProperty("http.proxyUser"),
System.getProperty("http.proxyPassword").toCharArray()));
+ }
+ });
+ }
+
//
URLConnection conn;
try