You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by gi...@apache.org on 2012/07/31 17:18:29 UTC
svn commit: r1367609 -
/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
Author: giger
Date: Tue Jul 31 15:18:29 2012
New Revision: 1367609
URL: http://svn.apache.org/viewvc?rev=1367609&view=rev
Log:
- Fix possible race conditions: When an exception occurs the proxy settings will not be restored.
- Fix Proxy-Authentication header
There is still a race condition due to the way we have to set the proxy. JDK 1.4 and below don't
support java.net.Proxy as parameter to openConnection()
Modified:
santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
Modified: santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java?rev=1367609&r1=1367608&r2=1367609&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java Tue Jul 31 15:18:29 2012
@@ -104,7 +104,6 @@ public class ResolverDirectHTTP extends
public XMLSignatureInput engineResolve(Attr uri, String BaseURI)
throws ResourceResolverException {
- try {
boolean useProxy = false;
String proxyHost =
engineGetProperty(ResolverDirectHTTP
@@ -138,6 +137,7 @@ public class ResolverDirectHTTP extends
&& (oldProxyHost != null)
&& (oldProxyPort != null));
+ try {
// calculate new URI
URI uriNew = getNewURI(uri.getNodeValue(), BaseURI);
@@ -163,9 +163,8 @@ public class ResolverDirectHTTP extends
String password = proxyUser + ":" + proxyPass;
String encodedPassword = Base64.encode(password.getBytes("ISO-8859-1"));
- // or was it Proxy-Authenticate ?
urlConnection.setRequestProperty("Proxy-Authorization",
- encodedPassword);
+ "Basic " + encodedPassword);
}
}
@@ -223,13 +222,6 @@ public class ResolverDirectHTTP extends
result.setSourceURI(uriNew.toString());
result.setMIMEType(mimeType);
- // switch off proxy usage
- if (useProxy && switchBackProxy) {
- System.setProperty("http.proxySet", oldProxySet);
- System.setProperty("http.proxyHost", oldProxyHost);
- System.setProperty("http.proxyPort", oldProxyPort);
- }
-
return result;
} catch (MalformedURLException ex) {
throw new ResourceResolverException("generic.EmptyMessage", ex, uri,
@@ -237,6 +229,13 @@ public class ResolverDirectHTTP extends
} catch (IOException ex) {
throw new ResourceResolverException("generic.EmptyMessage", ex, uri,
BaseURI);
+ } finally {
+ // switch off proxy usage
+ if (useProxy && switchBackProxy) {
+ System.setProperty("http.proxySet", oldProxySet);
+ System.setProperty("http.proxyHost", oldProxyHost);
+ System.setProperty("http.proxyPort", oldProxyPort);
+ }
}
}