001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.security;
019:
020: /**
021: * Static class used to preload java classes when using the
022: * Java SecurityManager so that the defineClassInPackage
023: * RuntimePermission does not trigger an AccessControlException.
024: *
025: * @author Glenn L. Nielsen
026: * @author Jean-Francois Arcand
027: * @version $Revision: 541991 $ $Date: 2007-05-27 16:02:36 +0200 (dim., 27 mai 2007) $
028: */
029:
030: public final class SecurityClassLoad {
031:
032: public static void securityClassLoad(ClassLoader loader)
033: throws Exception {
034:
035: if (System.getSecurityManager() == null) {
036: return;
037: }
038:
039: loadCorePackage(loader);
040: loadLoaderPackage(loader);
041: loadSessionPackage(loader);
042: loadUtilPackage(loader);
043: loadJavaxPackage(loader);
044: loadCoyotePackage(loader);
045: loadHttp11Package(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: loader
061: .loadClass(basePackage
062: + "core.ApplicationHttpRequest$AttributeNamesEnumerator");
063: }
064:
065: private final static void loadLoaderPackage(ClassLoader loader)
066: throws Exception {
067: String basePackage = "org.apache.catalina.";
068: loader.loadClass(basePackage
069: + "loader.WebappClassLoader$PrivilegedFindResource");
070: }
071:
072: private final static void loadSessionPackage(ClassLoader loader)
073: throws Exception {
074: String basePackage = "org.apache.catalina.";
075: loader.loadClass(basePackage + "session.StandardSession");
076: loader.loadClass(basePackage + "session.StandardSession$1");
077: loader.loadClass(basePackage
078: + "session.StandardManager$PrivilegedDoUnload");
079: }
080:
081: private final static void loadUtilPackage(ClassLoader loader)
082: throws Exception {
083: String basePackage = "org.apache.catalina.";
084: loader.loadClass(basePackage + "util.URL");
085: loader.loadClass(basePackage + "util.Enumerator");
086: }
087:
088: private final static void loadJavaxPackage(ClassLoader loader)
089: throws Exception {
090: loader.loadClass("javax.servlet.http.Cookie");
091: }
092:
093: private final static void loadHttp11Package(ClassLoader loader)
094: throws Exception {
095: String basePackage = "org.apache.coyote.http11.";
096: loader.loadClass(basePackage + "Http11Processor$1");
097: loader.loadClass(basePackage + "InternalOutputBuffer$1");
098: loader.loadClass(basePackage + "InternalOutputBuffer$2");
099: }
100:
101: private final static void loadCoyotePackage(ClassLoader loader)
102: throws Exception {
103: String basePackage = "org.apache.catalina.connector.";
104: loader.loadClass(basePackage
105: + "RequestFacade$GetAttributePrivilegedAction");
106: loader.loadClass(basePackage
107: + "RequestFacade$GetParameterMapPrivilegedAction");
108: loader.loadClass(basePackage
109: + "RequestFacade$GetRequestDispatcherPrivilegedAction");
110: loader.loadClass(basePackage
111: + "RequestFacade$GetParameterPrivilegedAction");
112: loader.loadClass(basePackage
113: + "RequestFacade$GetParameterNamesPrivilegedAction");
114: loader.loadClass(basePackage
115: + "RequestFacade$GetParameterValuePrivilegedAction");
116: loader.loadClass(basePackage
117: + "RequestFacade$GetCharacterEncodingPrivilegedAction");
118: loader.loadClass(basePackage
119: + "RequestFacade$GetHeadersPrivilegedAction");
120: loader.loadClass(basePackage
121: + "RequestFacade$GetHeaderNamesPrivilegedAction");
122: loader.loadClass(basePackage
123: + "RequestFacade$GetCookiesPrivilegedAction");
124: loader.loadClass(basePackage
125: + "RequestFacade$GetLocalePrivilegedAction");
126: loader.loadClass(basePackage
127: + "RequestFacade$GetLocalesPrivilegedAction");
128: loader.loadClass(basePackage
129: + "ResponseFacade$SetContentTypePrivilegedAction");
130: loader.loadClass(basePackage
131: + "ResponseFacade$DateHeaderPrivilegedAction");
132: loader.loadClass(basePackage
133: + "RequestFacade$GetSessionPrivilegedAction");
134: loader.loadClass(basePackage + "ResponseFacade$1");
135: loader.loadClass(basePackage + "OutputBuffer$1");
136: loader.loadClass(basePackage + "CoyoteInputStream$1");
137: loader.loadClass(basePackage + "CoyoteInputStream$2");
138: loader.loadClass(basePackage + "CoyoteInputStream$3");
139: loader.loadClass(basePackage + "CoyoteInputStream$4");
140: loader.loadClass(basePackage + "CoyoteInputStream$5");
141: loader.loadClass(basePackage + "InputBuffer$1");
142: loader.loadClass(basePackage + "Response$1");
143: loader.loadClass(basePackage + "Response$2");
144: loader.loadClass(basePackage + "Response$3");
145: }
146:
147: }
|