// Path: app/src/main/java/fr/coding/tools/model/SslByPass.java
// public class SslByPass {
//     public String id;
//     public String CName;
//     public String Host;
//     public long ValidNotAfter;
//     public Date dtCreated;
//     public boolean activated;
// 
//     // default values
//     public SslByPass() {
//         id = UUID.randomUUID().toString();
//         activated = true;
//     }
// 
//     public String toString() {
//         return Host + (activated?"":" (NotAllowed)");
//     }
// 
//     public static SslByPass JSONobjToSslByPass(JSONObject jsonobj) throws JSONException {
//         SslByPass sslByPass = new SslByPass();
// 
//         if (jsonobj.has("id"))
//             sslByPass.id = jsonobj.getString("id");
// 
//         if (jsonobj.has("ValidNotAfter"))
//             sslByPass.ValidNotAfter = jsonobj.getLong("ValidNotAfter");
//         sslByPass.CName = jsonobj.getString("CName");
//         sslByPass.activated = jsonobj.getBoolean("activated");
// 
//         sslByPass.dtCreated = new Date();
//         if (jsonobj.has("dtCreated"))
//             sslByPass.dtCreated = new Date(jsonobj.getLong("dtCreated"));
// 
//         sslByPass.Host = "";
//         if (jsonobj.has("Host"))
//             sslByPass.Host = jsonobj.getString("Host");
// 
//         return sslByPass;
//     }
// 
//     public JSONObject toJSONobj() throws JSONException {
//         JSONObject jsonobj = new JSONObject();
//         jsonobj.put("id", id);
//         jsonobj.put("ValidNotAfter", ValidNotAfter);
//         jsonobj.put("CName", CName);
//         jsonobj.put("activated", activated);
//         jsonobj.put("dtCreated", dtCreated.getTime());
//         jsonobj.put("Host", Host);
//         return jsonobj;
//     }
// }


import android.net.http.SslError;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.widget.Toast;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.List;
import fr.coding.tools.model.SslByPass;

            // totally insecure
            if (completeByPass) {
                handler.proceed();
                return;
            }
            if (sslAllowed != null) {
                for (SslByPass sbp :
                        sslAllowed) {
                    // a little bit less insecure, but still insecure

                    if (error.getCertificate().getIssuedBy().getCName().equals(sbp.CName)
                            && (host.equals(sbp.Host))
                            && (error.getCertificate().getValidNotAfterDate().getTime() == sbp.ValidNotAfter)
                            && (error.getPrimaryError() == SslError.SSL_UNTRUSTED)
                            && (!error.hasError(SslError.SSL_IDMISMATCH)) && (!error.hasError(SslError.SSL_EXPIRED))) {
                        if (sbp.activated)
                            handler.proceed(); // Ignore SSL certificate errorse
                        else
                            Toast.makeText(view.getContext(), "SSL Certificate " + error.getCertificate().getIssuedBy().getCName() + " not allowed", Toast.LENGTH_LONG).show();
                        return;
                    }
                }
            }

            if (!error.hasError(SslError.SSL_IDMISMATCH) && (!error.hasError(SslError.SSL_EXPIRED))) {
                // Not Handled print error
                Toast.makeText(view.getContext(), "SSL not accepted CNAME : " + error.getCertificate().getIssuedBy().getCName() + ", hashcode : " + error.getCertificate().hashCode(), Toast.LENGTH_LONG).show();

                if (sslUnknownManager != null) {
// Path: app/src/main/java/fr/coding/tools/model/SslByPass.java
// public class SslByPass {
//     public String id;
//     public String CName;
//     public String Host;
//     public long ValidNotAfter;
//     public Date dtCreated;
//     public boolean activated;
// 
//     // default values
//     public SslByPass() {
//         id = UUID.randomUUID().toString();
//         activated = true;
//     }
// 
//     public String toString() {
//         return Host + (activated?"":" (NotAllowed)");
//     }
// 
//     public static SslByPass JSONobjToSslByPass(JSONObject jsonobj) throws JSONException {
//         SslByPass sslByPass = new SslByPass();
// 
//         if (jsonobj.has("id"))
//             sslByPass.id = jsonobj.getString("id");
// 
//         if (jsonobj.has("ValidNotAfter"))
//             sslByPass.ValidNotAfter = jsonobj.getLong("ValidNotAfter");
//         sslByPass.CName = jsonobj.getString("CName");
//         sslByPass.activated = jsonobj.getBoolean("activated");
// 
//         sslByPass.dtCreated = new Date();
//         if (jsonobj.has("dtCreated"))
//             sslByPass.dtCreated = new Date(jsonobj.getLong("dtCreated"));
// 
//         sslByPass.Host = "";
//         if (jsonobj.has("Host"))
//             sslByPass.Host = jsonobj.getString("Host");
// 
//         return sslByPass;
//     }
// 
//     public JSONObject toJSONobj() throws JSONException {
//         JSONObject jsonobj = new JSONObject();
//         jsonobj.put("id", id);
//         jsonobj.put("ValidNotAfter", ValidNotAfter);
//         jsonobj.put("CName", CName);
//         jsonobj.put("activated", activated);
//         jsonobj.put("dtCreated", dtCreated.getTime());
//         jsonobj.put("Host", Host);
//         return jsonobj;
//     }
// }


// Path: app/src/main/java/fr/coding/tools/SslWebView.java
import android.net.http.SslError;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.widget.Toast;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.List;
import fr.coding.tools.model.SslByPass;


            // totally insecure
            if (completeByPass) {
                handler.proceed();
                return;
            }
            if (sslAllowed != null) {
                for (SslByPass sbp :
                        sslAllowed) {
                    // a little bit less insecure, but still insecure

                    if (error.getCertificate().getIssuedBy().getCName().equals(sbp.CName)
                            && (host.equals(sbp.Host))
                            && (error.getCertificate().getValidNotAfterDate().getTime() == sbp.ValidNotAfter)
                            && (error.getPrimaryError() == SslError.SSL_UNTRUSTED)
                            && (!error.hasError(SslError.SSL_IDMISMATCH)) && (!error.hasError(SslError.SSL_EXPIRED))) {
                        if (sbp.activated)
                            handler.proceed(); // Ignore SSL certificate errorse
                        else
                            Toast.makeText(view.getContext(), "SSL Certificate " + error.getCertificate().getIssuedBy().getCName() + " not allowed", Toast.LENGTH_LONG).show();
                        return;
                    }
                }
            }

            if (!error.hasError(SslError.SSL_IDMISMATCH) && (!error.hasError(SslError.SSL_EXPIRED))) {
                // Not Handled print error
                Toast.makeText(view.getContext(), "SSL not accepted CNAME : " + error.getCertificate().getIssuedBy().getCName() + ", hashcode : " + error.getCertificate().hashCode(), Toast.LENGTH_LONG).show();

                if (sslUnknownManager != null) {
                    SslByPass byPass = new SslByPass();