KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > security > SecurityClassLoad


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.security;
20
21 /**
22  * Static class used to preload java classes when using the
23  * Java SecurityManager so that the defineClassInPackage
24  * RuntimePermission does not trigger an AccessControlException.
25  *
26  * @author Glenn L. Nielsen
27  * @author Jean-Francois Arcand
28  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
29  */

30
31 public final class SecurityClassLoad {
32
33     public static void securityClassLoad(ClassLoader JavaDoc loader)
34         throws Exception JavaDoc {
35
36         if( System.getSecurityManager() == null ){
37             return;
38         }
39         
40         loadCorePackage(loader);
41         loadLoaderPackage(loader);
42         loadSessionPackage(loader);
43         loadUtilPackage(loader);
44         loadJavaxPackage(loader);
45         loadCoyotePackage(loader);
46         loadHttp11Package(loader);
47     }
48     
49     
50     private final static void loadCorePackage(ClassLoader JavaDoc loader)
51         throws Exception JavaDoc {
52         String JavaDoc basePackage = "org.apache.catalina.";
53         loader.loadClass
54             (basePackage +
55              "core.ApplicationContextFacade$1");
56         loader.loadClass
57             (basePackage +
58              "core.ApplicationDispatcher$PrivilegedForward");
59         loader.loadClass
60             (basePackage +
61              "core.ApplicationDispatcher$PrivilegedInclude");
62         loader.loadClass
63             (basePackage +
64              "core.ContainerBase$PrivilegedAddChild");
65         loader.loadClass
66             (basePackage +
67              "core.StandardWrapper$1");
68     }
69     
70     
71     private final static void loadLoaderPackage(ClassLoader JavaDoc loader)
72         throws Exception JavaDoc {
73         String JavaDoc basePackage = "org.apache.catalina.";
74         loader.loadClass
75             (basePackage +
76              "loader.WebappClassLoader$PrivilegedFindResource");
77     }
78     
79     
80     private final static void loadSessionPackage(ClassLoader JavaDoc loader)
81         throws Exception JavaDoc {
82         String JavaDoc basePackage = "org.apache.catalina.";
83         loader.loadClass
84             (basePackage + "session.StandardSession");
85         loader.loadClass
86             (basePackage +
87              "session.StandardSession$1");
88         loader.loadClass
89             (basePackage +
90              "session.StandardManager$PrivilegedDoUnload");
91     }
92     
93     
94     private final static void loadUtilPackage(ClassLoader JavaDoc loader)
95         throws Exception JavaDoc {
96         String JavaDoc basePackage = "org.apache.catalina.";
97         loader.loadClass
98             (basePackage + "util.URL");
99         loader.loadClass(basePackage + "util.Enumerator");
100     }
101     
102     
103     private final static void loadJavaxPackage(ClassLoader JavaDoc loader)
104         throws Exception JavaDoc {
105         loader.loadClass("javax.servlet.http.Cookie");
106     }
107     
108
109     private final static void loadHttp11Package(ClassLoader JavaDoc loader)
110         throws Exception JavaDoc {
111         String JavaDoc basePackage = "org.apache.coyote.http11.";
112         loader.loadClass(basePackage + "Http11Processor$1");
113         loader.loadClass(basePackage + "InternalOutputBuffer$1");
114         loader.loadClass(basePackage + "InternalOutputBuffer$2");
115     }
116     
117     
118     private final static void loadCoyotePackage(ClassLoader JavaDoc loader)
119         throws Exception JavaDoc {
120         String JavaDoc basePackage = "org.apache.catalina.connector.";
121         loader.loadClass
122             (basePackage +
123              "RequestFacade$GetAttributePrivilegedAction");
124         loader.loadClass
125             (basePackage +
126              "RequestFacade$GetParameterMapPrivilegedAction");
127         loader.loadClass
128             (basePackage +
129              "RequestFacade$GetRequestDispatcherPrivilegedAction");
130         loader.loadClass
131             (basePackage +
132              "RequestFacade$GetParameterPrivilegedAction");
133         loader.loadClass
134             (basePackage +
135              "RequestFacade$GetParameterNamesPrivilegedAction");
136         loader.loadClass
137             (basePackage +
138              "RequestFacade$GetParameterValuePrivilegedAction");
139         loader.loadClass
140             (basePackage +
141              "RequestFacade$GetCharacterEncodingPrivilegedAction");
142         loader.loadClass
143             (basePackage +
144              "RequestFacade$GetHeadersPrivilegedAction");
145         loader.loadClass
146             (basePackage +
147              "RequestFacade$GetHeaderNamesPrivilegedAction");
148         loader.loadClass
149             (basePackage +
150              "RequestFacade$GetCookiesPrivilegedAction");
151         loader.loadClass
152             (basePackage +
153              "RequestFacade$GetLocalePrivilegedAction");
154         loader.loadClass
155             (basePackage +
156              "RequestFacade$GetLocalesPrivilegedAction");
157         loader.loadClass
158             (basePackage +
159              "ResponseFacade$SetContentTypePrivilegedAction");
160         loader.loadClass
161             (basePackage +
162              "ResponseFacade$DateHeaderPrivilegedAction");
163         loader.loadClass
164             (basePackage +
165              "RequestFacade$GetSessionPrivilegedAction");
166         loader.loadClass
167             (basePackage +
168              "ResponseFacade$1");
169         loader.loadClass
170             (basePackage +
171              "OutputBuffer$1");
172         loader.loadClass
173             (basePackage +
174              "CoyoteInputStream$1");
175         loader.loadClass
176             (basePackage +
177              "CoyoteInputStream$2");
178         loader.loadClass
179             (basePackage +
180              "CoyoteInputStream$3");
181         loader.loadClass
182             (basePackage +
183              "CoyoteInputStream$4");
184         loader.loadClass
185             (basePackage +
186              "CoyoteInputStream$5");
187         loader.loadClass
188             (basePackage +
189              "InputBuffer$1");
190         loader.loadClass
191             (basePackage +
192              "Response$1");
193         loader.loadClass
194             (basePackage +
195              "Response$2");
196         loader.loadClass
197             (basePackage +
198              "Response$3");
199     }
200
201 }
202
203
Popular Tags