From 26f89391d3e506aecc6b9ed8cef4f6802bafe957 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sat, 25 Apr 2015 22:56:51 +0000
Subject: [PATCH] Mods to remove additional Apache dependencies and unneeded
 code, now compiles

---
 .../conn/ssl/DefaultHostnameVerifier.java     | 13 ++-
 .../http/conn/util/InetAddressUtils.java      |  2 -
 .../http/conn/util/PublicSuffixList.java      |  2 -
 .../conn/util/PublicSuffixListParser.java     |  2 -
 .../http/conn/util/PublicSuffixMatcher.java   |  2 -
 core/java/src/org/apache/http/util/Args.java  | 89 -------------------
 6 files changed, 6 insertions(+), 104 deletions(-)

diff --git a/core/java/src/org/apache/http/conn/ssl/DefaultHostnameVerifier.java b/core/java/src/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
index 03a1edb918..39318b308e 100644
--- a/core/java/src/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
+++ b/core/java/src/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
@@ -49,24 +49,23 @@ import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLSession;
 import javax.security.auth.x500.X500Principal;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.annotation.Immutable;
 import org.apache.http.conn.util.InetAddressUtils;
 import org.apache.http.conn.util.PublicSuffixMatcher;
 
+import net.i2p.I2PAppContext;
+import net.i2p.util.Log;
+
 /**
  * Default {@link javax.net.ssl.HostnameVerifier} implementation.
  *
  * @since 4.4
  */
