001package Torello.Browser;
002
003import java.util.*;
004import javax.json.*;
005import javax.json.stream.*;
006import java.io.*;
007
008import java.lang.reflect.Method;
009import java.lang.reflect.Parameter;
010import java.util.function.Function;
011
012import Torello.Java.Additional.*;
013
014import static Torello.Java.Additional.JFlag.*;
015
016import Torello.Java.StrCmpr;
017import Torello.JavaDoc.StaticFunctional;
018import Torello.JavaDoc.JDHeaderBackgroundImg;
019import Torello.JavaDoc.Excuse;
020
021/**
022 * <SPAN CLASS=CopiedJDK><B>Security</B></SPAN>
023 * 
024 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
025 */
026@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
027@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
028public class Security
029{
030    // ********************************************************************************************
031    // ********************************************************************************************
032    // Class Header Stuff
033    // ********************************************************************************************
034    // ********************************************************************************************
035
036
037    // No Pubic Constructors
038    private Security () { }
039
040    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
041    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
042    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
043    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
044
045    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
046    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
047    // offically, two empty-vectors.  One for String's, and the other for Classes.
048
049    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
050    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
051
052    static
053    {
054        for (Method m : Security.class.getMethods())
055        {
056            // This doesn't work!  The parameter names are all "arg0" ... "argN"
057            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
058            //
059            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
060
061            Vector<Class<?>> parameterTypesList = new Vector<>();
062        
063            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
064
065            parameterTypes.put(
066                m.getName(),
067                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
068            );
069        }
070    }
071
072    static
073    {
074        Vector<String> v = null;
075
076        parameterNames.put("disable", EMPTY_VEC_STR);
077
078        parameterNames.put("enable", EMPTY_VEC_STR);
079
080        v = new Vector<String>(1);
081        parameterNames.put("setIgnoreCertificateErrors", v);
082        Collections.addAll(v, new String[]
083        { "ignore", });
084
085        v = new Vector<String>(2);
086        parameterNames.put("handleCertificateError", v);
087        Collections.addAll(v, new String[]
088        { "eventId", "action", });
089
090        v = new Vector<String>(1);
091        parameterNames.put("setOverrideCertificateErrors", v);
092        Collections.addAll(v, new String[]
093        { "override", });
094    }
095
096
097    // ********************************************************************************************
098    // ********************************************************************************************
099    // Types - Static Inner Classes
100    // ********************************************************************************************
101    // ********************************************************************************************
102
103    // public static class CertificateId => Integer
104    
105    /**
106     * A description of mixed content (HTTP resources on HTTPS pages), as defined by
107     * https://www.w3.org/TR/mixed-content/#categories
108     */
109    public static final String[] MixedContentType =
110    { "blockable", "optionally-blockable", "none", };
111    
112    /** The security level of a page or resource. */
113    public static final String[] SecurityState =
114    { "unknown", "neutral", "insecure", "secure", "info", "insecure-broken", };
115    
116    /**
117     * <CODE>[No Description Provided by Google]</CODE>
118     * <BR />
119     * <BR /><B>EXPERIMENTAL</B>
120     */
121    public static final String[] SafetyTipStatus =
122    { "badReputation", "lookalike", };
123    
124    /**
125     * The action to take when a certificate error occurs. continue will continue processing the
126     * request and cancel will cancel the request.
127     */
128    public static final String[] CertificateErrorAction =
129    { "continue", "cancel", };
130    
131    /**
132     * Details about the security state of the page certificate.
133     * <BR />
134     * <BR /><B>EXPERIMENTAL</B>
135     */
136    public static class CertificateSecurityState extends BaseType
137    {
138        /** For Object Serialization.  java.io.Serializable */
139        protected static final long serialVersionUID = 1;
140        
141        public boolean[] optionals()
142        { return new boolean[] { false, false, true, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, }; }
143        
144        /** Protocol name (e.g. "TLS 1.2" or "QUIC"). */
145        public final String protocol;
146        
147        /** Key Exchange used by the connection, or the empty string if not applicable. */
148        public final String keyExchange;
149        
150        /**
151         * (EC)DH group used by the connection, if applicable.
152         * <BR />
153         * <BR /><B>OPTIONAL</B>
154         */
155        public final String keyExchangeGroup;
156        
157        /** Cipher name. */
158        public final String cipher;
159        
160        /**
161         * TLS MAC. Note that AEAD ciphers do not have separate MACs.
162         * <BR />
163         * <BR /><B>OPTIONAL</B>
164         */
165        public final String mac;
166        
167        /** Page certificate. */
168        public final String[] certificate;
169        
170        /** Certificate subject name. */
171        public final String subjectName;
172        
173        /** Name of the issuing CA. */
174        public final String issuer;
175        
176        /** Certificate valid from date. */
177        public final Number validFrom;
178        
179        /** Certificate valid to (expiration) date */
180        public final Number validTo;
181        
182        /**
183         * The highest priority network error code, if the certificate has an error.
184         * <BR />
185         * <BR /><B>OPTIONAL</B>
186         */
187        public final String certificateNetworkError;
188        
189        /** True if the certificate uses a weak signature aglorithm. */
190        public final boolean certificateHasWeakSignature;
191        
192        /** True if the certificate has a SHA1 signature in the chain. */
193        public final boolean certificateHasSha1Signature;
194        
195        /** True if modern SSL */
196        public final boolean modernSSL;
197        
198        /** True if the connection is using an obsolete SSL protocol. */
199        public final boolean obsoleteSslProtocol;
200        
201        /** True if the connection is using an obsolete SSL key exchange. */
202        public final boolean obsoleteSslKeyExchange;
203        
204        /** True if the connection is using an obsolete SSL cipher. */
205        public final boolean obsoleteSslCipher;
206        
207        /** True if the connection is using an obsolete SSL signature. */
208        public final boolean obsoleteSslSignature;
209        
210        /**
211         * Constructor
212         *
213         * @param protocol Protocol name (e.g. "TLS 1.2" or "QUIC").
214         * 
215         * @param keyExchange Key Exchange used by the connection, or the empty string if not applicable.
216         * 
217         * @param keyExchangeGroup (EC)DH group used by the connection, if applicable.
218         * <BR /><B>OPTIONAL</B>
219         * 
220         * @param cipher Cipher name.
221         * 
222         * @param mac TLS MAC. Note that AEAD ciphers do not have separate MACs.
223         * <BR /><B>OPTIONAL</B>
224         * 
225         * @param certificate Page certificate.
226         * 
227         * @param subjectName Certificate subject name.
228         * 
229         * @param issuer Name of the issuing CA.
230         * 
231         * @param validFrom Certificate valid from date.
232         * 
233         * @param validTo Certificate valid to (expiration) date
234         * 
235         * @param certificateNetworkError The highest priority network error code, if the certificate has an error.
236         * <BR /><B>OPTIONAL</B>
237         * 
238         * @param certificateHasWeakSignature True if the certificate uses a weak signature aglorithm.
239         * 
240         * @param certificateHasSha1Signature True if the certificate has a SHA1 signature in the chain.
241         * 
242         * @param modernSSL True if modern SSL
243         * 
244         * @param obsoleteSslProtocol True if the connection is using an obsolete SSL protocol.
245         * 
246         * @param obsoleteSslKeyExchange True if the connection is using an obsolete SSL key exchange.
247         * 
248         * @param obsoleteSslCipher True if the connection is using an obsolete SSL cipher.
249         * 
250         * @param obsoleteSslSignature True if the connection is using an obsolete SSL signature.
251         */
252        public CertificateSecurityState(
253                String protocol, String keyExchange, String keyExchangeGroup, String cipher, 
254                String mac, String[] certificate, String subjectName, String issuer, 
255                Number validFrom, Number validTo, String certificateNetworkError, 
256                boolean certificateHasWeakSignature, boolean certificateHasSha1Signature, 
257                boolean modernSSL, boolean obsoleteSslProtocol, boolean obsoleteSslKeyExchange, 
258                boolean obsoleteSslCipher, boolean obsoleteSslSignature
259            )
260        {
261            // Exception-Check(s) to ensure that if any parameters which are not declared as
262            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
263            
264            if (protocol == null)    BRDPC.throwNPE("protocol");
265            if (keyExchange == null) BRDPC.throwNPE("keyExchange");
266            if (cipher == null)      BRDPC.throwNPE("cipher");
267            if (certificate == null) BRDPC.throwNPE("certificate");
268            if (subjectName == null) BRDPC.throwNPE("subjectName");
269            if (issuer == null)      BRDPC.throwNPE("issuer");
270            if (validFrom == null)   BRDPC.throwNPE("validFrom");
271            if (validTo == null)     BRDPC.throwNPE("validTo");
272            
273            this.protocol                     = protocol;
274            this.keyExchange                  = keyExchange;
275            this.keyExchangeGroup             = keyExchangeGroup;
276            this.cipher                       = cipher;
277            this.mac                          = mac;
278            this.certificate                  = certificate;
279            this.subjectName                  = subjectName;
280            this.issuer                       = issuer;
281            this.validFrom                    = validFrom;
282            this.validTo                      = validTo;
283            this.certificateNetworkError      = certificateNetworkError;
284            this.certificateHasWeakSignature  = certificateHasWeakSignature;
285            this.certificateHasSha1Signature  = certificateHasSha1Signature;
286            this.modernSSL                    = modernSSL;
287            this.obsoleteSslProtocol          = obsoleteSslProtocol;
288            this.obsoleteSslKeyExchange       = obsoleteSslKeyExchange;
289            this.obsoleteSslCipher            = obsoleteSslCipher;
290            this.obsoleteSslSignature         = obsoleteSslSignature;
291        }
292        
293        /**
294         * JSON Object Constructor
295         * @param jo A Json-Object having data about an instance of {@code 'CertificateSecurityState'}.
296         */
297        public CertificateSecurityState (JsonObject jo)
298        {
299            this.protocol                     = ReadJSON.getString(jo, "protocol", false, true);
300            this.keyExchange                  = ReadJSON.getString(jo, "keyExchange", false, true);
301            this.keyExchangeGroup             = ReadJSON.getString(jo, "keyExchangeGroup", true, false);
302            this.cipher                       = ReadJSON.getString(jo, "cipher", false, true);
303            this.mac                          = ReadJSON.getString(jo, "mac", true, false);
304            this.certificate                  = (jo.getJsonArray("certificate") == null)
305            ? null
306            : ReadArrJSON.DimN.strArr(jo.getJsonArray("certificate"), null, 0, String[].class);
307            this.subjectName                  = ReadJSON.getString(jo, "subjectName", false, true);
308            this.issuer                       = ReadJSON.getString(jo, "issuer", false, true);
309            this.validFrom                    = ReadJSON.getNUMBER(jo, "validFrom", false, true);
310            this.validTo                      = ReadJSON.getNUMBER(jo, "validTo", false, true);
311            this.certificateNetworkError      = ReadJSON.getString(jo, "certificateNetworkError", true, false);
312            this.certificateHasWeakSignature  = ReadJSON.getBoolean(jo, "certificateHasWeakSignature");
313            this.certificateHasSha1Signature  = ReadJSON.getBoolean(jo, "certificateHasSha1Signature");
314            this.modernSSL                    = ReadJSON.getBoolean(jo, "modernSSL");
315            this.obsoleteSslProtocol          = ReadJSON.getBoolean(jo, "obsoleteSslProtocol");
316            this.obsoleteSslKeyExchange       = ReadJSON.getBoolean(jo, "obsoleteSslKeyExchange");
317            this.obsoleteSslCipher            = ReadJSON.getBoolean(jo, "obsoleteSslCipher");
318            this.obsoleteSslSignature         = ReadJSON.getBoolean(jo, "obsoleteSslSignature");
319        }
320        
321    }
322    
323    /**
324     * <CODE>[No Description Provided by Google]</CODE>
325     * <BR />
326     * <BR /><B>EXPERIMENTAL</B>
327     */
328    public static class SafetyTipInfo extends BaseType
329    {
330        /** For Object Serialization.  java.io.Serializable */
331        protected static final long serialVersionUID = 1;
332        
333        public boolean[] optionals()
334        { return new boolean[] { false, true, }; }
335        
336        /** Describes whether the page triggers any safety tips or reputation warnings. Default is unknown. */
337        public final String safetyTipStatus;
338        
339        /**
340         * The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches.
341         * <BR />
342         * <BR /><B>OPTIONAL</B>
343         */
344        public final String safeUrl;
345        
346        /**
347         * Constructor
348         *
349         * @param safetyTipStatus Describes whether the page triggers any safety tips or reputation warnings. Default is unknown.
350         * 
351         * @param safeUrl The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches.
352         * <BR /><B>OPTIONAL</B>
353         */
354        public SafetyTipInfo(String safetyTipStatus, String safeUrl)
355        {
356            // Exception-Check(s) to ensure that if any parameters which are not declared as
357            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
358            
359            if (safetyTipStatus == null) BRDPC.throwNPE("safetyTipStatus");
360            
361            // Exception-Check(s) to ensure that if any parameters which must adhere to a
362            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
363            
364            BRDPC.checkIAE("safetyTipStatus", safetyTipStatus, "Security.SafetyTipStatus", Security.SafetyTipStatus);
365            
366            this.safetyTipStatus  = safetyTipStatus;
367            this.safeUrl          = safeUrl;
368        }
369        
370        /**
371         * JSON Object Constructor
372         * @param jo A Json-Object having data about an instance of {@code 'SafetyTipInfo'}.
373         */
374        public SafetyTipInfo (JsonObject jo)
375        {
376            this.safetyTipStatus  = ReadJSON.getString(jo, "safetyTipStatus", false, true);
377            this.safeUrl          = ReadJSON.getString(jo, "safeUrl", true, false);
378        }
379        
380    }
381    
382    /**
383     * Security state information about the page.
384     * <BR />
385     * <BR /><B>EXPERIMENTAL</B>
386     */
387    public static class VisibleSecurityState extends BaseType
388    {
389        /** For Object Serialization.  java.io.Serializable */
390        protected static final long serialVersionUID = 1;
391        
392        public boolean[] optionals()
393        { return new boolean[] { false, true, true, false, }; }
394        
395        /** The security level of the page. */
396        public final String securityState;
397        
398        /**
399         * Security state details about the page certificate.
400         * <BR />
401         * <BR /><B>OPTIONAL</B>
402         */
403        public final Security.CertificateSecurityState certificateSecurityState;
404        
405        /**
406         * The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown.
407         * <BR />
408         * <BR /><B>OPTIONAL</B>
409         */
410        public final Security.SafetyTipInfo safetyTipInfo;
411        
412        /** Array of security state issues ids. */
413        public final String[] securityStateIssueIds;
414        
415        /**
416         * Constructor
417         *
418         * @param securityState The security level of the page.
419         * 
420         * @param certificateSecurityState Security state details about the page certificate.
421         * <BR /><B>OPTIONAL</B>
422         * 
423         * @param safetyTipInfo The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown.
424         * <BR /><B>OPTIONAL</B>
425         * 
426         * @param securityStateIssueIds Array of security state issues ids.
427         */
428        public VisibleSecurityState(
429                String securityState, Security.CertificateSecurityState certificateSecurityState, 
430                Security.SafetyTipInfo safetyTipInfo, String[] securityStateIssueIds
431            )
432        {
433            // Exception-Check(s) to ensure that if any parameters which are not declared as
434            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
435            
436            if (securityState == null)         BRDPC.throwNPE("securityState");
437            if (securityStateIssueIds == null) BRDPC.throwNPE("securityStateIssueIds");
438            
439            // Exception-Check(s) to ensure that if any parameters which must adhere to a
440            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
441            
442            BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState);
443            
444            this.securityState             = securityState;
445            this.certificateSecurityState  = certificateSecurityState;
446            this.safetyTipInfo             = safetyTipInfo;
447            this.securityStateIssueIds     = securityStateIssueIds;
448        }
449        
450        /**
451         * JSON Object Constructor
452         * @param jo A Json-Object having data about an instance of {@code 'VisibleSecurityState'}.
453         */
454        public VisibleSecurityState (JsonObject jo)
455        {
456            this.securityState             = ReadJSON.getString(jo, "securityState", false, true);
457            this.certificateSecurityState  = ReadJSON.XL.getObject(jo, "certificateSecurityState", Security.CertificateSecurityState.class, true, false);
458            this.safetyTipInfo             = ReadJSON.XL.getObject(jo, "safetyTipInfo", Security.SafetyTipInfo.class, true, false);
459            this.securityStateIssueIds     = (jo.getJsonArray("securityStateIssueIds") == null)
460            ? null
461            : ReadArrJSON.DimN.strArr(jo.getJsonArray("securityStateIssueIds"), null, 0, String[].class);
462        }
463        
464    }
465    
466    /** An explanation of an factor contributing to the security state. */
467    public static class SecurityStateExplanation extends BaseType
468    {
469        /** For Object Serialization.  java.io.Serializable */
470        protected static final long serialVersionUID = 1;
471        
472        public boolean[] optionals()
473        { return new boolean[] { false, false, false, false, false, false, true, }; }
474        
475        /** Security state representing the severity of the factor being explained. */
476        public final String securityState;
477        
478        /** Title describing the type of factor. */
479        public final String title;
480        
481        /** Short phrase describing the type of factor. */
482        public final String summary;
483        
484        /** Full text explanation of the factor. */
485        public final String description;
486        
487        /** The type of mixed content described by the explanation. */
488        public final String mixedContentType;
489        
490        /** Page certificate. */
491        public final String[] certificate;
492        
493        /**
494         * Recommendations to fix any issues.
495         * <BR />
496         * <BR /><B>OPTIONAL</B>
497         */
498        public final String[] recommendations;
499        
500        /**
501         * Constructor
502         *
503         * @param securityState Security state representing the severity of the factor being explained.
504         * 
505         * @param title Title describing the type of factor.
506         * 
507         * @param summary Short phrase describing the type of factor.
508         * 
509         * @param description Full text explanation of the factor.
510         * 
511         * @param mixedContentType The type of mixed content described by the explanation.
512         * 
513         * @param certificate Page certificate.
514         * 
515         * @param recommendations Recommendations to fix any issues.
516         * <BR /><B>OPTIONAL</B>
517         */
518        public SecurityStateExplanation(
519                String securityState, String title, String summary, String description, 
520                String mixedContentType, String[] certificate, String[] recommendations
521            )
522        {
523            // Exception-Check(s) to ensure that if any parameters which are not declared as
524            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
525            
526            if (securityState == null)    BRDPC.throwNPE("securityState");
527            if (title == null)            BRDPC.throwNPE("title");
528            if (summary == null)          BRDPC.throwNPE("summary");
529            if (description == null)      BRDPC.throwNPE("description");
530            if (mixedContentType == null) BRDPC.throwNPE("mixedContentType");
531            if (certificate == null)      BRDPC.throwNPE("certificate");
532            
533            // Exception-Check(s) to ensure that if any parameters which must adhere to a
534            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
535            
536            BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState);
537            BRDPC.checkIAE("mixedContentType", mixedContentType, "Security.MixedContentType", Security.MixedContentType);
538            
539            this.securityState     = securityState;
540            this.title             = title;
541            this.summary           = summary;
542            this.description       = description;
543            this.mixedContentType  = mixedContentType;
544            this.certificate       = certificate;
545            this.recommendations   = recommendations;
546        }
547        
548        /**
549         * JSON Object Constructor
550         * @param jo A Json-Object having data about an instance of {@code 'SecurityStateExplanation'}.
551         */
552        public SecurityStateExplanation (JsonObject jo)
553        {
554            this.securityState     = ReadJSON.getString(jo, "securityState", false, true);
555            this.title             = ReadJSON.getString(jo, "title", false, true);
556            this.summary           = ReadJSON.getString(jo, "summary", false, true);
557            this.description       = ReadJSON.getString(jo, "description", false, true);
558            this.mixedContentType  = ReadJSON.getString(jo, "mixedContentType", false, true);
559            this.certificate       = (jo.getJsonArray("certificate") == null)
560            ? null
561            : ReadArrJSON.DimN.strArr(jo.getJsonArray("certificate"), null, 0, String[].class);
562            this.recommendations   = (jo.getJsonArray("recommendations") == null)
563            ? null
564            : ReadArrJSON.DimN.strArr(jo.getJsonArray("recommendations"), null, 0, String[].class);
565        }
566        
567    }
568    
569    /**
570     * Information about insecure content on the page.
571     * <BR />
572     * <BR /><B>DEPRECATED</B>
573     */
574    public static class InsecureContentStatus extends BaseType
575    {
576        /** For Object Serialization.  java.io.Serializable */
577        protected static final long serialVersionUID = 1;
578        
579        public boolean[] optionals()
580        { return new boolean[] { false, false, false, false, false, false, false, }; }
581        
582        /** Always false. */
583        public final boolean ranMixedContent;
584        
585        /** Always false. */
586        public final boolean displayedMixedContent;
587        
588        /** Always false. */
589        public final boolean containedMixedForm;
590        
591        /** Always false. */
592        public final boolean ranContentWithCertErrors;
593        
594        /** Always false. */
595        public final boolean displayedContentWithCertErrors;
596        
597        /** Always set to unknown. */
598        public final String ranInsecureContentStyle;
599        
600        /** Always set to unknown. */
601        public final String displayedInsecureContentStyle;
602        
603        /**
604         * Constructor
605         *
606         * @param ranMixedContent Always false.
607         * 
608         * @param displayedMixedContent Always false.
609         * 
610         * @param containedMixedForm Always false.
611         * 
612         * @param ranContentWithCertErrors Always false.
613         * 
614         * @param displayedContentWithCertErrors Always false.
615         * 
616         * @param ranInsecureContentStyle Always set to unknown.
617         * 
618         * @param displayedInsecureContentStyle Always set to unknown.
619         */
620        public InsecureContentStatus(
621                boolean ranMixedContent, boolean displayedMixedContent, boolean containedMixedForm, 
622                boolean ranContentWithCertErrors, boolean displayedContentWithCertErrors, 
623                String ranInsecureContentStyle, String displayedInsecureContentStyle
624            )
625        {
626            // Exception-Check(s) to ensure that if any parameters which are not declared as
627            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
628            
629            if (ranInsecureContentStyle == null)       BRDPC.throwNPE("ranInsecureContentStyle");
630            if (displayedInsecureContentStyle == null) BRDPC.throwNPE("displayedInsecureContentStyle");
631            
632            // Exception-Check(s) to ensure that if any parameters which must adhere to a
633            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
634            
635            BRDPC.checkIAE("ranInsecureContentStyle", ranInsecureContentStyle, "Security.SecurityState", Security.SecurityState);
636            BRDPC.checkIAE("displayedInsecureContentStyle", displayedInsecureContentStyle, "Security.SecurityState", Security.SecurityState);
637            
638            this.ranMixedContent                 = ranMixedContent;
639            this.displayedMixedContent           = displayedMixedContent;
640            this.containedMixedForm              = containedMixedForm;
641            this.ranContentWithCertErrors        = ranContentWithCertErrors;
642            this.displayedContentWithCertErrors  = displayedContentWithCertErrors;
643            this.ranInsecureContentStyle         = ranInsecureContentStyle;
644            this.displayedInsecureContentStyle   = displayedInsecureContentStyle;
645        }
646        
647        /**
648         * JSON Object Constructor
649         * @param jo A Json-Object having data about an instance of {@code 'InsecureContentStatus'}.
650         */
651        public InsecureContentStatus (JsonObject jo)
652        {
653            this.ranMixedContent                 = ReadJSON.getBoolean(jo, "ranMixedContent");
654            this.displayedMixedContent           = ReadJSON.getBoolean(jo, "displayedMixedContent");
655            this.containedMixedForm              = ReadJSON.getBoolean(jo, "containedMixedForm");
656            this.ranContentWithCertErrors        = ReadJSON.getBoolean(jo, "ranContentWithCertErrors");
657            this.displayedContentWithCertErrors  = ReadJSON.getBoolean(jo, "displayedContentWithCertErrors");
658            this.ranInsecureContentStyle         = ReadJSON.getString(jo, "ranInsecureContentStyle", false, true);
659            this.displayedInsecureContentStyle   = ReadJSON.getString(jo, "displayedInsecureContentStyle", false, true);
660        }
661        
662    }
663    
664    /**
665     * There is a certificate error. If overriding certificate errors is enabled, then it should be
666     * handled with the <CODE>handleCertificateError</CODE> command. Note: this event does not fire if the
667     * certificate error has been allowed internally. Only one client per target should override
668     * certificate errors at the same time.
669     * <BR />
670     * <BR /><B>DEPRECATED</B>
671     */
672    public static class certificateError extends BrowserEvent
673    {
674        /** For Object Serialization.  java.io.Serializable */
675        protected static final long serialVersionUID = 1;
676        
677        public boolean[] optionals()
678        { return new boolean[] { false, false, false, }; }
679        
680        /** The ID of the event. */
681        public final int eventId;
682        
683        /** The type of the error. */
684        public final String errorType;
685        
686        /** The url that was requested. */
687        public final String requestURL;
688        
689        /**
690         * Constructor
691         *
692         * @param eventId The ID of the event.
693         * 
694         * @param errorType The type of the error.
695         * 
696         * @param requestURL The url that was requested.
697         */
698        public certificateError(int eventId, String errorType, String requestURL)
699        {
700            super("Security", "certificateError", 3);
701            
702            // Exception-Check(s) to ensure that if any parameters which are not declared as
703            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
704            
705            if (errorType == null)  BRDPC.throwNPE("errorType");
706            if (requestURL == null) BRDPC.throwNPE("requestURL");
707            
708            this.eventId     = eventId;
709            this.errorType   = errorType;
710            this.requestURL  = requestURL;
711        }
712        
713        /**
714         * JSON Object Constructor
715         * @param jo A Json-Object having data about an instance of {@code 'certificateError'}.
716         */
717        public certificateError (JsonObject jo)
718        {
719            super("Security", "certificateError", 3);
720        
721            this.eventId     = ReadJSON.getInt(jo, "eventId");
722            this.errorType   = ReadJSON.getString(jo, "errorType", false, true);
723            this.requestURL  = ReadJSON.getString(jo, "requestURL", false, true);
724        }
725        
726    }
727    
728    /**
729     * The security state of the page changed.
730     * <BR />
731     * <BR /><B>EXPERIMENTAL</B>
732     */
733    public static class visibleSecurityStateChanged extends BrowserEvent
734    {
735        /** For Object Serialization.  java.io.Serializable */
736        protected static final long serialVersionUID = 1;
737        
738        public boolean[] optionals()
739        { return new boolean[] { false, }; }
740        
741        /** Security state information about the page. */
742        public final Security.VisibleSecurityState visibleSecurityState;
743        
744        /**
745         * Constructor
746         *
747         * @param visibleSecurityState Security state information about the page.
748         */
749        public visibleSecurityStateChanged(Security.VisibleSecurityState visibleSecurityState)
750        {
751            super("Security", "visibleSecurityStateChanged", 1);
752            
753            // Exception-Check(s) to ensure that if any parameters which are not declared as
754            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
755            
756            if (visibleSecurityState == null) BRDPC.throwNPE("visibleSecurityState");
757            
758            this.visibleSecurityState  = visibleSecurityState;
759        }
760        
761        /**
762         * JSON Object Constructor
763         * @param jo A Json-Object having data about an instance of {@code 'visibleSecurityStateChanged'}.
764         */
765        public visibleSecurityStateChanged (JsonObject jo)
766        {
767            super("Security", "visibleSecurityStateChanged", 1);
768        
769            this.visibleSecurityState  = ReadJSON.XL.getObject(jo, "visibleSecurityState", Security.VisibleSecurityState.class, false, true);
770        }
771        
772    }
773    
774    /** The security state of the page changed. */
775    public static class securityStateChanged extends BrowserEvent
776    {
777        /** For Object Serialization.  java.io.Serializable */
778        protected static final long serialVersionUID = 1;
779        
780        public boolean[] optionals()
781        { return new boolean[] { false, false, false, false, true, }; }
782        
783        /** Security state. */
784        public final String securityState;
785        
786        /**
787         * True if the page was loaded over cryptographic transport such as HTTPS.
788         * <BR />
789         * <BR /><B>DEPRECATED</B>
790         */
791        public final boolean schemeIsCryptographic;
792        
793        /**
794         * List of explanations for the security state. If the overall security state is <CODE>insecure</CODE> or
795         * <CODE>warning</CODE>, at least one corresponding explanation should be included.
796         */
797        public final Security.SecurityStateExplanation[] explanations;
798        
799        /**
800         * Information about insecure content on the page.
801         * <BR />
802         * <BR /><B>DEPRECATED</B>
803         */
804        public final Security.InsecureContentStatus insecureContentStatus;
805        
806        /**
807         * Overrides user-visible description of the state.
808         * <BR />
809         * <BR /><B>OPTIONAL</B>
810         */
811        public final String summary;
812        
813        /**
814         * Constructor
815         *
816         * @param securityState Security state.
817         * 
818         * @param schemeIsCryptographic True if the page was loaded over cryptographic transport such as HTTPS.
819         * <BR /><B>DEPRECATED</B>
820         * 
821         * @param explanations 
822         * List of explanations for the security state. If the overall security state is <CODE>insecure</CODE> or
823         * <CODE>warning</CODE>, at least one corresponding explanation should be included.
824         * 
825         * @param insecureContentStatus Information about insecure content on the page.
826         * <BR /><B>DEPRECATED</B>
827         * 
828         * @param summary Overrides user-visible description of the state.
829         * <BR /><B>OPTIONAL</B>
830         */
831        public securityStateChanged(
832                String securityState, boolean schemeIsCryptographic, 
833                Security.SecurityStateExplanation[] explanations, 
834                Security.InsecureContentStatus insecureContentStatus, String summary
835            )
836        {
837            super("Security", "securityStateChanged", 5);
838            
839            // Exception-Check(s) to ensure that if any parameters which are not declared as
840            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
841            
842            if (securityState == null)         BRDPC.throwNPE("securityState");
843            if (explanations == null)          BRDPC.throwNPE("explanations");
844            if (insecureContentStatus == null) BRDPC.throwNPE("insecureContentStatus");
845            
846            // Exception-Check(s) to ensure that if any parameters which must adhere to a
847            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
848            
849            BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState);
850            
851            this.securityState          = securityState;
852            this.schemeIsCryptographic  = schemeIsCryptographic;
853            this.explanations           = explanations;
854            this.insecureContentStatus  = insecureContentStatus;
855            this.summary                = summary;
856        }
857        
858        /**
859         * JSON Object Constructor
860         * @param jo A Json-Object having data about an instance of {@code 'securityStateChanged'}.
861         */
862        public securityStateChanged (JsonObject jo)
863        {
864            super("Security", "securityStateChanged", 5);
865        
866            this.securityState          = ReadJSON.getString(jo, "securityState", false, true);
867            this.schemeIsCryptographic  = ReadJSON.getBoolean(jo, "schemeIsCryptographic");
868            this.explanations           = (jo.getJsonArray("explanations") == null)
869            ? null
870            : ReadArrJSON.DimN.objArr(jo.getJsonArray("explanations"), null, 0, Security.SecurityStateExplanation[].class);
871            this.insecureContentStatus  = ReadJSON.XL.getObject(jo, "insecureContentStatus", Security.InsecureContentStatus.class, false, true);
872            this.summary                = ReadJSON.getString(jo, "summary", true, false);
873        }
874        
875    }
876    
877    
878    // Counter for keeping the WebSocket Request ID's distinct.
879    private static int counter = 1;
880    
881    /**
882     * Disables tracking security state changes.
883     * 
884     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
885     * {@link Ret0}&gt;</CODE>
886     *
887     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
888     * browser receives the invocation-request.
889     *
890     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
891     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
892     * {@code >} to ensure the Browser Function has run to completion.
893     */
894    public static Script<String, JsonObject, Ret0> disable()
895    {
896        final int          webSocketID = 35000000 + counter++;
897        final boolean[]    optionals   = new boolean[0];
898        
899        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
900        String requestJSON = WriteJSON.get(
901            parameterTypes.get("disable"),
902            parameterNames.get("disable"),
903            optionals, webSocketID,
904            "Security.disable"
905        );
906        
907        // This Remote Command does not have a Return-Value.
908        return new Script<>
909            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
910    }
911    
912    /**
913     * Enables tracking security state changes.
914     * 
915     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
916     * {@link Ret0}&gt;</CODE>
917     *
918     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
919     * browser receives the invocation-request.
920     *
921     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
922     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
923     * {@code >} to ensure the Browser Function has run to completion.
924     */
925    public static Script<String, JsonObject, Ret0> enable()
926    {
927        final int          webSocketID = 35001000 + counter++;
928        final boolean[]    optionals   = new boolean[0];
929        
930        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
931        String requestJSON = WriteJSON.get(
932            parameterTypes.get("enable"),
933            parameterNames.get("enable"),
934            optionals, webSocketID,
935            "Security.enable"
936        );
937        
938        // This Remote Command does not have a Return-Value.
939        return new Script<>
940            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
941    }
942    
943    /**
944     * Enable/disable whether all certificate errors should be ignored.
945     * <BR /><B>EXPERIMENTAL</B>
946     * 
947     * @param ignore If true, all certificate errors will be ignored.
948     * 
949     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
950     * {@link Ret0}&gt;</CODE>
951     *
952     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
953     * browser receives the invocation-request.
954     *
955     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
956     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
957     * {@code >} to ensure the Browser Function has run to completion.
958     */
959    public static Script<String, JsonObject, Ret0> setIgnoreCertificateErrors(boolean ignore)
960    {
961        final int       webSocketID = 35002000 + counter++;
962        final boolean[] optionals   = { false, };
963        
964        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
965        String requestJSON = WriteJSON.get(
966            parameterTypes.get("setIgnoreCertificateErrors"),
967            parameterNames.get("setIgnoreCertificateErrors"),
968            optionals, webSocketID,
969            "Security.setIgnoreCertificateErrors",
970            ignore
971        );
972        
973        // This Remote Command does not have a Return-Value.
974        return new Script<>
975            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
976    }
977    
978    /**
979     * Handles a certificate error that fired a certificateError event.
980     * <BR /><B>DEPRECATED</B>
981     * 
982     * @param eventId The ID of the event.
983     * 
984     * @param action The action to take on the certificate error.
985     * 
986     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
987     * {@link Ret0}&gt;</CODE>
988     *
989     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
990     * browser receives the invocation-request.
991     *
992     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
993     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
994     * {@code >} to ensure the Browser Function has run to completion.
995     */
996    public static Script<String, JsonObject, Ret0> handleCertificateError
997        (int eventId, String action)
998    {
999        // Exception-Check(s) to ensure that if any parameters which are not declared as
1000        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
1001        
1002        if (action == null) BRDPC.throwNPE("action");
1003        
1004        // Exception-Check(s) to ensure that if any parameters which must adhere to a
1005        // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
1006        
1007        BRDPC.checkIAE("action", action, "Security.CertificateErrorAction", Security.CertificateErrorAction);
1008        
1009        final int       webSocketID = 35003000 + counter++;
1010        final boolean[] optionals   = { false, false, };
1011        
1012        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1013        String requestJSON = WriteJSON.get(
1014            parameterTypes.get("handleCertificateError"),
1015            parameterNames.get("handleCertificateError"),
1016            optionals, webSocketID,
1017            "Security.handleCertificateError",
1018            eventId, action
1019        );
1020        
1021        // This Remote Command does not have a Return-Value.
1022        return new Script<>
1023            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1024    }
1025    
1026    /**
1027     * Enable/disable overriding certificate errors. If enabled, all certificate error events need to
1028     * be handled by the DevTools client and should be answered with <CODE>handleCertificateError</CODE> commands.
1029     * <BR /><B>DEPRECATED</B>
1030     * 
1031     * @param override If true, certificate errors will be overridden.
1032     * 
1033     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
1034     * {@link Ret0}&gt;</CODE>
1035     *
1036     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
1037     * browser receives the invocation-request.
1038     *
1039     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
1040     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
1041     * {@code >} to ensure the Browser Function has run to completion.
1042     */
1043    public static Script<String, JsonObject, Ret0> setOverrideCertificateErrors
1044        (boolean override)
1045    {
1046        final int       webSocketID = 35004000 + counter++;
1047        final boolean[] optionals   = { false, };
1048        
1049        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
1050        String requestJSON = WriteJSON.get(
1051            parameterTypes.get("setOverrideCertificateErrors"),
1052            parameterNames.get("setOverrideCertificateErrors"),
1053            optionals, webSocketID,
1054            "Security.setOverrideCertificateErrors",
1055            override
1056        );
1057        
1058        // This Remote Command does not have a Return-Value.
1059        return new Script<>
1060            (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues);
1061    }
1062    
1063}