Class OkHostnameVerifier

java.lang.Object
com.neovisionaries.ws.client.OkHostnameVerifier
All Implemented Interfaces:
HostnameVerifier

final class OkHostnameVerifier extends Object implements HostnameVerifier
A HostnameVerifier consistent with RFC 2818.
  • Field Details

    • INSTANCE

      public static final OkHostnameVerifier INSTANCE
    • VERIFY_AS_IP_ADDRESS

      private static final Pattern VERIFY_AS_IP_ADDRESS
      Quick and dirty pattern to differentiate IP addresses from hostnames. This is an approximation of Android's private InetAddress#isNumeric API.

      This matches IPv6 addresses as a hex string containing at least one colon, and possibly including dots after the first colon. It matches IPv4 addresses as strings containing only decimal digits and dots. This pattern matches strings like "a:.23" and "54" that are neither IP addresses nor hostnames; they will be verified as IP addresses (which is a more strict verification).

    • ALT_DNS_NAME

      private static final int ALT_DNS_NAME
      See Also:
    • ALT_IPA_NAME

      private static final int ALT_IPA_NAME
      See Also:
  • Constructor Details

    • OkHostnameVerifier

      private OkHostnameVerifier()
  • Method Details

    • verify

      public boolean verify(String host, SSLSession session)
      Specified by:
      verify in interface HostnameVerifier
    • verify

      public boolean verify(String host, X509Certificate certificate)
    • verifyAsIpAddress

      static boolean verifyAsIpAddress(String host)
    • verifyIpAddress

      private boolean verifyIpAddress(String ipAddress, X509Certificate certificate)
      Returns true if certificate matches ipAddress.
    • verifyHostName

      private boolean verifyHostName(String hostName, X509Certificate certificate)
      Returns true if certificate matches hostName.
    • allSubjectAltNames

      public static List<String> allSubjectAltNames(X509Certificate certificate)
    • getSubjectAltNames

      private static List<String> getSubjectAltNames(X509Certificate certificate, int type)
    • verifyHostName

      private boolean verifyHostName(String hostName, String pattern)
      Returns true iff hostName matches the domain name pattern.
      Parameters:
      hostName - lower-case host name.
      pattern - domain name pattern from certificate. May be a wildcard pattern such as *.android.com.