felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r933677 - in /felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl: DataModelHelperImpl.java FileUtil.java ResolverImpl.java
Date Tue, 13 Apr 2010 15:28:58 GMT
Author: gnodet
Date: Tue Apr 13 15:28:58 2010
New Revision: 933677

URL: http://svn.apache.org/viewvc?rev=933677&view=rev
Log:
FELIX-2276: Authentication credentials for proxies are not set when retrieving resources

Modified:
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java?rev=933677&r1=933676&r2=933677&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
Tue Apr 13 15:28:58 2010
@@ -94,24 +94,9 @@ public class DataModelHelperImpl impleme
 
         try
         {
-            // Do it the manual way to have a chance to
-            // set request properties as proxy auth (EW).
-            URLConnection conn = url.openConnection();
-
-            // Support for http proxy authentication
-            String auth = System.getProperty("http.proxyAuth");
-            if ((auth != null) && (auth.length() > 0))
-            {
-                if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol()))
-                {
-                    String base64 = Base64Encoder.base64Encode(auth);
-                    conn.setRequestProperty("Proxy-Authorization", "Basic " + base64);
-                }
-            }
-
             if (url.getPath().endsWith(".zip"))
             {
-                ZipInputStream zin = new ZipInputStream(conn.getInputStream());
+                ZipInputStream zin = new ZipInputStream(FileUtil.openURL(url));
                 ZipEntry entry = zin.getNextEntry();
                 while (entry != null)
                 {
@@ -125,7 +110,7 @@ public class DataModelHelperImpl impleme
             }
             else
             {
-                is = conn.getInputStream();
+                is = FileUtil.openURL(url);
             }
 
             if (is != null)
@@ -464,7 +449,7 @@ public class DataModelHelperImpl impleme
             }
             private byte[] loadEntry(String name) throws IOException
             {
-                InputStream is = bundleUrl.openStream();
+                InputStream is = FileUtil.openURL(bundleUrl);
                 try
                 {
                     ZipInputStream jis = new ZipInputStream(is);

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java?rev=933677&r1=933676&r2=933677&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
Tue Apr 13 15:28:58 2010
@@ -18,7 +18,14 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.io.*;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.jar.JarEntry;
@@ -48,6 +55,7 @@ public class FileUtil
 
             OutputStream os = new FileOutputStream(file);
             URLConnection conn = srcURL.openConnection();
+            FileUtil.setProxyAuth(conn);
             int total = conn.getContentLength();
             InputStream is = conn.getInputStream();
 
@@ -167,4 +175,32 @@ public class FileUtil
         }
         bos.close();
     }
+
+    public static void setProxyAuth(URLConnection conn) throws IOException {
+        // Support for http proxy authentication
+        String auth = System.getProperty("http.proxyAuth");
+        if ((auth != null) && (auth.length() > 0))
+        {
+            if ("http".equals(conn.getURL().getProtocol()) || "https".equals(conn.getURL().getProtocol()))
+            {
+                String base64 = Base64Encoder.base64Encode(auth);
+                conn.setRequestProperty("Proxy-Authorization", "Basic " + base64);
+            }
+        }
+
+    }
+
+    public static InputStream openURL(final URL url) throws IOException {
+        // Do it the manual way to have a chance to
+        // set request properties as proxy auth (EW).
+        return openURL(url.openConnection());
+    }
+
+    public static InputStream openURL(final URLConnection conn) throws IOException {
+        // Do it the manual way to have a chance to
+        // set request properties as proxy auth (EW).
+        setProxyAuth(conn);
+        return conn.getInputStream();
+    }
+
 }
\ No newline at end of file

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java?rev=933677&r1=933676&r2=933677&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
Tue Apr 13 15:28:58 2010
@@ -560,7 +560,7 @@ public class ResolverImpl implements Res
                             localResource.getBundle().stop();
                         }
                         
-                        localResource.getBundle().update(new URL(deployResources[i].getURI()).openStream());
+                        localResource.getBundle().update(FileUtil.openURL(new URL(deployResources[i].getURI())));
 
                         // If necessary, save the updated bundle to be
                         // started later.
@@ -599,7 +599,7 @@ public class ResolverImpl implements Res
                             "obr://"
                             + deployResources[i].getSymbolicName()
                             + "/-" + System.currentTimeMillis(),
-                            url.openStream());
+                            FileUtil.openURL(url));
 
                         // If necessary, save the installed bundle to be
                         // started later.



Mime
View raw message