001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina.security;
018:
019: /**
020: * Static class used to preload java classes when using the
021: * Java SecurityManager so that the defineClassInPackage
022: * RuntimePermission does not trigger an AccessControlException.
023: *
024: * @author Glenn L. Nielsen
025: * @author Jean-Francois Arcand
026: * @version $Revision: 1.16 $ $Date: 2004/02/27 14:58:46 $
027: */
028:
029: public final class SecurityClassLoad {
030:
031: public static void securityClassLoad(ClassLoader loader)
032: throws Exception {
033:
034: if (System.getSecurityManager() == null) {
035: return;
036: }
037:
038: loadCorePackage(loader);
039: loadLoaderPackage(loader);
040: loadSessionPackage(loader);
041: loadUtilPackage(loader);
042: loadJavaxPackage(loader);
043: loadCoyotePackage(loader);
044: loadHttp11Package(loader);
045: loadJkPackage(loader);
046: }
047:
048: private final static void loadCorePackage(ClassLoader loader)
049: throws Exception {
050: String basePackage = "org.apache.catalina.";
051: loader.loadClass(basePackage
052: + "core.ApplicationContextFacade$1");
053: loader.loadClass(basePackage
054: + "core.ApplicationDispatcher$PrivilegedForward");
055: loader.loadClass(basePackage
056: + "core.ApplicationDispatcher$PrivilegedInclude");
057: loader.loadClass(basePackage
058: + "core.ContainerBase$PrivilegedAddChild");
059: loader.loadClass(basePackage + "core.StandardWrapper$1");
060: }
061:
062: private final static void loadLoaderPackage(ClassLoader loader)
063: throws Exception {
064: String basePackage = "org.apache.catalina.";
065: loader.loadClass(basePackage
066: + "loader.WebappClassLoader$PrivilegedFindResource");
067: }
068:
069: private final static void loadSessionPackage(ClassLoader loader)
070: throws Exception {
071: String basePackage = "org.apache.catalina.";
072: loader.loadClass(basePackage + "session.StandardSession");
073: loader.loadClass(basePackage + "session.StandardSession$1");
074: loader.loadClass(basePackage
075: + "session.StandardManager$PrivilegedDoUnload");
076: }
077:
078: private final static void loadUtilPackage(ClassLoader loader)
079: throws Exception {
080: String basePackage = "org.apache.catalina.";
081: loader.loadClass(basePackage + "util.URL");
082: loader.loadClass(basePackage + "util.Enumerator");
083: }
084:
085: private final static void loadJavaxPackage(ClassLoader loader)
086: throws Exception {
087: loader.loadClass("javax.servlet.http.Cookie");
088: }
089:
090: private final static void loadHttp11Package(ClassLoader loader)
091: throws Exception {
092: String basePackage = "org.apache.coyote.http11.";
093: loader.loadClass(basePackage + "Http11Processor$1");
094: loader.loadClass(basePackage + "InternalOutputBuffer$1");
095: loader.loadClass(basePackage + "InternalOutputBuffer$2");
096: }
097:
098: private final static void loadCoyotePackage(ClassLoader loader)
099: throws Exception {
100: String basePackage = "org.apache.coyote.tomcat5.";
101: loader.loadClass(basePackage
102: + "CoyoteRequestFacade$GetAttributePrivilegedAction");
103: loader
104: .loadClass(basePackage
105: + "CoyoteRequestFacade$GetParameterMapPrivilegedAction");
106: loader
107: .loadClass(basePackage
108: + "CoyoteRequestFacade$GetRequestDispatcherPrivilegedAction");
109: loader.loadClass(basePackage
110: + "CoyoteRequestFacade$GetParameterPrivilegedAction");
111: loader
112: .loadClass(basePackage
113: + "CoyoteRequestFacade$GetParameterNamesPrivilegedAction");
114: loader
115: .loadClass(basePackage
116: + "CoyoteRequestFacade$GetParameterValuePrivilegedAction");
117: loader
118: .loadClass(basePackage
119: + "CoyoteRequestFacade$GetCharacterEncodingPrivilegedAction");
120: loader.loadClass(basePackage
121: + "CoyoteRequestFacade$GetHeadersPrivilegedAction");
122: loader.loadClass(basePackage
123: + "CoyoteRequestFacade$GetHeaderNamesPrivilegedAction");
124: loader.loadClass(basePackage
125: + "CoyoteRequestFacade$GetCookiesPrivilegedAction");
126: loader.loadClass(basePackage
127: + "CoyoteRequestFacade$GetLocalePrivilegedAction");
128: loader.loadClass(basePackage
129: + "CoyoteRequestFacade$GetLocalesPrivilegedAction");
130: loader
131: .loadClass(basePackage
132: + "CoyoteResponseFacade$SetContentTypePrivilegedAction");
133: loader.loadClass(basePackage
134: + "CoyoteResponseFacade$DateHeaderPrivilegedAction");
135: loader.loadClass(basePackage
136: + "CoyoteRequestFacade$GetSessionPrivilegedAction");
137: loader.loadClass(basePackage + "CoyoteResponseFacade$1");
138: loader.loadClass(basePackage + "OutputBuffer$1");
139: loader.loadClass(basePackage + "CoyoteInputStream$1");
140: loader.loadClass(basePackage + "CoyoteInputStream$2");
141: loader.loadClass(basePackage + "CoyoteInputStream$3");
142: loader.loadClass(basePackage + "CoyoteInputStream$4");
143: loader.loadClass(basePackage + "CoyoteInputStream$5");
144: loader.loadClass(basePackage + "InputBuffer$1");
145: loader.loadClass(basePackage + "CoyoteResponse$1");
146: loader.loadClass(basePackage + "CoyoteResponse$2");
147: loader.loadClass(basePackage + "CoyoteResponse$3");
148: }
149:
150: private final static void loadJkPackage(ClassLoader loader)
151: throws Exception {
152: String basePackage = "org.apache.jk.";
153: loader.loadClass(basePackage + "server.JkCoyoteHandler$1");
154: loader.loadClass(basePackage
155: + "server.JkCoyoteHandler$StatusLinePrivilegedAction");
156: }
157: }
|