-@Immutable
 public final class DefaultHostnameVerifier implements HostnameVerifier {
 
     final static int DNS_NAME_TYPE        = 2;
     final static int IP_ADDRESS_TYPE      = 7;
 
-    private final Log log = LogFactory.getLog(getClass());
+    private final Log log = I2PAppContext.getGlobalContext().logManager().getLog(getClass());
 
     private final PublicSuffixMatcher publicSuffixMatcher;
 
@@ -86,8 +85,8 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
             verify(host, x509);
             return true;
         } catch(final SSLException ex) {
-            if (log.isDebugEnabled()) {
-                log.debug(ex.getMessage(), ex);
+            if (log.shouldWarn()) {
+                log.warn(ex.getMessage(), ex);
             }
             return false;
         }
diff --git a/core/java/src/org/apache/http/conn/util/InetAddressUtils.java b/core/java/src/org/apache/http/conn/util/InetAddressUtils.java
index acee8afa23..c7b8b85e75 100644
--- a/core/java/src/org/apache/http/conn/util/InetAddressUtils.java
+++ b/core/java/src/org/apache/http/conn/util/InetAddressUtils.java
@@ -29,14 +29,12 @@ package org.apache.http.conn.util;
 
 import java.util.regex.Pattern;
 
-import org.apache.http.annotation.Immutable;
 
 /**
  * A collection of utilities relating to InetAddresses.
  *
  * @since 4.0
  */
-@Immutable
 public class InetAddressUtils {
 
     private InetAddressUtils() {
diff --git a/core/java/src/org/apache/http/conn/util/PublicSuffixList.java b/core/java/src/org/apache/http/conn/util/PublicSuffixList.java
index ec15c9d40b..cf6b959c93 100644
--- a/core/java/src/org/apache/http/conn/util/PublicSuffixList.java
+++ b/core/java/src/org/apache/http/conn/util/PublicSuffixList.java
@@ -29,7 +29,6 @@ package org.apache.http.conn.util;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.http.annotation.Immutable;
 import org.apache.http.util.Args;
 
 /**
@@ -41,7 +40,6 @@ import org.apache.http.util.Args;
  *
  * @since 4.4
  */
-@Immutable
 public final class PublicSuffixList {
 
     private final List<String> rules;
diff --git a/core/java/src/org/apache/http/conn/util/PublicSuffixListParser.java b/core/java/src/org/apache/http/conn/util/PublicSuffixListParser.java
index 84bbd182fc..2cd2f4ec49 100644
--- a/core/java/src/org/apache/http/conn/util/PublicSuffixListParser.java
+++ b/core/java/src/org/apache/http/conn/util/PublicSuffixListParser.java
@@ -32,7 +32,6 @@ import java.io.Reader;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.annotation.Immutable;
 
 /**
  * Parses the list from <a href="http://publicsuffix.org/">publicsuffix.org</a>
@@ -40,7 +39,6 @@ import org.apache.http.annotation.Immutable;
  *
  * @since 4.4
  */
-@Immutable
 public final class PublicSuffixListParser {
 
     private static final int MAX_LINE_LEN = 256;
diff --git a/core/java/src/org/apache/http/conn/util/PublicSuffixMatcher.java b/core/java/src/org/apache/http/conn/util/PublicSuffixMatcher.java
index 02393aca4d..6da27bb7aa 100644
--- a/core/java/src/org/apache/http/conn/util/PublicSuffixMatcher.java
+++ b/core/java/src/org/apache/http/conn/util/PublicSuffixMatcher.java
@@ -32,7 +32,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.util.Args;
 
 /**
@@ -45,7 +44,6 @@ import org.apache.http.util.Args;
  *
  * @since 4.4
  */
-@ThreadSafe
 public final class PublicSuffixMatcher {
 
     private final Map<String, String> rules;
diff --git a/core/java/src/org/apache/http/util/Args.java b/core/java/src/org/apache/http/util/Args.java
index 9eb8a251ff..b39d87a7ec 100644
--- a/core/java/src/org/apache/http/util/Args.java
+++ b/core/java/src/org/apache/http/util/Args.java
@@ -27,101 +27,12 @@
 
 package org.apache.http.util;
 
-import java.util.Collection;
-
 public class Args {
 
-    public static void check(final boolean expression, final String message) {
-        if (!expression) {
-            throw new IllegalArgumentException(message);
-        }
-    }
-
-    public static void check(final boolean expression, final String message, final Object... args) {
-        if (!expression) {
-            throw new IllegalArgumentException(String.format(message, args));
-        }
-    }
-
-    public static void check(final boolean expression, final String message, final Object arg) {
-        if (!expression) {
-            throw new IllegalArgumentException(String.format(message, arg));
-        }
-    }
-
     public static <T> T notNull(final T argument, final String name) {
         if (argument == null) {
             throw new IllegalArgumentException(name + " may not be null");
         }
         return argument;
     }
-
-    public static <T extends CharSequence> T notEmpty(final T argument, final String name) {
-        if (argument == null) {
-            throw new IllegalArgumentException(name + " may not be null");
-        }
-        if (TextUtils.isEmpty(argument)) {
-            throw new IllegalArgumentException(name + " may not be empty");
-        }
-        return argument;
-    }
-
-    public static <T extends CharSequence> T notBlank(final T argument, final String name) {
-        if (argument == null) {
-            throw new IllegalArgumentException(name + " may not be null");
-        }
-        if (TextUtils.isBlank(argument)) {
-            throw new IllegalArgumentException(name + " may not be blank");
-        }
-        return argument;
-    }
-
-    public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) {
-        if (argument == null) {
-            throw new IllegalArgumentException(name + " may not be null");
-        }
-        if (TextUtils.containsBlanks(argument)) {
-            throw new IllegalArgumentException(name + " may not contain blanks");
-        }
-        return argument;
-    }
-
-    public static <E, T extends Collection<E>> T notEmpty(final T argument, final String name) {
-        if (argument == null) {
-            throw new IllegalArgumentException(name + " may not be null");
-        }
-        if (argument.isEmpty()) {
-            throw new IllegalArgumentException(name + " may not be empty");
-        }
-        return argument;
-    }
-
-    public static int positive(final int n, final String name) {
-        if (n <= 0) {
-            throw new IllegalArgumentException(name + " may not be negative or zero");
-        }
-        return n;
-    }
-
-    public static long positive(final long n, final String name) {
-        if (n <= 0) {
-            throw new IllegalArgumentException(name + " may not be negative or zero");
-        }
-        return n;
-    }
-
-    public static int notNegative(final int n, final String name) {
-        if (n < 0) {
-            throw new IllegalArgumentException(name + " may not be negative");
-        }
-        return n;
-    }
-
-    public static long notNegative(final long n, final String name) {
-        if (n < 0) {
-            throw new IllegalArgumentException(name + " may not be negative");
-        }
-        return n;
-    }
-
 }
-- 
GitLab