author | coffeys |
Tue, 20 Nov 2018 13:12:48 +0000 | |
changeset 52621 | f7309a1491d9 |
permissions | -rw-r--r-- |
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
1 |
/* |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
4 |
* |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
8 |
* |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
13 |
* accompanied this code). |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
14 |
* |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
18 |
* |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
21 |
* questions. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
22 |
*/ |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
23 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
24 |
package jdk.test.lib.security; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
25 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
26 |
import java.io.ByteArrayInputStream; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
27 |
import java.security.cert.CertPath; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
28 |
import java.security.cert.CertPathValidator; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
29 |
import java.security.cert.CertificateException; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
30 |
import java.security.cert.CertificateFactory; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
31 |
import java.security.cert.PKIXParameters; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
32 |
import java.security.cert.TrustAnchor; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
33 |
import java.security.cert.X509Certificate; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
34 |
import java.util.Collections; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
35 |
import java.util.Date; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
36 |
import java.util.List; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
37 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
38 |
// Certificates taken from old ValWithAnchorByName testcase *** |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
39 |
public enum TestCertificate { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
40 |
// Subject: CN=SSLCertificate, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
41 |
// Issuer: CN=Intermediate CA Cert, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
42 |
// Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017 |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
43 |
ONE("1000", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
44 |
"CN=SSLCertificate, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
45 |
"CN=Intermediate CA Cert, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
46 |
-1063259762, |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
47 |
"-----BEGIN CERTIFICATE-----\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
48 |
"MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
49 |
"ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
50 |
"MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
51 |
"FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
52 |
"MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
53 |
"vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
54 |
"ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
55 |
"BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
56 |
"kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
57 |
"nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
58 |
"CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
59 |
"b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
60 |
"HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
61 |
"BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
62 |
"AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
63 |
"f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
64 |
"Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
65 |
"a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
66 |
"IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
67 |
"5/rmc06sICqBjLfPEB68Jjw=\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
68 |
"-----END CERTIFICATE-----"), |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
69 |
// Subject: CN=Intermediate CA Cert, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
70 |
// Issuer: CN=Root CA Cert, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
71 |
// Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018 |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
72 |
TWO("64", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
73 |
"CN=Intermediate CA Cert, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
74 |
"CN=Root CA Cert, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
75 |
-927189373, |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
76 |
"-----BEGIN CERTIFICATE-----\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
77 |
"MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
78 |
"Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
79 |
"DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
80 |
"FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
81 |
"CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
82 |
"7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
83 |
"C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
84 |
"NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
85 |
"V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
86 |
"7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
87 |
"Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
88 |
"OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
89 |
"BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
90 |
"AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
91 |
"7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
92 |
"5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
93 |
"0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
94 |
"fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
95 |
"g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
96 |
"-----END CERTIFICATE-----"), |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
97 |
// Subject: CN=Root CA Cert, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
98 |
// Issuer: CN=Root CA Cert, O=SomeCompany |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
99 |
// Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019 |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
100 |
ROOT_CA("1", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
101 |
"CN=Root CA Cert, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
102 |
"CN=Root CA Cert, O=SomeCompany", |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
103 |
-1299818863, |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
104 |
"-----BEGIN CERTIFICATE-----\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
105 |
"MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
106 |
"Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
107 |
"DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
108 |
"DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
109 |
"M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
110 |
"Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
111 |
"y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
112 |
"c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
113 |
"Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
114 |
"KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
115 |
"GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
116 |
"xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
117 |
"sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
118 |
"IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
119 |
"UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
120 |
"sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
121 |
"sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
122 |
"J2GyCaJINsyaI/I2\n" + |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
123 |
"-----END CERTIFICATE-----"); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
124 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
125 |
public String serialNumber; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
126 |
public String algorithm; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
127 |
public String subject; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
128 |
public String issuer; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
129 |
public String keyType; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
130 |
public long certId; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
131 |
public int keyLength; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
132 |
public String encoded; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
133 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
134 |
TestCertificate(String serialNumber, String subject, String issuer, |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
135 |
long certId, String encoded) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
136 |
this.serialNumber = serialNumber; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
137 |
this.subject = subject; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
138 |
this.issuer = issuer; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
139 |
this.algorithm = "SHA256withRSA"; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
140 |
this.encoded = encoded; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
141 |
this.certId = certId; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
142 |
this.keyType = "RSA"; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
143 |
this.keyLength = 2048; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
144 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
145 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
146 |
public X509Certificate generate(CertificateFactory cf) throws CertificateException { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
147 |
ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes()); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
148 |
return (X509Certificate) cf.generateCertificate(is); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
149 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
150 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
151 |
public static void generateChain(boolean selfSignedTest) throws Exception { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
152 |
// Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
153 |
// This value is within the lifetimes of all certificates. |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
154 |
Date testDate = new Date(1473199941000L); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
155 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
156 |
CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
157 |
X509Certificate c1 = TestCertificate.ONE.generate(cf); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
158 |
X509Certificate c2 = TestCertificate.TWO.generate(cf); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
159 |
X509Certificate ca = TestCertificate.ROOT_CA.generate(cf); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
160 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
161 |
TrustAnchor ta = new TrustAnchor(ca, null); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
162 |
CertPathValidator validator = CertPathValidator.getInstance("PKIX"); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
163 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
164 |
PKIXParameters params = new PKIXParameters(Collections.singleton(ta)); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
165 |
params.setRevocationEnabled(false); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
166 |
params.setDate(testDate); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
167 |
if (!selfSignedTest) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
168 |
CertPath path = cf.generateCertPath(List.of(c1, c2)); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
169 |
validator.validate(path, params); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
170 |
} else { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
171 |
CertPath path = cf.generateCertPath(List.of(ca)); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
172 |
validator.validate(path, params); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
173 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
174 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
diff
changeset
|
175 |
} |