tests/test_plugins/test_cert_plugins/testHostnameVerifier.java
<reponame>orgTestCodacy11KRepos110MB/repo-5196-qark<filename>tests/test_plugins/test_cert_plugins/testHostnameVerifier.javapackage test_plugins.test_cert_plugins;

public class testHostnameVerifier {
  public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new AllowAllHostnameVerifier();
}

public class testSetHostnameVerifier {
  public static void vulnerableMethod() {
    URL url = new URL("https://example.org/");
    HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection();
    urlConnection.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  }
  public static void nonVulnerableMethod() {
    URL url = new URL("https://example.org/");
    HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection();
    urlConnection.setHostnameVerifier(SSLSocketFactory.SOMETHING_ELSE);
  }
}
