WebView. Verify certificates. Save data

0

My code is as follows:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);

    //Activar Flecha ir atras
    getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);

    progressBar = (ProgressBar) findViewById(R.id.progressBar);

    webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);

    // Ajustamos la vista para que no se vea demasiado grande
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);

    // habilitamos el zoom
    webView.getSettings().setBuiltInZoomControls(true);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
            String message = "SSL Certificate error.";
            switch (error.getPrimaryError()) {
                case SslError.SSL_UNTRUSTED:
                    message = "The certificate authority is not trusted.";
                    break;
                case SslError.SSL_EXPIRED:
                    message = "The certificate has expired.";
                    break;
                case SslError.SSL_IDMISMATCH:
                    message = "The certificate Hostname mismatch.";
                    break;
                case SslError.SSL_NOTYETVALID:
                    message = "The certificate is not yet valid.";
                    break;
            }
            message += "\"SSL Certificate Error\" Do you want to continue anyway?.. YES";

            handler.proceed();
        }
    });

    webView.loadUrl("http://correo.ucf.edu.cu/owa");

    webView.setWebChromeClient(new WebChromeClient()
    {
        @Override
        public void onProgressChanged(WebView view, int progress)
        {
            progressBar.setProgress(0);
            progressBar.setVisibility(View.VISIBLE);
            progressBar.setProgress(progress*1000);
            progressBar.incrementProgressBy(progress);
            if(progress == 100)
            {
                progressBar.setVisibility(View.GONE);
            }
        }
    });
}

And I have two questions as I can verify the certificates of any web page and give accept or add security exception as firefox, and the other as I can save the information you enter in a web page login for example as firefox itself. Thanks for any answer to any of the two questions

    
asked by Alex Rivas 02.05.2018 в 17:51
source

0 answers