Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277108

HCAPTCHA not supported in JRE 8

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u311
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
      web
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10 Edition Home / JRE 8 u 311

      A DESCRIPTION OF THE PROBLEM :
      HCAPTCHA not supported in JRE 8. HCAPTCHA is a component that detect robots webbrowser. JAVA FX is considered as a robot and can not log into the site -> <link>

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to log into <link> with WebView

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Blocked

      ---------- BEGIN SOURCE ----------
      package _TEST;

      import java.awt.BorderLayout;
      import java.io.File;
      import java.security.KeyManagementException;
      import java.security.NoSuchAlgorithmException;

      import javax.net.ssl.HostnameVerifier;
      import javax.net.ssl.HttpsURLConnection;
      import javax.net.ssl.SSLContext;
      import javax.net.ssl.SSLSession;
      import javax.net.ssl.TrustManager;
      import javax.net.ssl.X509TrustManager;
      import javax.swing.JFrame;
      import javax.swing.JPanel;

      import com.sun.javafx.application.PlatformImpl;

      import javafx.application.Platform;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.collections.ObservableList;
      import javafx.concurrent.Worker.State;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Group;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      class CL_SwingFXWebView extends JPanel {

      private static JFrame f = null;

      public static void main(String[] args) {
              f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel p = new CL_SwingFXWebView();
              f.getContentPane().add(p);
              f.setSize(800, 600);
              f.setVisible(true);
              
              ((CL_SwingFXWebView) p).load("<link>");
          }

      private static final long serialVersionUID = 8990771757800321056L;

      private Stage stage = null;
      private WebView browser = null;
      private JFXPanel jfxPanel = null;
      private WebEngine webEngine = null;

      public CL_SwingFXWebView() {
      jfxPanel = new JFXPanel();

      PlatformImpl.startup(new Runnable() {

      public void run() {
      stage = new Stage();
      Group root = new Group();
      Scene scene = new Scene(root);
      stage.setScene(scene);

      browser = new WebView();
      webEngine = browser.getEngine();
      webEngine.setUserDataDirectory(new File("."));
      webEngine.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5");
      webEngine.setJavaScriptEnabled(true);

      TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {

      public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1) throws java.security.cert.CertificateException {}

      public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {}

      public java.security.cert.X509Certificate[] getAcceptedIssuers() {
      return null;
      }
      }};

      SSLContext sc = null;
      try {
      sc = SSLContext.getInstance("SSL");
      sc.init(null, trustAllCerts, new java.security.SecureRandom());
      HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
      } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
      } catch (KeyManagementException e) {
      e.printStackTrace();
      }

      HostnameVerifier allHostsValid = new HostnameVerifier() {
      public boolean verify(String hostname, SSLSession session) {
      return true;
      }
      };

      HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);

      webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {

      public void changed(ObservableValue<? extends State> ov, State oldState, State newState) {

      if (newState == State.RUNNING) {
      }

      if (newState == State.SUCCEEDED) {
      f.setTitle(webEngine.getLocation());
      }
      }
      });

      webEngine.getLoadWorker().progressProperty().addListener(new ChangeListener<Number>() {

      public void changed(ObservableValue<? extends Number> ov, Number oldNumber, Number newNumber) {
      }
      });

      ObservableList<Node> children = root.getChildren();
      children.add(browser);

      jfxPanel.setScene(scene);
      }
      });

      setLayout(new BorderLayout());
      add(jfxPanel, BorderLayout.CENTER);
      }

      public void setPrefDimension(double _dWidth, double _dHeight) {
      if (browser != null) { browser.setPrefWidth(_dWidth);browser.setPrefHeight(_dHeight); }
      }

      public WebEngine getEngine() {
      return webEngine;
      }

      public void load(final String _sURL) {

      Platform.runLater(new Runnable() {

      public void run() {
      webEngine.load(_sURL);
      }
      });
      }

      public void reloadPage() {
      Platform.runLater(new Runnable() {

      public void run() {
      webEngine.reload();
      }
      });
      }

      public void navigateBack() {
      Platform.runLater(new Runnable() {

      public void run() {
      webEngine.executeScript("history.back()");
      }
      });
      }

      public void navigateForward() {
      Platform.runLater(new Runnable() {

      public void run() {
      webEngine.executeScript("history.forward()");
      }
      });
      }

      public void stopLoading() {

      Platform.runLater(new Runnable() {

      public void run() {
      webEngine.executeScript("window.stop()");
      }
      });
      }

      public String getHTMLContent() {
      return webEngine.executeScript("document.documentElement.innerHTML").toString();
      }

      public String getURL() {
      return webEngine.getLocation();
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pnarayanaswa Praveen Narayanaswamy
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: