Example usage for org.apache.http.conn.util InetAddressUtilsHC4 isIPv6Address

List of usage examples for org.apache.http.conn.util InetAddressUtilsHC4 isIPv6Address

Introduction

In this page you can find the example usage for org.apache.http.conn.util InetAddressUtilsHC4 isIPv6Address.

Prototype

public static boolean isIPv6Address(final String input) 

Source Link

Document

Checks whether the parameter is a valid IPv6 address (including compressed).

Usage

From source file:de.vanita5.twittnuker.util.net.TwidereHostAddressResolver.java

private static boolean isValidIpAddress(final String address) {
    if (isEmpty(address))
        return false;
    return InetAddressUtilsHC4.isIPv4Address(address) || InetAddressUtilsHC4.isIPv6Address(address);
}

From source file:de.vanita5.twittnuker.util.net.ssl.AbstractCheckSignatureVerifier.java

private static boolean isIPAddress(final String hostname) {
    return hostname != null
            && (InetAddressUtilsHC4.isIPv4Address(hostname) || InetAddressUtilsHC4.isIPv6Address(hostname));
}

From source file:de.vanita5.twittnuker.util.net.ssl.AbstractCheckSignatureVerifier.java

private static String normaliseIPv6Address(final String hostname) {
    if (hostname == null || !InetAddressUtilsHC4.isIPv6Address(hostname))
        return hostname;
    try {//  w  ww  . j a v  a 2s  .  co  m
        final InetAddress inetAddress = InetAddress.getByName(hostname);
        return inetAddress.getHostAddress();
    } catch (final UnknownHostException uhe) { // Should not happen, because
        // we check for IPv6 address
        // above
        Log.e(TAG, "Unexpected error converting " + hostname, uhe);
        return hostname;
    }
}