HostnameVerifier Interface

If the SSL or TLS implementation's standard hostname verification logic fails, the implementation will call the verify method of the class which implements this interface and is assigned to this HttpsURLConnection instance. If the callback class can determine that the hostname is acceptable given the parameters, it should report that the connection should be allowed. An unacceptable response will cause the connection to be terminated.

For example:
public class MyHostnameVerifier implements HostnameVerifier {
 public boolean verify(String hostname, SSLSession session) {
  // pop up an interactive dialog box
  // or insert additional matching logic
  if (good_address) {
   return true;
  } else {
   return false;
  }
 }
}

//...deleted...


HttpsURLConnection urlc = (HttpsURLConnection)
 (new URL("https://www.ibm.com/")).openConnection();
urlc.setHostnameVerifier(new MyHostnameVerifier());

See HttpsURLConnection Class for more information on how to assign the HostnameVerifier to the HttpsURLConnection.