Mods to remove additional Apache dependencies

and unneeded code, now compiles
This commit is contained in:
zzz
2015-04-25 22:56:51 +00:00
parent aaae72cf84
commit 26f89391d3
6 changed files with 6 additions and 104 deletions

View File

@@ -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;
}

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}
}