forked from I2P_Developers/i2p.i2p
Mods to remove additional Apache dependencies
and unneeded code, now compiles
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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() {
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user