1561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/*
2561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  Licensed to the Apache Software Foundation (ASF) under one or more
3561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  contributor license agreements.  See the NOTICE file distributed with
4561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  this work for additional information regarding copyright ownership.
5561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  The ASF licenses this file to You under the Apache License, Version 2.0
6561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  (the "License"); you may not use this file except in compliance with
7561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  the License.  You may obtain a copy of the License at
8561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *
9561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *     http://www.apache.org/licenses/LICENSE-2.0
10561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *
11561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  Unless required by applicable law or agreed to in writing, software
12561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  distributed under the License is distributed on an "AS IS" BASIS,
13561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  See the License for the specific language governing permissions and
15561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes *  limitations under the License.
16561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */
17561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
18561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/**
19561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes* @author Alexander V. Astapchuk
20561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes*/
21561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
22561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughespackage java.security;
23561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
24561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport java.net.URL;
25561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport java.net.URLClassLoader;
26561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport java.nio.ByteBuffer;
27561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport java.security.cert.Certificate;
28561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
29561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport junit.framework.TestCase;
30561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
31561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
32561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/**
33561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Unit test for SecureClassLoader.
34e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes *
35561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */
36561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
37561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughespublic class SecureClassLoaderTest extends TestCase {
38561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
39561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
40e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes     * A class name for the class presented as {@link klassData bytecode below}
41561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
42561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    private static final String klassName = "HiWorld";
43561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
44561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
45561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Some class presented as bytecode<br>
46561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Class src:<br>
47561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * <p>
48561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * <code>public class HiWorld {
49e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes     * 	public static void main(String[] args)
50e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes     * 		{System.out.println("Hi, world!"); }
51561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     *	}
52561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * </code>
53561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
54561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
55561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    private static final byte[] klassData = { (byte) 0xCA, (byte) 0xFE,
56561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0xBA, (byte) 0xBE, (byte) 0x00, (byte) 0x00, (byte) 0x00,
57561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x2E, (byte) 0x00, (byte) 0x22, (byte) 0x01, (byte) 0x00,
58561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x07, (byte) 0x48, (byte) 0x69, (byte) 0x57, (byte) 0x6F,
59561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x07, (byte) 0x00,
60561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x6A,
61561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C,
62561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x4F,
63561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x62, (byte) 0x6A, (byte) 0x65, (byte) 0x63, (byte) 0x74,
64561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x07, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x00,
65561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x06, (byte) 0x3C, (byte) 0x69, (byte) 0x6E, (byte) 0x69,
66561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x74, (byte) 0x3E, (byte) 0x01, (byte) 0x00, (byte) 0x03,
67561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x28, (byte) 0x29, (byte) 0x56, (byte) 0x01, (byte) 0x00,
68561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x04, (byte) 0x43, (byte) 0x6F, (byte) 0x64, (byte) 0x65,
69561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x0C, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x06,
70561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x0A, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x08,
71561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x01, (byte) 0x00, (byte) 0x0F, (byte) 0x4C, (byte) 0x69,
72561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6E, (byte) 0x65, (byte) 0x4E, (byte) 0x75, (byte) 0x6D,
73561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x62, (byte) 0x65, (byte) 0x72, (byte) 0x54, (byte) 0x61,
74561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x01, (byte) 0x00,
75561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x12, (byte) 0x4C, (byte) 0x6F, (byte) 0x63, (byte) 0x61,
76561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6C, (byte) 0x56, (byte) 0x61, (byte) 0x72, (byte) 0x69,
77561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x54,
78561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x62, (byte) 0x6C, (byte) 0x65, (byte) 0x01,
79561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x04, (byte) 0x74, (byte) 0x68, (byte) 0x69,
80561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x73, (byte) 0x01, (byte) 0x00, (byte) 0x09, (byte) 0x4C,
81561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x48, (byte) 0x69, (byte) 0x57, (byte) 0x6F, (byte) 0x72,
82561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6C, (byte) 0x64, (byte) 0x3B, (byte) 0x01, (byte) 0x00,
83561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x04, (byte) 0x6D, (byte) 0x61, (byte) 0x69, (byte) 0x6E,
84561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x01, (byte) 0x00, (byte) 0x16, (byte) 0x28, (byte) 0x5B,
85561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,
86561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,
87561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,
88561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x29, (byte) 0x56,
89561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x01, (byte) 0x00, (byte) 0x10, (byte) 0x6A, (byte) 0x61,
90561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61,
91561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x79,
92561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x73, (byte) 0x74, (byte) 0x65, (byte) 0x6D, (byte) 0x07,
93561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x10, (byte) 0x01, (byte) 0x00, (byte) 0x03,
94561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6F, (byte) 0x75, (byte) 0x74, (byte) 0x01, (byte) 0x00,
95561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x15, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,
96561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x2F, (byte) 0x69, (byte) 0x6F, (byte) 0x2F,
97561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x50, (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x74,
98561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x65, (byte) 0x61,
99561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6D, (byte) 0x3B, (byte) 0x0C, (byte) 0x00, (byte) 0x12,
100561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x13, (byte) 0x09, (byte) 0x00, (byte) 0x11,
101561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x00, (byte) 0x0A,
102561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x48, (byte) 0x69, (byte) 0x2C, (byte) 0x20, (byte) 0x77,
103561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6F, (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x21,
104561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x08, (byte) 0x00, (byte) 0x16, (byte) 0x01, (byte) 0x00,
105561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x13, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,
106561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x2F, (byte) 0x69, (byte) 0x6F, (byte) 0x2F, (byte) 0x50,
107561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x74, (byte) 0x53,
108561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x74, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x6D,
109561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x07, (byte) 0x00, (byte) 0x18, (byte) 0x01, (byte) 0x00,
110561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x07, (byte) 0x70, (byte) 0x72, (byte) 0x69, (byte) 0x6E,
111561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x74, (byte) 0x6C, (byte) 0x6E, (byte) 0x01, (byte) 0x00,
112561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x15, (byte) 0x28, (byte) 0x4C, (byte) 0x6A, (byte) 0x61,
113561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61,
114561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74,
115561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B,
116561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x29, (byte) 0x56, (byte) 0x0C, (byte) 0x00, (byte) 0x1A,
117561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x1B, (byte) 0x0A, (byte) 0x00, (byte) 0x19,
118561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x1C, (byte) 0x01, (byte) 0x00, (byte) 0x04,
119561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x72, (byte) 0x67, (byte) 0x73, (byte) 0x01,
120561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x13, (byte) 0x5B, (byte) 0x4C, (byte) 0x6A,
121561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2F, (byte) 0x6C,
122561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x61, (byte) 0x6E, (byte) 0x67, (byte) 0x2F, (byte) 0x53,
123561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6E, (byte) 0x67,
124561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x3B, (byte) 0x01, (byte) 0x00, (byte) 0x0A, (byte) 0x53,
125561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6F, (byte) 0x75, (byte) 0x72, (byte) 0x63, (byte) 0x65,
126561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x46, (byte) 0x69, (byte) 0x6C, (byte) 0x65, (byte) 0x01,
127561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x0C, (byte) 0x48, (byte) 0x69, (byte) 0x57,
128561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6F, (byte) 0x72, (byte) 0x6C, (byte) 0x64, (byte) 0x2E,
129561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x00,
130561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x21, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x04,
131561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
132561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x05,
133561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00,
134561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x2F,
135561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
136561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x2A, (byte) 0xB7,
137561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x09, (byte) 0xB1, (byte) 0x00, (byte) 0x00,
138561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x0A, (byte) 0x00,
139561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01,
140561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x14, (byte) 0x00,
141561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C,
142561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
143561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x05, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x0D,
144561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x00,
145561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x0E, (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x01,
146561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00,
147561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x37, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x01,
148561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0xB2,
149561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x15, (byte) 0x12, (byte) 0x17, (byte) 0xB6,
150561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x1D, (byte) 0xB1, (byte) 0x00, (byte) 0x00,
151561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x0A, (byte) 0x00,
152561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x00, (byte) 0x02,
153561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00,
154561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x08, (byte) 0x00, (byte) 0x18, (byte) 0x00, (byte) 0x0B,
155561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C, (byte) 0x00,
156561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09,
157561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x1E, (byte) 0x00, (byte) 0x1F, (byte) 0x00,
158561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x20,
159561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00,
160561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes            (byte) 0x21, };
161561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
162561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
163561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Tests default ctor
164561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
165561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    public void testSecureClassLoader() {
166561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        new SecureClassLoader();
167561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    }
168561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
169561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
170561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Tests SecureClassLoader(ClassLoader)
171561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
172561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    public void testSecureClassLoaderClassLoader() throws Exception {
173561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        URL[] urls = new URL[] { new URL("http://localhost") };
174561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        URLClassLoader ucl = URLClassLoader.newInstance(urls);
175561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        new SecureClassLoader(ucl);
176561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    }
177561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
178561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
179561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Tests getPermission
180561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
181561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    public void testGetPermissions() throws Exception {
182561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        URL url = new URL("http://localhost");
183561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        CodeSource cs = new CodeSource(url, (Certificate[]) null);
184561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        SecureClassLoader ldr = new SecureClassLoader();
185561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        ldr.getPermissions(null);
186561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        ldr.getPermissions(cs);
187561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    }
188561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
189561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
190561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Tests defineClass(String, byte[], int, int, CodeSource)
191561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
192561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    public void testDefineClassStringbyteArrayintintCodeSource() {
193561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        SecureClassLoader ldr = new SecureClassLoader();
194561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        Class klass = ldr.defineClass(null, klassData, 0, klassData.length,
195561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes                null);
196561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        assertEquals(klass.getName(), klassName);
197561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    }
198561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes
199561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    /**
200561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     * Tests defineClass(String, ByteBuffer, CodeSource)
201561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes     */
202561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    public void testDefineClassStringByteBufferCodeSource() {
203561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        SecureClassLoader ldr = new SecureClassLoader();
204561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        ByteBuffer bbuf = ByteBuffer.wrap(klassData);
205561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        Class klass = ldr.defineClass(null, bbuf, null);
206561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes        assertEquals(klass.getName(), klassName);
207561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes    }
208561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes}
209