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 2015/06/01 22:43:17 UTC
ant-ivy git commit: We can use Java5 methods now :)
Repository: ant-ivy
Updated Branches:
refs/heads/master 2c03505da -> 05a457b9a
We can use Java5 methods now :)
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/05a457b9
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/05a457b9
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/05a457b9
Branch: refs/heads/master
Commit: 05a457b9a0e8b1e7917670de9ace5572b9ab117e
Parents: 2c03505
Author: Maarten Coene <ma...@apache.org>
Authored: Mon Jun 1 22:41:32 2015 +0200
Committer: Maarten Coene <ma...@apache.org>
Committed: Mon Jun 1 22:41:32 2015 +0200
----------------------------------------------------------------------
.../apache/ivy/util/url/IvyAuthenticator.java | 38 ++------------------
1 file changed, 2 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/05a457b9/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/url/IvyAuthenticator.java b/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
index a529ad2..99cb99d 100644
--- a/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
+++ b/src/java/org/apache/ivy/util/url/IvyAuthenticator.java
@@ -114,44 +114,10 @@ public final class IvyAuthenticator extends Authenticator {
}
/**
- * Checks if the current authentication request is for the proxy server. This functionality is
- * not available in JDK1.4, so we check this in a very dirty way which is probably not very
- * portable, but will work for the SUN 1.4 JDKs.
- *
- * @return
+ * Checks if the current authentication request is for the proxy server.
*/
private boolean isProxyAuthentication() {
- try {
- // we first try to invoke the getRequestorType() method which is a JDK1.5+ method
- Method m = Authenticator.class.getDeclaredMethod("getRequestorType", null);
- Object result = m.invoke(this, null);
- return "PROXY".equals(String.valueOf(result));
- } catch (NoSuchMethodException e) {
- // do nothing, this is a JDK1.5+ method
- } catch (Throwable t) {
- Message.debug("Error occurred while checking if the authentication request is for the proxy server: "
- + t.getMessage());
- }
-
- // now we will do something very dirty and analyse the stack trace to see
- // if this method is called from within the 'getHttpProxyAuthentication' method
- // or the 'getServerAuthentication' method which are both part of the
- // sun.net.www.protocol.http.HttpURLConnection class.
- // This might not work on other 1.4 JVM's!
- // This code should be removed when Ivy requires JDK1.5+
- StackTraceElement[] stackTrace = (new Exception()).getStackTrace();
- for (int i = 0; i < stackTrace.length; i++) {
- if ("getHttpProxyAuthentication".equals(stackTrace[i].getMethodName())) {
- return true;
- }
- if ("getServerAuthentication".equals(stackTrace[i].getMethodName())) {
- return false;
- }
- }
-
- // fallback to the Ivy 2.2.0 behavior
- String proxyHost = System.getProperty("http.proxyHost");
- return getRequestingHost().equals(proxyHost);
+ return RequestorType.PROXY.equals(getRequestorType());
}
}