1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 | package Torello.Browser; import java.util.*; import javax.json.*; import javax.json.stream.*; import java.io.*; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.function.Function; import Torello.Java.Additional.*; import Torello.Java.JSON.*; import static Torello.Java.JSON.JFlag.*; import Torello.Java.StrCmpr; import Torello.JavaDoc.StaticFunctional; import Torello.JavaDoc.JDHeaderBackgroundImg; import Torello.JavaDoc.Excuse; /** * <SPAN CLASS=COPIEDJDK><B>Security</B></SPAN> * * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> */ @StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) @JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") public class Security { // ******************************************************************************************** // ******************************************************************************************** // Class Header Stuff // ******************************************************************************************** // ******************************************************************************************** // No Pubic Constructors private Security () { } // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, // offically, two empty-vectors. One for String's, and the other for Classes. private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); static { for (Method m : Security.class.getMethods()) { // This doesn't work! The parameter names are all "arg0" ... "argN" // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! // // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! Vector<Class<?>> parameterTypesList = new Vector<>(); for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); parameterTypes.put( m.getName(), (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS ); } } static { Vector<String> v = null; parameterNames.put("disable", EMPTY_VEC_STR); parameterNames.put("enable", EMPTY_VEC_STR); v = new Vector<String>(1); parameterNames.put("setIgnoreCertificateErrors", v); Collections.addAll(v, new String[] { "ignore", }); v = new Vector<String>(2); parameterNames.put("handleCertificateError", v); Collections.addAll(v, new String[] { "eventId", "action", }); v = new Vector<String>(1); parameterNames.put("setOverrideCertificateErrors", v); Collections.addAll(v, new String[] { "override", }); } // ******************************************************************************************** // ******************************************************************************************** // Types - Static Inner Classes // ******************************************************************************************** // ******************************************************************************************** // public static class CertificateId => Integer /** * A description of mixed content (HTTP resources on HTTPS pages), as defined by * https://www.w3.org/TR/mixed-content/#categories */ public static final String[] MixedContentType = { "blockable", "optionally-blockable", "none", }; /** The security level of a page or resource. */ public static final String[] SecurityState = { "unknown", "neutral", "insecure", "secure", "info", "insecure-broken", }; /** * <CODE>[No Description Provided by Google]</CODE> * <BR /> * <BR /><B>EXPERIMENTAL</B> */ public static final String[] SafetyTipStatus = { "badReputation", "lookalike", }; /** * The action to take when a certificate error occurs. continue will continue processing the * request and cancel will cancel the request. */ public static final String[] CertificateErrorAction = { "continue", "cancel", }; /** * Details about the security state of the page certificate. * <BR /> * <BR /><B>EXPERIMENTAL</B> */ public static class CertificateSecurityState extends BaseType implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, false, true, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, }; } /** Protocol name (e.g. "TLS 1.2" or "QUIC"). */ public final String protocol; /** Key Exchange used by the connection, or the empty string if not applicable. */ public final String keyExchange; /** * (EC)DH group used by the connection, if applicable. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String keyExchangeGroup; /** Cipher name. */ public final String cipher; /** * TLS MAC. Note that AEAD ciphers do not have separate MACs. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String mac; /** Page certificate. */ public final String[] certificate; /** Certificate subject name. */ public final String subjectName; /** Name of the issuing CA. */ public final String issuer; /** Certificate valid from date. */ public final Number validFrom; /** Certificate valid to (expiration) date */ public final Number validTo; /** * The highest priority network error code, if the certificate has an error. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String certificateNetworkError; /** True if the certificate uses a weak signature aglorithm. */ public final boolean certificateHasWeakSignature; /** True if the certificate has a SHA1 signature in the chain. */ public final boolean certificateHasSha1Signature; /** True if modern SSL */ public final boolean modernSSL; /** True if the connection is using an obsolete SSL protocol. */ public final boolean obsoleteSslProtocol; /** True if the connection is using an obsolete SSL key exchange. */ public final boolean obsoleteSslKeyExchange; /** True if the connection is using an obsolete SSL cipher. */ public final boolean obsoleteSslCipher; /** True if the connection is using an obsolete SSL signature. */ public final boolean obsoleteSslSignature; /** * Constructor * * @param protocol Protocol name (e.g. "TLS 1.2" or "QUIC"). * * @param keyExchange Key Exchange used by the connection, or the empty string if not applicable. * * @param keyExchangeGroup (EC)DH group used by the connection, if applicable. * <BR /><B>OPTIONAL</B> * * @param cipher Cipher name. * * @param mac TLS MAC. Note that AEAD ciphers do not have separate MACs. * <BR /><B>OPTIONAL</B> * * @param certificate Page certificate. * * @param subjectName Certificate subject name. * * @param issuer Name of the issuing CA. * * @param validFrom Certificate valid from date. * * @param validTo Certificate valid to (expiration) date * * @param certificateNetworkError The highest priority network error code, if the certificate has an error. * <BR /><B>OPTIONAL</B> * * @param certificateHasWeakSignature True if the certificate uses a weak signature aglorithm. * * @param certificateHasSha1Signature True if the certificate has a SHA1 signature in the chain. * * @param modernSSL True if modern SSL * * @param obsoleteSslProtocol True if the connection is using an obsolete SSL protocol. * * @param obsoleteSslKeyExchange True if the connection is using an obsolete SSL key exchange. * * @param obsoleteSslCipher True if the connection is using an obsolete SSL cipher. * * @param obsoleteSslSignature True if the connection is using an obsolete SSL signature. */ public CertificateSecurityState( String protocol, String keyExchange, String keyExchangeGroup, String cipher, String mac, String[] certificate, String subjectName, String issuer, Number validFrom, Number validTo, String certificateNetworkError, boolean certificateHasWeakSignature, boolean certificateHasSha1Signature, boolean modernSSL, boolean obsoleteSslProtocol, boolean obsoleteSslKeyExchange, boolean obsoleteSslCipher, boolean obsoleteSslSignature ) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (protocol == null) BRDPC.throwNPE("protocol"); if (keyExchange == null) BRDPC.throwNPE("keyExchange"); if (cipher == null) BRDPC.throwNPE("cipher"); if (certificate == null) BRDPC.throwNPE("certificate"); if (subjectName == null) BRDPC.throwNPE("subjectName"); if (issuer == null) BRDPC.throwNPE("issuer"); if (validFrom == null) BRDPC.throwNPE("validFrom"); if (validTo == null) BRDPC.throwNPE("validTo"); this.protocol = protocol; this.keyExchange = keyExchange; this.keyExchangeGroup = keyExchangeGroup; this.cipher = cipher; this.mac = mac; this.certificate = certificate; this.subjectName = subjectName; this.issuer = issuer; this.validFrom = validFrom; this.validTo = validTo; this.certificateNetworkError = certificateNetworkError; this.certificateHasWeakSignature = certificateHasWeakSignature; this.certificateHasSha1Signature = certificateHasSha1Signature; this.modernSSL = modernSSL; this.obsoleteSslProtocol = obsoleteSslProtocol; this.obsoleteSslKeyExchange = obsoleteSslKeyExchange; this.obsoleteSslCipher = obsoleteSslCipher; this.obsoleteSslSignature = obsoleteSslSignature; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'CertificateSecurityState'}. */ public CertificateSecurityState (JsonObject jo) { this.protocol = ReadJSON.getString(jo, "protocol", false, true); this.keyExchange = ReadJSON.getString(jo, "keyExchange", false, true); this.keyExchangeGroup = ReadJSON.getString(jo, "keyExchangeGroup", true, false); this.cipher = ReadJSON.getString(jo, "cipher", false, true); this.mac = ReadJSON.getString(jo, "mac", true, false); this.certificate = (jo.getJsonArray("certificate") == null) ? null : ReadArrJSON.DimN.strArr(jo.getJsonArray("certificate"), null, 0, String[].class); this.subjectName = ReadJSON.getString(jo, "subjectName", false, true); this.issuer = ReadJSON.getString(jo, "issuer", false, true); this.validFrom = ReadNumberJSON.get(jo, "validFrom", false, true); this.validTo = ReadNumberJSON.get(jo, "validTo", false, true); this.certificateNetworkError = ReadJSON.getString(jo, "certificateNetworkError", true, false); this.certificateHasWeakSignature = ReadPrimJSON.getBoolean(jo, "certificateHasWeakSignature"); this.certificateHasSha1Signature = ReadPrimJSON.getBoolean(jo, "certificateHasSha1Signature"); this.modernSSL = ReadPrimJSON.getBoolean(jo, "modernSSL"); this.obsoleteSslProtocol = ReadPrimJSON.getBoolean(jo, "obsoleteSslProtocol"); this.obsoleteSslKeyExchange = ReadPrimJSON.getBoolean(jo, "obsoleteSslKeyExchange"); this.obsoleteSslCipher = ReadPrimJSON.getBoolean(jo, "obsoleteSslCipher"); this.obsoleteSslSignature = ReadPrimJSON.getBoolean(jo, "obsoleteSslSignature"); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; CertificateSecurityState o = (CertificateSecurityState) other; return Objects.equals(this.protocol, o.protocol) && Objects.equals(this.keyExchange, o.keyExchange) && Objects.equals(this.keyExchangeGroup, o.keyExchangeGroup) && Objects.equals(this.cipher, o.cipher) && Objects.equals(this.mac, o.mac) && Arrays.deepEquals(this.certificate, o.certificate) && Objects.equals(this.subjectName, o.subjectName) && Objects.equals(this.issuer, o.issuer) && Objects.equals(this.validFrom, o.validFrom) && Objects.equals(this.validTo, o.validTo) && Objects.equals(this.certificateNetworkError, o.certificateNetworkError) && (this.certificateHasWeakSignature == o.certificateHasWeakSignature) && (this.certificateHasSha1Signature == o.certificateHasSha1Signature) && (this.modernSSL == o.modernSSL) && (this.obsoleteSslProtocol == o.obsoleteSslProtocol) && (this.obsoleteSslKeyExchange == o.obsoleteSslKeyExchange) && (this.obsoleteSslCipher == o.obsoleteSslCipher) && (this.obsoleteSslSignature == o.obsoleteSslSignature); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return Objects.hashCode(this.protocol) + Objects.hashCode(this.keyExchange) + Objects.hashCode(this.keyExchangeGroup) + Objects.hashCode(this.cipher) + Objects.hashCode(this.mac) + Arrays.deepHashCode(this.certificate) + Objects.hashCode(this.subjectName) + Objects.hashCode(this.issuer) + Objects.hashCode(this.validFrom) + Objects.hashCode(this.validTo) + Objects.hashCode(this.certificateNetworkError) + (this.certificateHasWeakSignature ? 1 : 0) + (this.certificateHasSha1Signature ? 1 : 0) + (this.modernSSL ? 1 : 0) + (this.obsoleteSslProtocol ? 1 : 0) + (this.obsoleteSslKeyExchange ? 1 : 0) + (this.obsoleteSslCipher ? 1 : 0) + (this.obsoleteSslSignature ? 1 : 0); } } /** * <CODE>[No Description Provided by Google]</CODE> * <BR /> * <BR /><B>EXPERIMENTAL</B> */ public static class SafetyTipInfo extends BaseType implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, true, }; } /** Describes whether the page triggers any safety tips or reputation warnings. Default is unknown. */ public final String safetyTipStatus; /** * The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String safeUrl; /** * Constructor * * @param safetyTipStatus Describes whether the page triggers any safety tips or reputation warnings. Default is unknown. * * @param safeUrl The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches. * <BR /><B>OPTIONAL</B> */ public SafetyTipInfo(String safetyTipStatus, String safeUrl) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (safetyTipStatus == null) BRDPC.throwNPE("safetyTipStatus"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("safetyTipStatus", safetyTipStatus, "Security.SafetyTipStatus", Security.SafetyTipStatus); this.safetyTipStatus = safetyTipStatus; this.safeUrl = safeUrl; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'SafetyTipInfo'}. */ public SafetyTipInfo (JsonObject jo) { this.safetyTipStatus = ReadJSON.getString(jo, "safetyTipStatus", false, true); this.safeUrl = ReadJSON.getString(jo, "safeUrl", true, false); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; SafetyTipInfo o = (SafetyTipInfo) other; return Objects.equals(this.safetyTipStatus, o.safetyTipStatus) && Objects.equals(this.safeUrl, o.safeUrl); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return Objects.hashCode(this.safetyTipStatus) + Objects.hashCode(this.safeUrl); } } /** * Security state information about the page. * <BR /> * <BR /><B>EXPERIMENTAL</B> */ public static class VisibleSecurityState extends BaseType implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, true, true, false, }; } /** The security level of the page. */ public final String securityState; /** * Security state details about the page certificate. * <BR /> * <BR /><B>OPTIONAL</B> */ public final Security.CertificateSecurityState certificateSecurityState; /** * 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. * <BR /> * <BR /><B>OPTIONAL</B> */ public final Security.SafetyTipInfo safetyTipInfo; /** Array of security state issues ids. */ public final String[] securityStateIssueIds; /** * Constructor * * @param securityState The security level of the page. * * @param certificateSecurityState Security state details about the page certificate. * <BR /><B>OPTIONAL</B> * * @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. * <BR /><B>OPTIONAL</B> * * @param securityStateIssueIds Array of security state issues ids. */ public VisibleSecurityState( String securityState, Security.CertificateSecurityState certificateSecurityState, Security.SafetyTipInfo safetyTipInfo, String[] securityStateIssueIds ) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (securityState == null) BRDPC.throwNPE("securityState"); if (securityStateIssueIds == null) BRDPC.throwNPE("securityStateIssueIds"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState); this.securityState = securityState; this.certificateSecurityState = certificateSecurityState; this.safetyTipInfo = safetyTipInfo; this.securityStateIssueIds = securityStateIssueIds; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'VisibleSecurityState'}. */ public VisibleSecurityState (JsonObject jo) { this.securityState = ReadJSON.getString(jo, "securityState", false, true); this.certificateSecurityState = ReadJSON.getObject(jo, "certificateSecurityState", Security.CertificateSecurityState.class, true, false); this.safetyTipInfo = ReadJSON.getObject(jo, "safetyTipInfo", Security.SafetyTipInfo.class, true, false); this.securityStateIssueIds = (jo.getJsonArray("securityStateIssueIds") == null) ? null : ReadArrJSON.DimN.strArr(jo.getJsonArray("securityStateIssueIds"), null, 0, String[].class); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; VisibleSecurityState o = (VisibleSecurityState) other; return Objects.equals(this.securityState, o.securityState) && Objects.equals(this.certificateSecurityState, o.certificateSecurityState) && Objects.equals(this.safetyTipInfo, o.safetyTipInfo) && Arrays.deepEquals(this.securityStateIssueIds, o.securityStateIssueIds); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return Objects.hashCode(this.securityState) + this.certificateSecurityState.hashCode() + this.safetyTipInfo.hashCode() + Arrays.deepHashCode(this.securityStateIssueIds); } } /** An explanation of an factor contributing to the security state. */ public static class SecurityStateExplanation extends BaseType implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, false, false, false, false, false, true, }; } /** Security state representing the severity of the factor being explained. */ public final String securityState; /** Title describing the type of factor. */ public final String title; /** Short phrase describing the type of factor. */ public final String summary; /** Full text explanation of the factor. */ public final String description; /** The type of mixed content described by the explanation. */ public final String mixedContentType; /** Page certificate. */ public final String[] certificate; /** * Recommendations to fix any issues. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String[] recommendations; /** * Constructor * * @param securityState Security state representing the severity of the factor being explained. * * @param title Title describing the type of factor. * * @param summary Short phrase describing the type of factor. * * @param description Full text explanation of the factor. * * @param mixedContentType The type of mixed content described by the explanation. * * @param certificate Page certificate. * * @param recommendations Recommendations to fix any issues. * <BR /><B>OPTIONAL</B> */ public SecurityStateExplanation( String securityState, String title, String summary, String description, String mixedContentType, String[] certificate, String[] recommendations ) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (securityState == null) BRDPC.throwNPE("securityState"); if (title == null) BRDPC.throwNPE("title"); if (summary == null) BRDPC.throwNPE("summary"); if (description == null) BRDPC.throwNPE("description"); if (mixedContentType == null) BRDPC.throwNPE("mixedContentType"); if (certificate == null) BRDPC.throwNPE("certificate"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState); BRDPC.checkIAE("mixedContentType", mixedContentType, "Security.MixedContentType", Security.MixedContentType); this.securityState = securityState; this.title = title; this.summary = summary; this.description = description; this.mixedContentType = mixedContentType; this.certificate = certificate; this.recommendations = recommendations; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'SecurityStateExplanation'}. */ public SecurityStateExplanation (JsonObject jo) { this.securityState = ReadJSON.getString(jo, "securityState", false, true); this.title = ReadJSON.getString(jo, "title", false, true); this.summary = ReadJSON.getString(jo, "summary", false, true); this.description = ReadJSON.getString(jo, "description", false, true); this.mixedContentType = ReadJSON.getString(jo, "mixedContentType", false, true); this.certificate = (jo.getJsonArray("certificate") == null) ? null : ReadArrJSON.DimN.strArr(jo.getJsonArray("certificate"), null, 0, String[].class); this.recommendations = (jo.getJsonArray("recommendations") == null) ? null : ReadArrJSON.DimN.strArr(jo.getJsonArray("recommendations"), null, 0, String[].class); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; SecurityStateExplanation o = (SecurityStateExplanation) other; return Objects.equals(this.securityState, o.securityState) && Objects.equals(this.title, o.title) && Objects.equals(this.summary, o.summary) && Objects.equals(this.description, o.description) && Objects.equals(this.mixedContentType, o.mixedContentType) && Arrays.deepEquals(this.certificate, o.certificate) && Arrays.deepEquals(this.recommendations, o.recommendations); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return Objects.hashCode(this.securityState) + Objects.hashCode(this.title) + Objects.hashCode(this.summary) + Objects.hashCode(this.description) + Objects.hashCode(this.mixedContentType) + Arrays.deepHashCode(this.certificate) + Arrays.deepHashCode(this.recommendations); } } /** * Information about insecure content on the page. * <BR /> * <BR /><B>DEPRECATED</B> */ public static class InsecureContentStatus extends BaseType implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, false, false, false, false, false, false, }; } /** Always false. */ public final boolean ranMixedContent; /** Always false. */ public final boolean displayedMixedContent; /** Always false. */ public final boolean containedMixedForm; /** Always false. */ public final boolean ranContentWithCertErrors; /** Always false. */ public final boolean displayedContentWithCertErrors; /** Always set to unknown. */ public final String ranInsecureContentStyle; /** Always set to unknown. */ public final String displayedInsecureContentStyle; /** * Constructor * * @param ranMixedContent Always false. * * @param displayedMixedContent Always false. * * @param containedMixedForm Always false. * * @param ranContentWithCertErrors Always false. * * @param displayedContentWithCertErrors Always false. * * @param ranInsecureContentStyle Always set to unknown. * * @param displayedInsecureContentStyle Always set to unknown. */ public InsecureContentStatus( boolean ranMixedContent, boolean displayedMixedContent, boolean containedMixedForm, boolean ranContentWithCertErrors, boolean displayedContentWithCertErrors, String ranInsecureContentStyle, String displayedInsecureContentStyle ) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (ranInsecureContentStyle == null) BRDPC.throwNPE("ranInsecureContentStyle"); if (displayedInsecureContentStyle == null) BRDPC.throwNPE("displayedInsecureContentStyle"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("ranInsecureContentStyle", ranInsecureContentStyle, "Security.SecurityState", Security.SecurityState); BRDPC.checkIAE("displayedInsecureContentStyle", displayedInsecureContentStyle, "Security.SecurityState", Security.SecurityState); this.ranMixedContent = ranMixedContent; this.displayedMixedContent = displayedMixedContent; this.containedMixedForm = containedMixedForm; this.ranContentWithCertErrors = ranContentWithCertErrors; this.displayedContentWithCertErrors = displayedContentWithCertErrors; this.ranInsecureContentStyle = ranInsecureContentStyle; this.displayedInsecureContentStyle = displayedInsecureContentStyle; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'InsecureContentStatus'}. */ public InsecureContentStatus (JsonObject jo) { this.ranMixedContent = ReadPrimJSON.getBoolean(jo, "ranMixedContent"); this.displayedMixedContent = ReadPrimJSON.getBoolean(jo, "displayedMixedContent"); this.containedMixedForm = ReadPrimJSON.getBoolean(jo, "containedMixedForm"); this.ranContentWithCertErrors = ReadPrimJSON.getBoolean(jo, "ranContentWithCertErrors"); this.displayedContentWithCertErrors = ReadPrimJSON.getBoolean(jo, "displayedContentWithCertErrors"); this.ranInsecureContentStyle = ReadJSON.getString(jo, "ranInsecureContentStyle", false, true); this.displayedInsecureContentStyle = ReadJSON.getString(jo, "displayedInsecureContentStyle", false, true); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; InsecureContentStatus o = (InsecureContentStatus) other; return (this.ranMixedContent == o.ranMixedContent) && (this.displayedMixedContent == o.displayedMixedContent) && (this.containedMixedForm == o.containedMixedForm) && (this.ranContentWithCertErrors == o.ranContentWithCertErrors) && (this.displayedContentWithCertErrors == o.displayedContentWithCertErrors) && Objects.equals(this.ranInsecureContentStyle, o.ranInsecureContentStyle) && Objects.equals(this.displayedInsecureContentStyle, o.displayedInsecureContentStyle); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return (this.ranMixedContent ? 1 : 0) + (this.displayedMixedContent ? 1 : 0) + (this.containedMixedForm ? 1 : 0) + (this.ranContentWithCertErrors ? 1 : 0) + (this.displayedContentWithCertErrors ? 1 : 0) + Objects.hashCode(this.ranInsecureContentStyle) + Objects.hashCode(this.displayedInsecureContentStyle); } } /** * There is a certificate error. If overriding certificate errors is enabled, then it should be * handled with the <CODE>handleCertificateError</CODE> command. Note: this event does not fire if the * certificate error has been allowed internally. Only one client per target should override * certificate errors at the same time. * <BR /> * <BR /><B>DEPRECATED</B> */ public static class certificateError extends BrowserEvent implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, false, false, }; } /** The ID of the event. */ public final int eventId; /** The type of the error. */ public final String errorType; /** The url that was requested. */ public final String requestURL; /** * Constructor * * @param eventId The ID of the event. * * @param errorType The type of the error. * * @param requestURL The url that was requested. */ public certificateError(int eventId, String errorType, String requestURL) { super("Security", "certificateError", 3); // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (errorType == null) BRDPC.throwNPE("errorType"); if (requestURL == null) BRDPC.throwNPE("requestURL"); this.eventId = eventId; this.errorType = errorType; this.requestURL = requestURL; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'certificateError'}. */ public certificateError (JsonObject jo) { super("Security", "certificateError", 3); this.eventId = ReadPrimJSON.getInt(jo, "eventId"); this.errorType = ReadJSON.getString(jo, "errorType", false, true); this.requestURL = ReadJSON.getString(jo, "requestURL", false, true); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; certificateError o = (certificateError) other; return (this.eventId == o.eventId) && Objects.equals(this.errorType, o.errorType) && Objects.equals(this.requestURL, o.requestURL); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return this.eventId + Objects.hashCode(this.errorType) + Objects.hashCode(this.requestURL); } } /** * The security state of the page changed. * <BR /> * <BR /><B>EXPERIMENTAL</B> */ public static class visibleSecurityStateChanged extends BrowserEvent implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, }; } /** Security state information about the page. */ public final Security.VisibleSecurityState visibleSecurityState; /** * Constructor * * @param visibleSecurityState Security state information about the page. */ public visibleSecurityStateChanged(Security.VisibleSecurityState visibleSecurityState) { super("Security", "visibleSecurityStateChanged", 1); // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (visibleSecurityState == null) BRDPC.throwNPE("visibleSecurityState"); this.visibleSecurityState = visibleSecurityState; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'visibleSecurityStateChanged'}. */ public visibleSecurityStateChanged (JsonObject jo) { super("Security", "visibleSecurityStateChanged", 1); this.visibleSecurityState = ReadJSON.getObject(jo, "visibleSecurityState", Security.VisibleSecurityState.class, false, true); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; visibleSecurityStateChanged o = (visibleSecurityStateChanged) other; return Objects.equals(this.visibleSecurityState, o.visibleSecurityState); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return this.visibleSecurityState.hashCode(); } } /** The security state of the page changed. */ public static class securityStateChanged extends BrowserEvent implements java.io.Serializable { /** For Object Serialization. java.io.Serializable */ protected static final long serialVersionUID = 1; public boolean[] optionals() { return new boolean[] { false, false, false, false, true, }; } /** Security state. */ public final String securityState; /** * True if the page was loaded over cryptographic transport such as HTTPS. * <BR /> * <BR /><B>DEPRECATED</B> */ public final boolean schemeIsCryptographic; /** * List of explanations for the security state. If the overall security state is <CODE>insecure</CODE> or * <CODE>warning</CODE>, at least one corresponding explanation should be included. */ public final Security.SecurityStateExplanation[] explanations; /** * Information about insecure content on the page. * <BR /> * <BR /><B>DEPRECATED</B> */ public final Security.InsecureContentStatus insecureContentStatus; /** * Overrides user-visible description of the state. * <BR /> * <BR /><B>OPTIONAL</B> */ public final String summary; /** * Constructor * * @param securityState Security state. * * @param schemeIsCryptographic True if the page was loaded over cryptographic transport such as HTTPS. * <BR /><B>DEPRECATED</B> * * @param explanations * List of explanations for the security state. If the overall security state is <CODE>insecure</CODE> or * <CODE>warning</CODE>, at least one corresponding explanation should be included. * * @param insecureContentStatus Information about insecure content on the page. * <BR /><B>DEPRECATED</B> * * @param summary Overrides user-visible description of the state. * <BR /><B>OPTIONAL</B> */ public securityStateChanged( String securityState, boolean schemeIsCryptographic, Security.SecurityStateExplanation[] explanations, Security.InsecureContentStatus insecureContentStatus, String summary ) { super("Security", "securityStateChanged", 5); // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (securityState == null) BRDPC.throwNPE("securityState"); if (explanations == null) BRDPC.throwNPE("explanations"); if (insecureContentStatus == null) BRDPC.throwNPE("insecureContentStatus"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("securityState", securityState, "Security.SecurityState", Security.SecurityState); this.securityState = securityState; this.schemeIsCryptographic = schemeIsCryptographic; this.explanations = explanations; this.insecureContentStatus = insecureContentStatus; this.summary = summary; } /** * JSON Object Constructor * @param jo A Json-Object having data about an instance of {@code 'securityStateChanged'}. */ public securityStateChanged (JsonObject jo) { super("Security", "securityStateChanged", 5); this.securityState = ReadJSON.getString(jo, "securityState", false, true); this.schemeIsCryptographic = ReadPrimJSON.getBoolean(jo, "schemeIsCryptographic"); this.explanations = (jo.getJsonArray("explanations") == null) ? null : ReadArrJSON.DimN.objArr(jo.getJsonArray("explanations"), null, 0, Security.SecurityStateExplanation[].class); this.insecureContentStatus = ReadJSON.getObject(jo, "insecureContentStatus", Security.InsecureContentStatus.class, false, true); this.summary = ReadJSON.getString(jo, "summary", true, false); } /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ public boolean equals(Object other) { if (other == null) return false; if (other.getClass() != this.getClass()) return false; securityStateChanged o = (securityStateChanged) other; return Objects.equals(this.securityState, o.securityState) && (this.schemeIsCryptographic == o.schemeIsCryptographic) && Arrays.deepEquals(this.explanations, o.explanations) && Objects.equals(this.insecureContentStatus, o.insecureContentStatus) && Objects.equals(this.summary, o.summary); } /** Generates a Hash-Code for {@code 'this'} instance */ public int hashCode() { return Objects.hashCode(this.securityState) + (this.schemeIsCryptographic ? 1 : 0) + Arrays.deepHashCode(this.explanations) + this.insecureContentStatus.hashCode() + Objects.hashCode(this.summary); } } // Counter for keeping the WebSocket Request ID's distinct. private static int counter = 1; /** * Disables tracking security state changes. * * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, * {@link Ret0}></CODE> * * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the * browser receives the invocation-request. * * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} * {@code >} to ensure the Browser Function has run to completion. */ public static Script<String, JsonObject, Ret0> disable() { final int webSocketID = 35000000 + counter++; final boolean[] optionals = new boolean[0]; // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) String requestJSON = WriteJSON.get( parameterTypes.get("disable"), parameterNames.get("disable"), optionals, webSocketID, "Security.disable" ); // This Remote Command does not have a Return-Value. return new Script<> (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); } /** * Enables tracking security state changes. * * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, * {@link Ret0}></CODE> * * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the * browser receives the invocation-request. * * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} * {@code >} to ensure the Browser Function has run to completion. */ public static Script<String, JsonObject, Ret0> enable() { final int webSocketID = 35001000 + counter++; final boolean[] optionals = new boolean[0]; // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) String requestJSON = WriteJSON.get( parameterTypes.get("enable"), parameterNames.get("enable"), optionals, webSocketID, "Security.enable" ); // This Remote Command does not have a Return-Value. return new Script<> (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); } /** * Enable/disable whether all certificate errors should be ignored. * <BR /><B>EXPERIMENTAL</B> * * @param ignore If true, all certificate errors will be ignored. * * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, * {@link Ret0}></CODE> * * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the * browser receives the invocation-request. * * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} * {@code >} to ensure the Browser Function has run to completion. */ public static Script<String, JsonObject, Ret0> setIgnoreCertificateErrors(boolean ignore) { final int webSocketID = 35002000 + counter++; final boolean[] optionals = { false, }; // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) String requestJSON = WriteJSON.get( parameterTypes.get("setIgnoreCertificateErrors"), parameterNames.get("setIgnoreCertificateErrors"), optionals, webSocketID, "Security.setIgnoreCertificateErrors", ignore ); // This Remote Command does not have a Return-Value. return new Script<> (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); } /** * Handles a certificate error that fired a certificateError event. * <BR /><B>DEPRECATED</B> * * @param eventId The ID of the event. * * @param action The action to take on the certificate error. * * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, * {@link Ret0}></CODE> * * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the * browser receives the invocation-request. * * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} * {@code >} to ensure the Browser Function has run to completion. */ public static Script<String, JsonObject, Ret0> handleCertificateError (int eventId, String action) { // Exception-Check(s) to ensure that if any parameters which are not declared as // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. if (action == null) BRDPC.throwNPE("action"); // Exception-Check(s) to ensure that if any parameters which must adhere to a // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. BRDPC.checkIAE("action", action, "Security.CertificateErrorAction", Security.CertificateErrorAction); final int webSocketID = 35003000 + counter++; final boolean[] optionals = { false, false, }; // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) String requestJSON = WriteJSON.get( parameterTypes.get("handleCertificateError"), parameterNames.get("handleCertificateError"), optionals, webSocketID, "Security.handleCertificateError", eventId, action ); // This Remote Command does not have a Return-Value. return new Script<> (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); } /** * Enable/disable overriding certificate errors. If enabled, all certificate error events need to * be handled by the DevTools client and should be answered with <CODE>handleCertificateError</CODE> commands. * <BR /><B>DEPRECATED</B> * * @param override If true, certificate errors will be overridden. * * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, * {@link Ret0}></CODE> * * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the * browser receives the invocation-request. * * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} * {@code >} to ensure the Browser Function has run to completion. */ public static Script<String, JsonObject, Ret0> setOverrideCertificateErrors (boolean override) { final int webSocketID = 35004000 + counter++; final boolean[] optionals = { false, }; // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) String requestJSON = WriteJSON.get( parameterTypes.get("setOverrideCertificateErrors"), parameterNames.get("setOverrideCertificateErrors"), optionals, webSocketID, "Security.setOverrideCertificateErrors", override ); // This Remote Command does not have a Return-Value. return new Script<> (BRDPC.defaultSender, webSocketID, requestJSON, BRDPC.NoReturnValues); } } |