author | mullan |
Mon, 20 Jul 2015 09:03:03 -0400 | |
changeset 31804 | 013c14047253 |
parent 31141 | ef5ddf021137 |
child 40416 | 5d91b2fd668c |
permissions | -rw-r--r-- |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
1 |
/* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
4 |
* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
8 |
* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
13 |
* accompanied this code). |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
14 |
* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
18 |
* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
21 |
* questions. |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
22 |
*/ |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
23 |
|
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
24 |
import java.io.ByteArrayInputStream; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
25 |
import java.io.File; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
26 |
import java.io.InputStream; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
27 |
import java.io.IOException; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
28 |
import java.io.OutputStream; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
29 |
import java.net.URL; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
30 |
import java.security.CodeSource; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
31 |
import java.security.Key; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
32 |
import java.security.KeyStoreException; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
33 |
import java.security.KeyStoreSpi; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
34 |
import java.security.NoSuchAlgorithmException; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
35 |
import java.security.Permission; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
36 |
import java.security.Policy; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
37 |
import java.security.ProtectionDomain; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
38 |
import java.security.Provider; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
39 |
import java.security.SecureClassLoader; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
40 |
import java.security.Security; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
41 |
import java.security.UnrecoverableKeyException; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
42 |
import java.security.URIParameter; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
43 |
import java.security.cert.Certificate; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
44 |
import java.security.cert.CertificateException; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
45 |
import java.security.cert.CertificateFactory; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
46 |
import java.util.ArrayList; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
47 |
import java.util.Arrays; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
48 |
import java.util.Base64; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
49 |
import java.util.Collections; |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
50 |
import java.util.Date; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
51 |
import java.util.Enumeration; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
52 |
import java.util.List; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
53 |
import java.util.PropertyPermission; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
54 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
55 |
/* |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
56 |
* @test |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
57 |
* @bug 6826789 8131486 |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
58 |
* @summary Make sure equivalent ProtectionDomains are granted the same |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
59 |
* permissions when the CodeSource URLs are different but resolve |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
60 |
* to the same ip address after name service resolution. |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
61 |
* @run main/othervm DefineClass |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
62 |
*/ |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
63 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
64 |
public class DefineClass { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
65 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
66 |
// permissions that are expected to be granted by the policy file |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
67 |
private final static Permission[] GRANTED_PERMS = new Permission[] { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
68 |
new PropertyPermission("user.home", "read"), |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
69 |
new PropertyPermission("user.name", "read") |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
70 |
}; |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
71 |
|
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
72 |
// Base64 encoded bytes of simple class: "package foo; public class Foo {}" |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
73 |
private final static String FOO_CLASS = |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
74 |
"yv66vgAAADMADQoAAwAKBwALBwAMAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
75 |
"D0xpbmVOdW1iZXJUYWJsZQEAClNvdXJjZUZpbGUBAAhGb28uamF2YQwABAAF" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
76 |
"AQAHZm9vL0ZvbwEAEGphdmEvbGFuZy9PYmplY3QAIQACAAMAAAAAAAEAAQAE" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
77 |
"AAUAAQAGAAAAHQABAAEAAAAFKrcAAbEAAAABAAcAAAAGAAEAAAABAAEACAAA" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
78 |
"AAIACQ=="; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
79 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
80 |
// Base64 encoded bytes of simple class: "package bar; public class Bar {}" |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
81 |
private final static String BAR_CLASS = |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
82 |
"yv66vgAAADMADQoAAwAKBwALBwAMAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
83 |
"D0xpbmVOdW1iZXJUYWJsZQEAClNvdXJjZUZpbGUBAAhCYXIuamF2YQwABAAF" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
84 |
"AQAHYmFyL0JhcgEAEGphdmEvbGFuZy9PYmplY3QAIQACAAMAAAAAAAEAAQAE" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
85 |
"AAUAAQAGAAAAHQABAAEAAAAFKrcAAbEAAAABAAcAAAAGAAEAAAABAAEACAAA" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
86 |
"AAIACQ=="; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
87 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
88 |
// Base64 encoded bytes of simple class: "package baz; public class Baz {}" |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
89 |
private final static String BAZ_CLASS = |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
90 |
"yv66vgAAADQADQoAAwAKBwALBwAMAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA" + |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
91 |
"D0xpbmVOdW1iZXJUYWJsZQEAClNvdXJjZUZpbGUBAAhCYXouamF2YQwABAAF" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
92 |
"AQAHYmF6L0JhegEAEGphdmEvbGFuZy9PYmplY3QAIQACAAMAAAAAAAEAAQAE" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
93 |
"AAUAAQAGAAAAHQABAAEAAAAFKrcAAbEAAAABAAcAAAAGAAEAAAABAAEACAAA" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
94 |
"AAIACQ=="; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
95 |
|
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
96 |
private final static String BAZ_CERT = |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
97 |
"-----BEGIN CERTIFICATE-----\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
98 |
"MIIEFzCCA8OgAwIBAgIESpPf8TANBglghkgBZQMEAwIFADAOMQwwCgYDVQQDEwNG\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
99 |
"b28wHhcNMTUwNzE1MTY1ODM5WhcNMTUxMDEzMTY1ODM5WjAOMQwwCgYDVQQDEwNG\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
100 |
"b28wggNCMIICNQYHKoZIzjgEATCCAigCggEBAI95Ndm5qum/q+2Ies9JUbbzLsWe\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
101 |
"O683GOjqxJYfPv02BudDUanEGDM5uAnnwq4cU5unR1uF0BGtuLR5h3VJhGlcrA6P\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
102 |
"FLM2CCiiL/onEQo9YqmTRTQJoP5pbEZY+EvdIIGcNwmgEFexla3NACM9ulSEtikf\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
103 |
"nWSO+INEhneXnOwEtDSmrC516Zhd4j2wKS/BEYyf+p2BgeczjbeStzDXueNJWS9o\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
104 |
"CZhyFTkV6j1ri0ZTxjNFj4A7MqTC4PJykCVuTj+KOwg4ocRQ5OGMGimjfd9eoUPe\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
105 |
"S2b/BJA+1c8WI+FY1IfGCOl/IRzYHcojy244B2X4IuNCvkhMBXY5OWAc1mcCHQC6\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
106 |
"9pamhXj3397n+mfJd8eF7zKyM7rlgMC81WldAoIBABamXFggSFBwTnUCo5dXBA00\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
107 |
"2jo0eMFU1OSlwC0kLuBPluYeS9CQSr2sjzfuseCfMYLSPJBDy2QviABBYO35ygmz\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
108 |
"IHannDKmJ/JHPpGHm6LE50S9IIFUTLVbgCw2jR+oPtSJ6U4PoGiOMkKKXHjEeMaN\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
109 |
"BSe3HJo6uwsL4SxEaJY559POdNsQGmWqK4f2TGgm2z7HL0tVmYNLtO2wL3yQ6aSW\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
110 |
"06VdU1vr/EXU9hn2Pz3tu4c5JcLyJOB3MSltqIfsHkdI+H77X963VIQxayIy3uVT\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
111 |
"3a8CESsNHwLaMJcyJP4nrtqLnUspItm6i+Oe2eEDpjxSgQvGiLfi7UMW4e8X294D\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
112 |
"ggEFAAKCAQBsGeU8/STExzQsJ8kFM9xarA/2VAFMzyUpd3IQ2UGHQC5rEnGh/RiU\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
113 |
"T20y7a2hCpQ1f/qgLnY8hku9GRVY3z8WamBzWLzCAEAx67EsS58mf4o8R3sUbkH5\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
114 |
"/mRaZoNVSPUy+tXoLmTzIetU4W+JT8Rq4OcXXU9uo9TreeBehhVexS3vpVgQeUIn\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
115 |
"MmMma8WHpovIJQQlp4cyjalX7Beda/tqX/HPLkAS4TRqQAz7hFr3FqFrVMKFSGo4\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
116 |
"fTS06GGdQ4tw9c6NQLuQ9WF9BxYSwSk9yENQvKDZaBNarqPMnsh1Gi/QcKMRBVhM\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
117 |
"RT/9vb4QUi/pOowhhKCDBLgjY60QgX3HoyEwHzAdBgNVHQ4EFgQUa787CE+3ZNAb\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
118 |
"g1ql9yJVVrRCdx0wDQYJYIZIAWUDBAMCBQADPwAwPAIcCUkZIRrBlKdTzhKYBEOm\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
119 |
"E1i45MMum1RuHc28agIcfHQkkjBA4FfH5UMRgKpIyRR8V/dVboxDj4hKOA==\n" + |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
120 |
"-----END CERTIFICATE-----"; |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
121 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
122 |
public static void main(String[] args) throws Exception { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
123 |
|
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
124 |
Security.addProvider(new TestProvider()); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
125 |
|
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
126 |
MySecureClassLoader scl = new MySecureClassLoader(); |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
127 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
128 |
File policyFile = new File(System.getProperty("test.src", "."), |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
129 |
"DefineClass.policy"); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
130 |
Policy p = Policy.getInstance("JavaPolicy", |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
131 |
new URIParameter(policyFile.toURI())); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
132 |
Policy.setPolicy(p); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
133 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
134 |
System.setSecurityManager(new SecurityManager()); |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
135 |
ArrayList<Permission> perms1 = getPermissions(scl, p, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
136 |
"http://localhost/", |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
137 |
"foo.Foo", FOO_CLASS, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
138 |
null); |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
139 |
checkPerms(perms1, GRANTED_PERMS); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
140 |
ArrayList<Permission> perms2 = getPermissions(scl, p, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
141 |
"http://127.0.0.1/", |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
142 |
"bar.Bar", BAR_CLASS, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
143 |
null); |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
144 |
checkPerms(perms2, GRANTED_PERMS); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
145 |
assert(perms1.equals(perms2)); |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
146 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
147 |
// check that class signed by baz is granted an additional permission |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
148 |
Certificate[] chain = new Certificate[] {getCert(BAZ_CERT)}; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
149 |
ArrayList<Permission> perms3 = getPermissions(scl, p, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
150 |
"http://localhost/", |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
151 |
"baz.Baz", BAZ_CLASS, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
152 |
chain); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
153 |
List<Permission> perms = new ArrayList<>(Arrays.asList(GRANTED_PERMS)); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
154 |
perms.add(new PropertyPermission("user.dir", "read")); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
155 |
checkPerms(perms3, perms.toArray(new Permission[0])); |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
156 |
} |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
157 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
158 |
// returns the permissions granted to the codebase URL |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
159 |
private static ArrayList<Permission> getPermissions(MySecureClassLoader scl, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
160 |
Policy p, String url, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
161 |
String className, |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
162 |
String classBytes, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
163 |
Certificate[] chain) |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
164 |
throws IOException { |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
165 |
CodeSource cs = new CodeSource(new URL(url), chain); |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
166 |
Base64.Decoder bd = Base64.getDecoder(); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
167 |
byte[] bytes = bd.decode(classBytes); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
168 |
Class<?> c = scl.defineMyClass(className, bytes, cs); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
169 |
ProtectionDomain pd = c.getProtectionDomain(); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
170 |
return Collections.list(p.getPermissions(pd).elements()); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
171 |
} |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
172 |
|
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
173 |
private static void checkPerms(List<Permission> perms, |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
174 |
Permission... grantedPerms) |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
175 |
throws Exception |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
176 |
{ |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
177 |
if (!perms.containsAll(Arrays.asList(grantedPerms))) { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
178 |
throw new Exception("Granted permissions not correct"); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
179 |
} |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
180 |
} |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
181 |
|
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
182 |
private static Certificate getCert(String base64Cert) throws Exception { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
183 |
CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
184 |
InputStream is = new ByteArrayInputStream(base64Cert.getBytes("UTF-8")); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
185 |
return cf.generateCertificate(is); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
186 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
187 |
|
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
188 |
// A SecureClassLoader that allows the test to define its own classes |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
189 |
private static class MySecureClassLoader extends SecureClassLoader { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
190 |
Class<?> defineMyClass(String name, byte[] b, CodeSource cs) { |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
191 |
return super.defineClass(name, b, 0, b.length, cs); |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
192 |
} |
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
193 |
} |
31804
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
194 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
195 |
private static class TestProvider extends Provider { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
196 |
TestProvider() { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
197 |
super("Test8131486", 0.0, "For testing only"); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
198 |
putService(new Provider.Service(this, "KeyStore", "Test8131486", |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
199 |
"DefineClass$TestKeyStore", null, null)); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
200 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
201 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
202 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
203 |
/** |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
204 |
* A KeyStore containing a single certificate entry named "baz". |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
205 |
*/ |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
206 |
public static class TestKeyStore extends KeyStoreSpi { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
207 |
private final String baz = "baz"; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
208 |
private final List<String> aliases = Collections.singletonList(baz); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
209 |
private final Certificate bazCert; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
210 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
211 |
public TestKeyStore() { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
212 |
try { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
213 |
this.bazCert = getCert(BAZ_CERT); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
214 |
} catch (Exception e) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
215 |
throw new Error(); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
216 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
217 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
218 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
219 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
220 |
public Enumeration<String> engineAliases() { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
221 |
return Collections.enumeration(aliases); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
222 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
223 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
224 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
225 |
public boolean engineContainsAlias(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
226 |
return alias.equals(baz); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
227 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
228 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
229 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
230 |
public void engineDeleteEntry(String alias) throws KeyStoreException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
231 |
throw new KeyStoreException(); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
232 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
233 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
234 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
235 |
public Certificate engineGetCertificate(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
236 |
return alias.equals(baz) ? bazCert : null; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
237 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
238 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
239 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
240 |
public String engineGetCertificateAlias(Certificate cert) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
241 |
return cert.equals(bazCert) ? baz : null; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
242 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
243 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
244 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
245 |
public Certificate[] engineGetCertificateChain(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
246 |
return alias.equals(baz) ? new Certificate[] {bazCert} : null; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
247 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
248 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
249 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
250 |
public Date engineGetCreationDate(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
251 |
return alias.equals(baz) ? new Date() : null; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
252 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
253 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
254 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
255 |
public Key engineGetKey(String alias, char[] password) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
256 |
throws NoSuchAlgorithmException, UnrecoverableKeyException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
257 |
return null; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
258 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
259 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
260 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
261 |
public boolean engineIsCertificateEntry(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
262 |
return alias.equals(baz); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
263 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
264 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
265 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
266 |
public boolean engineIsKeyEntry(String alias) { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
267 |
return false; |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
268 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
269 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
270 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
271 |
public void engineLoad(InputStream stream, char[] password) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
272 |
throws IOException, NoSuchAlgorithmException, CertificateException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
273 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
274 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
275 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
276 |
public void engineSetCertificateEntry(String alias, Certificate cert) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
277 |
throws KeyStoreException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
278 |
throw new KeyStoreException(); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
279 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
280 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
281 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
282 |
public void engineSetKeyEntry(String alias, byte[] key, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
283 |
Certificate[] chain) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
284 |
throws KeyStoreException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
285 |
throw new KeyStoreException(); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
286 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
287 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
288 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
289 |
public void engineSetKeyEntry(String alias, Key key, char[] password, |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
290 |
Certificate[] chain) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
291 |
throws KeyStoreException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
292 |
throw new KeyStoreException(); |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
293 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
294 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
295 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
296 |
public int engineSize() { return 1; } |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
297 |
|
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
298 |
@Override |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
299 |
public void engineStore(OutputStream stream, char[] password) |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
300 |
throws IOException, NoSuchAlgorithmException, CertificateException { |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
301 |
} |
013c14047253
8131486: SecureClassLoader key for ProtectionDomain cache also needs to take into account certificates
mullan
parents:
31141
diff
changeset
|
302 |
} |
31141
ef5ddf021137
6826789: SecureClassLoader should not use CodeSource URLs as HashMap keys
mullan
parents:
diff
changeset
|
303 |
} |