org.apache.catalina.security.SecurityClassLoad Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of payara-micro Show documentation
Show all versions of payara-micro Show documentation
Micro Distribution of the Payara Project for IBM JDK
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.security;
/**
* Static class used to preload java classes when using the
* Java SecurityManager so that the defineClassInPackage
* RuntimePermission does not trigger an AccessControlException.
*
* @author Glenn L. Nielsen
* @author Jean-Francois Arcand
* @version $Revision: 1.2 $ $Date: 2005/12/08 01:27:54 $
*/
public final class SecurityClassLoad {
public static void securityClassLoad(ClassLoader loader)
throws Exception {
if( System.getSecurityManager() == null ){
return;
}
loadCorePackage(loader);
loadLoaderPackage(loader);
loadServletsPackage(loader);
loadSessionPackage(loader);
loadUtilPackage(loader);
loadJavaxPackage(loader);
loadCoyotePackage(loader);
loadHttp11Package(loader);
loadTomcatPackage(loader);
}
private final static void loadCorePackage(ClassLoader loader)
throws Exception {
String basePackage = "org.apache.catalina.";
loader.loadClass
(basePackage +
"core.ApplicationContextFacade$1");
loader.loadClass
(basePackage +
"core.ApplicationDispatcher$PrivilegedForward");
loader.loadClass
(basePackage +
"core.ApplicationDispatcher$PrivilegedInclude");
loader.loadClass
(basePackage +
"core.ContainerBase$PrivilegedAddChild");
loader.loadClass
(basePackage +
"core.StandardWrapper$1");
}
private final static void loadLoaderPackage(ClassLoader loader)
throws Exception {
String basePackage = "org.apache.catalina.";
loader.loadClass
(basePackage +
"loader.WebappClassLoader$PrivilegedFindResource");
}
private static final void loadServletsPackage(ClassLoader loader)
throws Exception {
final String basePackage = "org.apache.catalina.servlets.";
// Avoid a possible memory leak in the DefaultServlet when running with
// a security manager. The DefaultServlet needs to load an XML parser
// when running under a security manager. We want this to be loaded by
// the container rather than a web application to prevent a memory leak
// via web application class loader.
loader.loadClass(basePackage + "DefaultServlet");
}
private final static void loadSessionPackage(ClassLoader loader)
throws Exception {
String basePackage = "org.apache.catalina.session.";
loader.loadClass(basePackage + "StandardSession");
loader.loadClass(basePackage + "StandardSession$1");
loader.loadClass(basePackage + "StandardManager$PrivilegedDoUnload");
}
private final static void loadUtilPackage(ClassLoader loader)
throws Exception {
String basePackage = "org.apache.catalina.";
loader.loadClass
(basePackage + "util.URL");
loader.loadClass(basePackage + "util.Enumerator");
}
private final static void loadJavaxPackage(ClassLoader loader)
throws Exception {
loader.loadClass("javax.servlet.http.Cookie");
}
private final static void loadHttp11Package(ClassLoader loader)
throws Exception {
String basePackage = "org.glassfish.grizzly.tcp.http11.";
loader.loadClass(basePackage + "Http11Processor$1");
loader.loadClass(basePackage + "InternalOutputBuffer$1");
loader.loadClass(basePackage + "InternalOutputBuffer$2");
}
private final static void loadCoyotePackage(ClassLoader loader)
throws Exception {
String basePackage = "org.apache.catalina.connector.";
loader.loadClass
(basePackage +
"RequestFacade$GetAttributePrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetParameterMapPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetRequestDispatcherPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetParameterPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetParameterNamesPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetParameterValuePrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetCharacterEncodingPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetHeadersPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetHeaderNamesPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetCookiesPrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetLocalePrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetLocalesPrivilegedAction");
loader.loadClass
(basePackage +
"ResponseFacade$SetContentTypePrivilegedAction");
loader.loadClass
(basePackage +
"RequestFacade$GetSessionPrivilegedAction");
loader.loadClass
(basePackage +
"ResponseFacade$1");
loader.loadClass
(basePackage +
"OutputBuffer$1");
loader.loadClass
(basePackage +
"CoyoteInputStream$1");
loader.loadClass
(basePackage +
"CoyoteInputStream$2");
loader.loadClass
(basePackage +
"CoyoteInputStream$3");
loader.loadClass
(basePackage +
"CoyoteInputStream$4");
loader.loadClass
(basePackage +
"CoyoteInputStream$5");
loader.loadClass
(basePackage +
"InputBuffer$1");
loader.loadClass
(basePackage +
"Response$1");
loader.loadClass
(basePackage +
"Response$2");
loader.loadClass
(basePackage +
"Response$3");
}
private final static void loadTomcatPackage(ClassLoader loader)
throws Exception {
String basePackage = "org.glassfish.grizzly.";
loader.loadClass(basePackage + "util.net.SSLSupport$CipherData");
// security
basePackage = "org.apache.tomcat.";
loader.loadClass(basePackage + "util.security.PrivilegedGetTccl");
loader.loadClass(basePackage + "util.security.PrivilegedSetTccl");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy