You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2010/08/02 00:16:46 UTC
svn commit: r981329 - in /ant/ivy/core/trunk: CHANGES.txt
src/java/org/apache/ivy/util/url/BasicURLHandler.java
src/java/org/apache/ivy/util/url/IvyAuthenticator.java
Author: maartenc
Date: Sun Aug 1 22:16:46 2010
New Revision: 981329
URL: http://svn.apache.org/viewvc?rev=981329&view=rev
Log:
IMPROVEMENT: Use IvyAuthenticator only when it is really necessary (IVY-1211)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=981329&r1=981328&r2=981329&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Aug 1 22:16:46 2010
@@ -110,6 +110,7 @@ for detailed view of each issue, please
trunk
=====================================
+- IMPROVEMENT: Use IvyAuthenticator only when it is really necessary (IVY-1211)
- IMPROVEMENT: ivy:makepom now accepts a list of configurations to include (IVY-1005) (thanks to Jesper Pedersen)
- FIX: XmlModuleDescriptorWriter does not write the transitive attribute (IVY-1207) (thanks to Abel Muino)
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?rev=981329&r1=981328&r2=981329&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java Sun Aug 1 22:16:46 2010
@@ -56,8 +56,10 @@ public class BasicURLHandler extends Abs
public URLInfo getURLInfo(URL url, int timeout) {
// Install the IvyAuthenticator
- IvyAuthenticator.install();
-
+ if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
+ IvyAuthenticator.install();
+ }
+
URLConnection con = null;
try {
url = normalizeToURL(url);
@@ -109,7 +111,9 @@ public class BasicURLHandler extends Abs
public InputStream openStream(URL url) throws IOException {
// Install the IvyAuthenticator
- IvyAuthenticator.install();
+ if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
+ IvyAuthenticator.install();
+ }
URLConnection conn = null;
try {
@@ -142,7 +146,9 @@ public class BasicURLHandler extends Abs
public void download(URL src, File dest, CopyProgressListener l) throws IOException {
// Install the IvyAuthenticator
- IvyAuthenticator.install();
+ if ("http".equals(src.getProtocol()) || "https".equals(src.getProtocol())) {
+ IvyAuthenticator.install();
+ }
URLConnection srcConn = null;
try {
@@ -186,14 +192,14 @@ public class BasicURLHandler extends Abs
}
public void upload(File source, URL dest, CopyProgressListener l) throws IOException {
- // Install the IvyAuthenticator
- IvyAuthenticator.install();
-
if (!"http".equals(dest.getProtocol()) && !"https".equals(dest.getProtocol())) {
throw new UnsupportedOperationException(
"URL repository only support HTTP PUT at the moment");
}
+ // Install the IvyAuthenticator
+ IvyAuthenticator.install();
+
HttpURLConnection conn = null;
try {
dest = normalizeToURL(dest);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java?rev=981329&r1=981328&r2=981329&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/IvyAuthenticator.java Sun Aug 1 22:16:46 2010
@@ -31,6 +31,8 @@ public final class IvyAuthenticator exte
private Authenticator original;
+ private static boolean securityWarningLogged = false;
+
/**
* Private c'tor to prevent instantiation.
*/
@@ -58,7 +60,15 @@ public final class IvyAuthenticator exte
}
if (!(original instanceof IvyAuthenticator)) {
- Authenticator.setDefault(new IvyAuthenticator(original));
+ try {
+ Authenticator.setDefault(new IvyAuthenticator(original));
+ } catch (SecurityException e) {
+ if (!securityWarningLogged) {
+ securityWarningLogged = true;
+ Message.warn("Not enough permissions to set the IvyAuthenticator. " +
+ "HTTP(S) authentication will be disabled!");
+ }
+ }
}
}